|
| 1 | +# Creating modules for AWS I&A Organization |
| 2 | + |
| 3 | +This repo template is used to seed Terraform Module templates for the [AWS I&A GitHub organization](https://github.com/aws-ia). Usage of this template is allowed per included license. PRs to this template will be considered but are not guaranteed to be included. Consider creating an issue to discuss a feature you want to include before taking the time to create a PR. |
| 4 | + |
| 5 | +<!-- markdownlint-disable MD001 --> |
| 6 | +### TL;DR |
| 7 | + |
| 8 | +1. [install pre-commit](https://pre-commit.com/#install) |
| 9 | + - Prerequisites: |
| 10 | + - [Python](https://docs.python.org/3/using/index.html) |
| 11 | + - [Pip](https://pip.pypa.io/en/stable/installation/) |
| 12 | +2. configure pre-commit: `pre-commit install` |
| 13 | +3. install required tools |
| 14 | + - [tflint](https://github.com/terraform-linters/tflint) |
| 15 | + - [tfsec](https://aquasecurity.github.io/tfsec/v1.0.11/) |
| 16 | + - [terraform-docs](https://github.com/terraform-docs/terraform-docs) |
| 17 | + - [golang](https://go.dev/doc/install) (for macos you can use `brew`) |
| 18 | + - [coreutils](https://www.gnu.org/software/coreutils/) |
| 19 | + |
| 20 | +Write code according to [I&A module standards](https://aws-ia.github.io/standards-terraform/) |
| 21 | + |
| 22 | +## Module Documentation |
| 23 | + |
| 24 | +**Do not manually update README.md**. README.md is automatically generated by pulling in content from other files. For instructions, including a fill-in-the-blank content template, see [Create readmes for Terraform-based Partner Solutions.](https://aws-ia-us-west-2.s3.us-west-2.amazonaws.com/docs/content/index.html#/lessons/8rpYWWL59M7dcS-NsjYmaISUu-L_UqEv) |
| 25 | + |
| 26 | +## Terratest |
| 27 | + |
| 28 | +Please include tests to validate your examples/<> root modules, at a minimum. This can be accomplished with usually only slight modifications to the [boilerplate test provided in this template](./test/examples_basic_test.go) |
| 29 | + |
| 30 | +### Configure and run Terratest |
| 31 | + |
| 32 | +1. Install |
| 33 | + |
| 34 | + [golang](https://go.dev/doc/install) (for macos you can use `brew`) |
| 35 | +2. Change directory into the test folder. |
| 36 | + |
| 37 | + `cd test` |
| 38 | +3. Initialize your test |
| 39 | + |
| 40 | + go mod init github.com/[github org]/[repository] |
| 41 | + |
| 42 | + `go mod init github.com/aws-ia/terraform-aws-vpc` |
| 43 | +4. Run tidy |
| 44 | + |
| 45 | + `go mod tidy` |
| 46 | +5. Install Terratest |
| 47 | + |
| 48 | + `go get github.com/gruntwork-io/terratest/modules/terraform` |
| 49 | +6. Run test (You can have multiple test files). |
| 50 | + - Run all tests |
| 51 | + |
| 52 | + `go test` |
| 53 | + - Run a specific test with a timeout |
| 54 | + |
| 55 | + `go test -run TestExamplesBasic -timeout 45m` |
| 56 | + |
| 57 | +## Module Standards |
| 58 | + |
| 59 | +For best practices and information on developing with Terraform, see the [I&A Module Standards](https://aws-ia.github.io/standards-terraform/) |
| 60 | + |
| 61 | +## Continuous Integration |
| 62 | + |
| 63 | +The I&A team uses AWS CodeBuild to perform continuous integration (CI) within the organization. Our CI uses the a repo's `.pre-commit-config.yaml` file as well as some other checks. All PRs with other CI will be rejected. See our [FAQ](https://aws-ia.github.io/standards-terraform/faq/#are-modules-protected-by-ci-automation) for more details. |
0 commit comments