“It is not the strongest of the species that survive, nor the most intelligent, but the one most responsive to change.” — Charles Darwin

“DevOps is a set of practice that seeks to reduce the gap between software development and software operation.”


Use Cloud and DevOps to build immutable infrastructure by agile development using collaborative open source tools:
-Terraform or Cloud Formation for infrastructure provisioning and scaling.
-Packer for building server images or containers using:
-chef cookbooks, puppet modules or ansible playbooks to build servers.

Verify AWS Infrastructure with Test Kitchen and awspec

Test-kitchen is a test harness tool that allows integration testing of configuration and infrastructure.

It has a plug-in architecture and has plugins for both Cloud Formation and terraform to create AWS infrastructure. For plugin details see kitchen-terraform and kitchen-cloudformation.

awspec is a tool that allows RSpec tests for AWS resources. For plugin details see kitchen-awspec.

There is a simple example in the kitchen-awspec github repository to demonstrate creating an EC2 instance with cloud formation and then verifying it with awspec. See https://github.com/neillturner/kitchen-verifier-awspec/tree/master/example

1. Install test-kitchen as per http://kitchen.ci/docs/getting-started/installing
  basically install ruby for your platform
  then to install test-kitchen
      gem install test-kitchen

  and the cloud formation or terraform plugin:
      gem install kitchen-cloudformation or gem install kitchen-terraform

  and the awspec plugin
      gem install kitchen-verifier-awspec

2. Use git to clone the github kitchen-awspec repository.
    git clone https://github.com/neillturner/kitchen-verifier-awspec.git

3. Run the example on your workstation:

a. Configuration AWS Settings
    See Configuration Settings and Precedence
For example:
    # configure aws keys via either a profile
    export AWS_DEFAULT_PROFILE=myprofile
    # or set keys directly
    export AWS_ACCESS_KEY_ID=myaccesskey
    export AWS_SECRET_ACCESS_KEY=mysecretkey

    # set aws region
    export AWS_REGION=eu-west-1

b. Go to example directory
    cd kitchen-verifier-awspec/example

c. For windows set the ssl cert file
    set SSL_CERT_FILE=C:/repository/kitchen-verifier-awspec/example/ca-bundle.crt

d. Check that everything installed successfully
    kitchen list
should return the base-aws instance

e. Create the Cloud Formation stack
    kitchen create base-aws -l debug

f. Verify the AWS Resources
    kitchen verify base-aws -l debug

g. Delete the Cloud Formation stack
    kitchen destroy base-aws -l debug

References
http://www.slideshare.net/stelligent/testdriven-infrastructure
http://www.slideshare.net/dkcwd/validating-puppet-managed-resources-in-aws-with-awspec
https://www.newcontext.com/introducing-kitchen-terraform/
https://www.unixdaemon.net/cloud/testing-terraform-projects/
http://koesystems.github.io/terraform-best-practices/

0 comments:

Post a Comment