Git Product home page Git Product logo

awspec-kitchen-terraform's Introduction

README

This repo contains:

  • An introduction to test driven infrastructure
  • An introduction to the basics of kitchen
  • An introduction to the basics of awspec
  • An introduction to the basics of terraform. requires version v0.10.2. sorry
  • An AWS lab to get you familiar with syntax and features

Prerequisites

  • brew install ruby
  • brew install ruby-dev
  • brew install terraform
  • gem install bundler --pre
  • gem install test-kitchen
  • gem install awsecrets
  • gem install awspec
  • bundle install --without showoff

Getting Up and Running

  • To present with deckrb please run this command:
bundle exec deck deck/01_awspec_kitchen_terraform.md
  • Once you have the server running go to localhost:4333 to access the training.

Licensing

Copyright 2017 Slalom LLC

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License

awspec-kitchen-terraform's People

Contributors

georgep-slalom avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

awspec-kitchen-terraform's Issues

Feedback on getting started with this Tutorial

Firstly, I want to say this is a really great resource. However, I had a few issues getting started so I'm feeding them back to you.

Problem: Doesn't work with ruby 2.5.0, but doesn't fail (it installs 0.3.0 of kitchen-terraform which is way old)
Solution: Use ruby < 2.5.0, eg. 2.4.3. I used rbenv to use 2.4.3 locally

Problem: The kitchen.yml example is not valid. It fails with:

>>>>>> Message: Kitchen::Driver::Terraform configuration: variables {:value=>["must be a hash which includes only symbol keys and string values"]}

Solution: Wrap the erb lines in quotes, eg.:

  variables:
    access_key: "<%= ENV['AWS_ACCESS_KEY_ID'] %>"
    secret_key: "<%= ENV['AWS_SECRET_ACCESS_KEY'] %>"

Alternatively, remove both access_key and secret_key entirely. If they are not specified, the aws provider reads them from ~/.aws.credentials directly.

Problem: terraform init is executed against the wrong dir:

$$$$$$ Running command `terraform init -input=false -lock=true -lock-timeout=0s  -upgrade -force-copy -backend=true  -get=true -get-plugins=true  -verify-plugins=true /Users/robin/code/awspec-kitchen-terraform-2

Solution: Wrong parameter in .kitchen.yml. Change directory to root_module_directory:

driver:
  name: terraform
  root_module_directory: tf

Remove terraform.tfstate.d and .terraform, and re-try

Problem: Error: Required variable not set: region
Solution: Set region on the command line

TF_VAR_region=us-west-1 bundle exec kitchen verify

Alternatively, remove region variable and use AWS_DEFAULT_REGION environment variable on the command line:

AWS_DEFAULT_REGION=us-west-1 bundle exec kitchen verify

Problem: I need to switch to a specific IAM profile when running AWS commands.
Solution: Specify this on the command line:

AWS_DEFAULT_REGION=us-west-1 AWS_PROFILE=engineering bundle exec kitchen verify

The tests now function, and I can start working through the exercises.

I've updated my fork of this repo with my changes: https://github.com/yo61/awspec-kitchen-terraform

Hope this is useful to you!

Thanks again for the tutorial.

Questions on how to implement?

Hi! Thanks so much for this, I found it very useful. I had a couple of quick questions for you:

  • Do you set up and teardown the environment each time, or do you leave your environment running?
  • I'm new to Test Kitchen and I don't understand it very well. It appears to be a generalized tool for setting up, testing, and destroying infrastructure, but it seems like these features are all also available in Terraform. Does it offer anything I'm missing?
  • In my own setup, my tests are working pretty well, but they also seem a little brittle--if the test needs the ID or IP address of the thing being tested (like a nat_gateway or an eip) I need to create the thing first, then get the IP/IP and add it to the test, then run the test. Any way around this? Is there a way to read the input vars, or query the resources, so I don't have to hardcode things into the tests?

Thanks again for the slideshow and any advice you can offer.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.