awspec
RSpec tests for your AWS resources.
Installation
Add this line to your application's Gemfile:
gem 'awspec'
And then execute:
$ bundle
Or install it yourself as:
$ gem install awspec
Getting Started
1. Generate awspec init files
$ awspec init
2. Set AWS credentials
2-1. Use Shared Credentials
$ aws configure
...
$ export AWS_REGION='ap-northeast-1'
2-2. Use spec/secrets.yml
$ cat <<EOF > spec/secrets.yml
region: ap-northeast-1
aws_access_key_id: XXXXXXXXXXXXXXXXXXXX
aws_secret_access_key: XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
EOF
3. Write spec/*_spec.rb
describe ec2('my-ec2-tag-name') do
it { should be_running }
its(:instance_id) { should eq 'i-ec12345a' }
its(:image_id) { should eq 'ami-abc12def' }
its(:public_ip_address) { should eq '123.0.456.789' }
it { should have_security_group('my-security-group-name') }
it { should belong_to_vpc('my-vpc') }
it { should belong_to_subnet('subnet-1234a567') }
it { should have_eip('123.0.456.789') }
end
4. Run tests
$ bundle exec rake spec
Advanced Usage: Spec generate command
Generate spec from AWS resources already exists.
$ awspec generate ec2 vpc-ab123cde >> spec/ec2_spec.rb
Support AWS Resources
- [x] EC2 (
ec2
) - [x] RDS (
rds
)- [x] RDS DB Parameter Group (
rds_db_parameter_group
)
- [x] RDS DB Parameter Group (
- [x] Security Group (
security_group
) - [x] VPC (
vpc
) - [x] S3 (
s3
) - Route53
- [x] Route53 Hosted Zone (
route53_hosted_zone
)
- [x] Route53 Hosted Zone (
- AutoScaling
- [x] Auto Scaling Group (
auto_scaling_group
)
- [x] Auto Scaling Group (
- [x] Subnet (
subnet
) - [x] RouteTable (
route_table
) - [x] EBS Volume (
ebs
) - [x] ELB (
elb
) - [x] Lambda (
lambda
)
Resource Types more infomation here
Next..
- IAM
- [ ] IAM User
- ...
Contributing
- Fork it ( https://github.com/k1LoW/awspec/fork )
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create a new Pull Request
How to add new resource type (ex. Redshift resource)
- Create your feature branch (
git checkout -b add-type-redshift
) - Generate template files (
bundle exec ./lib/awspec/bin/toolbox template redshift
) - Fill files with code.
- Generate doc/resource_types.md (
bundle exec ./lib/awspec/bin/toolbox docgen > doc/resource_type.md
) - Run test (
bundle exec rake spec
) - Push to the branch (
git push origin add-type-redshift
) - Create a new Pull Request
References
awspec is inspired by Serverspec.
- Original idea (code / architecture) -> Serverspec
AWS + Serverspec
original concept -> https://github.com/marcy-terui/awspec- Serverspec book