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
...
$ cat <<EOF > spec/secrets.yml
region: ap-northeast-1
aws_access_key_id: XXXXXXXXXXXXXXXXXXXX
aws_secret_access_key: XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
EOF
require 'spec_helper'
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
require 'spec_helper'
describe sqs('my-sqs-queue'), region: 'us-west-2' do
it { should exist }
its(:queue_url) { should eq 'https://sqs.us-west-2.amazonaws.com/xxxxxxxxxxxx/my-sqs-queue' }
its(:queue_arn) { should eq 'arn:aws:sqs:us-west-2:xxxxxxxxxxxx:my-sqs-queue' }
its(:visibility_timeout) { should eq '30' }
its(:maximum_message_size) { should eq '256000' }
its(:message_retention_period) { should eq '86400' }
its(:delay_seconds) { should eq '0' }
its(:receive_message_wait_time_seconds) { should eq '10' }
end
$ bundle exec rake spec
Generate spec from AWS resources already exists.
$ awspec generate ec2 vpc-ab123cde >> spec/ec2_spec.rb
$ awspec generate ec2 vpc-ab123cde --profile mycreds
$ AWS_PROFILE=mycreds bundle exec rake spec
Resource Types infomation here
Dependent on awsecrets.
awspec is inspired by Serverspec.
- Original idea (code / architecture) -> Serverspec
AWS + Serverspec
original concept -> https://github.com/marcy-terui/awspec- Serverspec book