RSpec tests for your AWS resources.
Add this line to your application's Gemfile:
gem 'awspec'
And then execute:
$ bundle
Or install it yourself as:
$ gem install awspec
$ awspec init
$ aws configure
...
$ export AWS_REGION='ap-northeast-1'
$ cat <<EOF > spec/secrets.yml
region: ap-northeast-1
aws_access_key_id: XXXXXXXXXXXXXXXXXXXX
aws_secret_access_key: XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
EOF
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') }
it { should be_disabled_api_termination }
end
$ bundle exec rake spec
Generate spec from AWS resources already exists.
$ awspec generate ec2 vpc-ab123cde >> spec/ec2_spec.rb
- EC2 (
ec2
) - RDS (
rds
)- RDS DB Parameter Group (
rds_db_parameter_group
)
- RDS DB Parameter Group (
- Security Group (
security_group
) - VPC (
vpc
) - S3 (
s3
) - Route53
- Route53 Hosted Zone (
route53_hosted_zone
)
- Route53 Hosted Zone (
- AutoScaling
- Auto Scaling Group (
auto_scaling_group
)
- Auto Scaling Group (
- Subnet (
subnet
) - RouteTable (
route_table
) - EBS Volume (
ebs
) - ELB (
elb
) - Lambda (
lambda
) - IAM
- IAM User (
iam_user
) - IAM Group (
iam_group
) - IAM Role (
iam_role
) - IAM Policy (
iam_policy
)
- IAM User (
- ElastiCache (
elasticache
)- ElastiCache Cache Parameter Group (
elasticache_cache_parameter_group
)
- ElastiCache Cache Parameter Group (
- CloudWatch
- CloudWatch Alarm (
cloudwatch_alarm
)
- CloudWatch Alarm (
Resource Types more infomation here
- ...
awspec is inspired by Serverspec.
- Original idea (code / architecture) -> Serverspec
AWS + Serverspec
original concept -> https://github.com/marcy-terui/awspec- Serverspec book