Giter VIP home page Giter VIP logo

terraform-test-using-terratest's Introduction

Terraform AWS EC2 & S3 Deployment with IAC Testing using Terratest, and Github Actions for Code Validation

This folder contains a simple Terraform module that deploys resources in AWS to demonstrate how you can use Terratest to write automated tests for your AWS Terraform code. This module deploys an S3 Bucket - and an EC2 Instance. This module gives both Bucket and Instance a Name & Owner tag with the value specified as Flugel and InfraTeam, respectively. This module also contains a terraform variable that will create a basic bucket policy that will restrict the "origin" bucket to only accept SSL connections.

Note that the S3 Buckets in this module will not contain any actual objects/files after creation; they will only contain a versioning and logging configuration, as well as tags.

WARNING: This module and the automated tests for it deploy real resources into your AWS account which can cost you money. The resources are all part of the AWS Free Tier, so if you haven't used that up, it should be free, but you are completely responsible for all AWS charges.

Running this module manually

  1. Sign up for AWS.
  2. Configure your AWS credentials using one of the supported methods for AWS CLI tools, such as setting the AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY environment variables. If you're using the ~/.aws/config file for profiles then export AWS_SDK_LOAD_CONFIG as "True".
  3. Set the AWS region you want to use as the environment variable AWS_DEFAULT_REGION.
  4. Install Terraform and make sure it's on your PATH.
  5. Run terraform init.
  6. Run terraform apply.
  7. When you're done, run terraform destroy.

Running automated tests against this module

  1. Sign up for AWS.
  2. Configure your AWS credentials using one of the supported methods for AWS CLI tools, such as setting the AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY environment variables. If you're using the ~/.aws/config file for profiles then export AWS_SDK_LOAD_CONFIG as "True".
  3. Install Terraform and make sure it's on your PATH.
  4. Install Golang and make sure this code is checked out into your GOPATH.
  5. cd test
  6. go mod init github.com/bobaddey/Terraform-test-using-terratest .
  7. go mod tidy
  8. go test -v -run TestTerraformAwsS3Example
  9. go test -v -run estTerraformAwsHelloWorldExampleT

terraform-test-using-terratest's People

Contributors

bobaddey avatar

Watchers

 avatar

Forkers

nimblenitin

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.