Skip to content
/ awspec Public
forked from k1LoW/awspec

RSpec tests for your AWS resources.

License

Notifications You must be signed in to change notification settings

ceaess/awspec

 
 

Repository files navigation

awspec Gem Travis Scrutinizer Gemnasium

Logo

RSpec tests for your AWS resources.

Join the chat at https://gitter.im/k1LoW/awspec

Resource Types | Contributing

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

STEP 1. Generate awspec init files

$ awspec init

STEP 2. Set AWS config

2-1. Use Shared Credentials like AWS CLI

$ aws configure

...

(See http://docs.aws.amazon.com/ja_jp/cli/latest/userguide/cli-chap-getting-started.html#config-settings-and-precedence)

2-2. Use secrets.yml

$ cat <<EOF > spec/secrets.yml
region: ap-northeast-1
aws_access_key_id: XXXXXXXXXXXXXXXXXXXX
aws_secret_access_key: XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
EOF

STEP 3. Write spec/*_spec.rb

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

STEP 4. Run tests

$ bundle exec rake spec

Advanced Tips: Spec generate command

Generate spec from AWS resources already exists.

$ awspec generate ec2 vpc-ab123cde >> spec/ec2_spec.rb

Advanced Tips: Use Shared Credentials (~/.aws/config ~/.aws/credentials)

$ awspec generate ec2 vpc-ab123cde --profile mycreds
$ AWS_PROFILE=mycreds bundle exec rake spec

Support AWS Resources

Resource Types infomation here

References

awspec is inspired by Serverspec.

About

RSpec tests for your AWS resources.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Ruby 100.0%