github.com/terraform-modules-krish/terratest@v0.29.0/examples/terraform-ssh-example/README.md (about) 1 # Terraform SSH Example 2 3 This folder contains a simple Terraform module that deploys resources in [AWS](https://aws.amazon.com/) to demonstrate 4 how you can use Terratest to write automated tests for your AWS Terraform code. This module deploys two [EC2 5 Instances](https://aws.amazon.com/ec2/), one with a public IP, one with a private IP, in the AWS region specified in 6 the `aws_region` variable. The EC2 Instances allow SSH requests on the port specified by the `ssh_port` variable. 7 8 Check out [test/terraform_ssh_example_test.go](https://github.com/terraform-modules-krish/terratest/blob/v0.29.0/test/terraform_ssh_example_test.go) to see how you can write 9 automated tests for this module. 10 11 Note that the example in this module is still fairly simplified, as the EC2 Instance doesn't do a whole lot! For a more 12 complicated, real-world, end-to-end example of a Terraform module and web server, see 13 [terraform-packer-example](https://github.com/terraform-modules-krish/terratest/blob/v0.29.0/examples/terraform-packer-example). 14 15 **WARNING**: This module and the automated tests for it deploy real resources into your AWS account which can cost you 16 money. The resources are all part of the [AWS Free Tier](https://aws.amazon.com/free/), so if you haven't used that up, 17 it should be free, but you are completely responsible for all AWS charges. 18 19 20 21 22 23 ## Running this module manually 24 25 1. Sign up for [AWS](https://aws.amazon.com/). 26 1. Configure your AWS credentials using one of the [supported methods for AWS CLI 27 tools](https://docs.aws.amazon.com/cli/latest/userguide/cli-chap-getting-started.html), such as setting the 28 `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". 29 1. Install [Terraform](https://www.terraform.io/) and make sure it's on your `PATH`. 30 1. Run `terraform init`. 31 1. Run `terraform apply`. 32 1. When you're done, run `terraform destroy`. 33 34 35 36 37 ## Running automated tests against this module 38 39 1. Sign up for [AWS](https://aws.amazon.com/). 40 1. Configure your AWS credentials using one of the [supported methods for AWS CLI 41 tools](https://docs.aws.amazon.com/cli/latest/userguide/cli-chap-getting-started.html), such as setting the 42 `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". 43 1. Install [Terraform](https://www.terraform.io/) and make sure it's on your `PATH`. 44 1. Install [Golang](https://golang.org/) and make sure this code is checked out into your `GOPATH`. 45 1. `cd test` 46 1. `dep ensure` 47 1. `go test -v -run TestTerraformSshExample`