github.com/terraform-modules-krish/terratest@v0.29.0/examples/terraform-aws-s3-example/README.md (about) 1 # Terraform AWS S3 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 an [S3 5 Bucket](https://aws.amazon.com/s3/) and gives that Bucket a `Name` & `Environment` tag with the value specified in the 6 `tag_bucket_name` and `tag_bucket_environment` variables, respectively. This module also contains a terraform variable 7 that will create a basic bucket policy that will restrict the bucket to only accept SSL connections. 8 9 Check out [test/terraform_aws_s3_example_test.go](https://github.com/terraform-modules-krish/terratest/blob/v0.29.0/test/terraform_aws_s3_example_test.go) to see how you can write 10 automated tests for this module. 11 12 Note that the S3 Bucket in this module will not contain any actual objects/files after creation; it will only contain a 13 versioning configuration, as well as tags. For slightly more complicated, real-world examples of Terraform modules (with 14 other AWS services), see [terraform-http-example](https://github.com/terraform-modules-krish/terratest/blob/v0.29.0/examples/terraform-http-example) and 15 [terraform-ssh-example](https://github.com/terraform-modules-krish/terratest/blob/v0.29.0/examples/terraform-ssh-example). 16 17 **WARNING**: This module and the automated tests for it deploy real resources into your AWS account which can cost you 18 money. The resources are all part of the [AWS Free Tier](https://aws.amazon.com/free/), so if you haven't used that up, 19 it should be free, but you are completely responsible for all AWS charges. 20 21 22 23 24 25 ## Running this module manually 26 27 1. Sign up for [AWS](https://aws.amazon.com/). 28 1. Configure your AWS credentials using one of the [supported methods for AWS CLI 29 tools](https://docs.aws.amazon.com/cli/latest/userguide/cli-chap-getting-started.html), such as setting the 30 `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". 31 1. Set the AWS region you want to use as the environment variable `AWS_DEFAULT_REGION`. 32 1. Install [Terraform](https://www.terraform.io/) and make sure it's on your `PATH`. 33 1. Run `terraform init`. 34 1. Run `terraform apply`. 35 1. When you're done, run `terraform destroy`. 36 37 38 39 40 ## Running automated tests against this module 41 42 1. Sign up for [AWS](https://aws.amazon.com/). 43 1. Configure your AWS credentials using one of the [supported methods for AWS CLI 44 tools](https://docs.aws.amazon.com/cli/latest/userguide/cli-chap-getting-started.html), such as setting the 45 `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". 46 1. Install [Terraform](https://www.terraform.io/) and make sure it's on your `PATH`. 47 1. Install [Golang](https://golang.org/) and make sure this code is checked out into your `GOPATH`. 48 1. `cd test` 49 1. `dep ensure` 50 1. `go test -v -run TestTerraformAwsS3Example`