All Projects → k1LoW → Awspec

k1LoW / Awspec

Licence: mit
RSpec tests for your AWS resources.

Programming Languages

ruby
36898 projects - #4 most used programming language

Labels

Projects that are alternatives of or similar to Awspec

Aws Testing Library
Chai (https://chaijs.com) and Jest (https://jestjs.io/) assertions for testing services built with aws
Stars: ✭ 52 (-95.21%)
Mutual labels:  aws
Lambda Audio
Run Sound eXchange (SoX), the Swiss Army knife of audio manipulation, with Lame on AWS Lambda
Stars: ✭ 53 (-95.12%)
Mutual labels:  aws
Aws Well Architected Labs
Hands on labs and code to help you learn, measure, and build using architectural best practices.
Stars: ✭ 1,077 (-0.83%)
Mutual labels:  aws
Aws Utilities
Docker images and scripts to deploy to AWS
Stars: ✭ 52 (-95.21%)
Mutual labels:  aws
Terraform Aws Vpc Peering Multi Account
Terraform module to provision a VPC peering across multiple VPCs in different accounts by using multiple providers
Stars: ✭ 52 (-95.21%)
Mutual labels:  aws
Aws Rfdk
The Render Farm Deployment Kit on AWS is a library for use with the AWS Cloud Development Kit that helps you define your render farm cloud infrastructure as code.
Stars: ✭ 54 (-95.03%)
Mutual labels:  aws
Aws Power Tuner Ui
AWS Lambda Power Tuner UI is an open source project creating a deployable easy to use website built on a layered technology stack allowing you to optimize your Lambda functions for cost and/or performance in a data-driven way via an easy to use UI.
Stars: ✭ 52 (-95.21%)
Mutual labels:  aws
Aws Sdk Java V2
The official AWS SDK for Java - Version 2
Stars: ✭ 1,083 (-0.28%)
Mutual labels:  aws
Terraform Aws Alb
Terraform module to provision a standard ALB for HTTP/HTTP traffic
Stars: ✭ 53 (-95.12%)
Mutual labels:  aws
Aws Cdk Github Actions
Stars: ✭ 55 (-94.94%)
Mutual labels:  aws
Awsrun
CLI and library to execute commands over one or more AWS accounts concurrently.
Stars: ✭ 53 (-95.12%)
Mutual labels:  aws
Ec2connect
Stars: ✭ 53 (-95.12%)
Mutual labels:  aws
Lifion Kinesis
A native Node.js producer and consumer library for Amazon Kinesis Data Streams
Stars: ✭ 54 (-95.03%)
Mutual labels:  aws
Loom
Loom enables operations engineers to provide a self-serve Kubernetes provisioning experience for developers
Stars: ✭ 52 (-95.21%)
Mutual labels:  aws
Reinvent2018 Dev303 Code
Code accompanying AWS re:Invent workshop DEV 303 showcasing how to get deep application insights using Amazon EKS with AWS X-Ray and Amazon CloudWatch.
Stars: ✭ 55 (-94.94%)
Mutual labels:  aws
Simples3
Simple no frills AWS S3 Golang Library using REST with V4 Signing (without AWS Go SDK)
Stars: ✭ 51 (-95.3%)
Mutual labels:  aws
Saw
Fast, multi-purpose tool for AWS CloudWatch Logs
Stars: ✭ 1,071 (-1.38%)
Mutual labels:  aws
Examples
Infrastructure, containers, and serverless apps to AWS, Azure, GCP, and Kubernetes... all deployed with Pulumi
Stars: ✭ 1,085 (-0.09%)
Mutual labels:  aws
Jsii
jsii allows code in any language to naturally interact with JavaScript classes. It is the technology that enables the AWS Cloud Development Kit to deliver polyglot libraries from a single codebase!
Stars: ✭ 1,080 (-0.55%)
Mutual labels:  aws
Bootcamp 2021
Fusing Serverless Cloud Computing, Infrastructure as Code, Graph Databases, AI, and IoT Technologies and preparing for Operation Unicorn Startups
Stars: ✭ 55 (-94.94%)
Mutual labels:  aws

awspec Gem Travis

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

If you're starting on a fresh RSpec project, you can use awspec to generate your init files:

$ awspec init

If you're working on an exisitng RSpec project, you will need to add the following lines to your spec_helper.rb file:

require 'awspec'
Awsecrets.load(secrets_path: File.expand_path('./secrets.yml', File.dirname(__FILE__)))

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

Using shared_context: region

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

Using terraform outputs as identifier

Especially in cases, where resources created by terraform have the same names (e.g. created by VPC module), it is helpful to use terraform outputs as unique identifiers.

output "my_ec2_instance" {
    value = aws_instance.my_instance.id
}
require 'spec_helper'

my_ec2_instance = `terraform output my_ec2_instance`.strip

describe ec2(my_ec2_instance) do
  it { should be_running }
  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

Add gem "rake" in your Gemfile if you are starting a blank project.

$ 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

Make sure you have added in your spec file

require 'spec_helper'

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

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

Advanced Tips: Configuring the AWS client retries

The ClientWrap class provides mechanisms for retrying AWS API calls when it receives a RequestLimitExceeded error. ClientWrap implements a backoff algorithm where the client will sleep for successively longer periods of time until the algorithm has calculated a backoff greater than or equal to the backoff_limit, at which point it will give up and re-raise the error. You can see the full implementation in ClientWrap#method_missing.

You can configure this retry and backoff logic in your spec_helper.rb:

require 'awspec'

# These are the defaults, but you can change them.
Awspec.configure do |config|
  config.client_backoff 0.0
  config.client_backoff_limit 30
  config.client_iteration 1
end

Support AWS Resources

Resource Types information here

awspec AWS key/secrets precedence

Dependent on awsecrets.

References

awspec is inspired by Serverspec.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].