Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Validating Puppet managed resources in AWS with awspec


Published on

Slides from the presentation at the August 2016 Sydney Puppet User Group meet up.

The session provided an overview of how to get started with using awspec to validate your AWS infrastructure while giving some extra context around why these kinds of tests can be valuable regardless of whether using Puppet to manage configuration or not.

Group event page:

Published in: Software
  • Be the first to comment

  • Be the first to like this

Validating Puppet managed resources in AWS with awspec

  1. 1. Validating Puppet managed resources with awspec Get started with rspec testing for AWS resources Twitter: @dkcwd
  2. 2. First a little background….
  3. 3. About this session When I talk about managing resources in AWS I’m talking about the servers and other services we are leveraging in AWS. The concepts of testing resources, whether in AWS or not, is relevant regardless of whether you are using Puppet or not. After the session, you know more about with the awspec library.
  4. 4. About this session We have people of all levels of experience in this session. Please feel free to share your knowledge and experience with the group and ask questions.
  5. 5. Why test our resources? ?
  6. 6. Why test our resources? Once the resources have been “spun up” and configured, the test suite can be run to verify resources are in line with expectations. CI tools can alert the team to issues which need attention. $$$ money can be saved….
  7. 7. Why test our resources? Resource tests can be considered part of fulfilling a contract with the business. Demonstrating the resources are ready could be as simple as ensuring the typical ports are exposed for a web server and that a page containing some specific text can be loaded within a specific timeframe.
  8. 8. Why test our resources? In the context of managing your Software Development Life Cycle (SDLC) Before we deploy an application to our infrastructure we want to know that the environment is correctly configured. Unexpected behavior can result from leveraging configuration data which has been included in error.
  9. 9. But Puppet describes the desired config! Yes! And if you are using Hiera, you are likely to be including extra data conditionally Sometimes people make mistakes….
  10. 10. A hypothetical situation You’re managing your network settings with Puppet and you have conditionally configured the value of resolve.conf The DNS settings which have been incorrectly supplied are appropriate for London when they should be settings which are appropriate for China.
  11. 11. Ok, so let’s talk about awspec….
  12. 12. Make sure you find the right library
  13. 13. Based on Serverspec
  14. 14. Some set up is required To become more familiar with awspec you should do the following: Set up an AWS account for testing Set up an IAM user, noting the access key and secret access key Install the AWS tools and run the ``aws configure`` command See:
  15. 15. Spin up an AWS EC2 instance When a new instance has been loaded test the command line config ``aws ec2 describe-instances`` See:
  16. 16. Install some Ruby dependencies Install RVM to make it easier to use different versions of Ruby See:
  17. 17. Follow the awspec guide The instructions explain what you need to do to write your tests See:
  18. 18. Try auto-generating a test The instructions explain what you need to do to write your tests See:
  19. 19. The result of auto-generation Base Dockerfile installing the Will project
  20. 20. There is a minor adjustment required Base Dockerfile installing the Will project Need to include a line at the top of the file to include the helper script.
  21. 21. Add the helper script if necessary This is required for the awspec methods to work correctly.
  22. 22. Run your example test Run your test suite. Note: in this case I wanted to see the exit code.
  23. 23. Run your example test You should see your tests passing. If not, you’ll need to debug.
  24. 24. So what should we test? Great question! That was a simple example to get you started. Take time to understand what expectations you can define. Here is a good question to get you in a testing mindset…. What would make you sleep better than knowing that configuration has been correctly applied?
  25. 25. Enjoy and share what you do…. I’m on Twitter: @dkcwd LinkedIn: