Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/dod-iac/terraform-module-template
Terraform Module Template
https://github.com/dod-iac/terraform-module-template
terraform terraform-modules
Last synced: 3 days ago
JSON representation
Terraform Module Template
- Host: GitHub
- URL: https://github.com/dod-iac/terraform-module-template
- Owner: dod-iac
- License: other
- Created: 2021-03-11T23:09:32.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2022-04-29T16:51:29.000Z (over 2 years ago)
- Last Synced: 2023-03-05T20:42:53.000Z (over 1 year ago)
- Topics: terraform, terraform-modules
- Language: Shell
- Homepage:
- Size: 73.2 KB
- Stars: 14
- Watchers: 5
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Terraform Module template
This repository is meant to be a template for creating new terraform modules.
## Creating a new Terraform Module
1. Clone this repo, renaming appropriately.
1. Write your terraform code in the root dir.
1. Ensure you've completed the [Developer Setup](#developer-setup).
1. In the root dir, modify the `module` line for the repo path. Then run `make tidy`, which updates the `go.sum` file and downloads dependencies.
1. Update the terratest tests in the examples and test directories.
1. Run your terratest tests to ensure they work as expected using instructions below.---
## Description
Please put a description of what this module does here
## Usage
Add Usage information here
Resources:
* [Article Example](https://article.example.com)
```hcl
module "example" {
source = "dod-iac/example/aws"tags = {
Project = var.project
Application = var.application
Environment = var.environment
Automation = "Terraform"
}
}
```## Testing
Run all terratest tests using the `terratest` script. If using `aws-vault`, you could use `aws-vault exec $AWS_PROFILE -- terratest`. The `AWS_DEFAULT_REGION` environment variable is required by the tests. Use `TT_SKIP_DESTROY=1` to not destroy the infrastructure created during the tests. Use `TT_VERBOSE=1` to log all tests as they are run. Use `TT_TIMEOUT` to set the timeout for the tests, with the value being in the Go format, e.g., 15m. The go test command can be executed directly, too.
## Terraform Version
Terraform 0.13. Pin module version to ~> 1.0.0 . Submit pull-requests to master branch.
Terraform 0.11 and 0.12 are not supported.
## License
This project constitutes a work of the United States Government and is not subject to domestic copyright protection under 17 USC § 105. However, because the project utilizes code licensed from contributors and other third parties, it therefore is licensed under the MIT License. See LICENSE file for more information.
## Developer Setup
This template is configured to use aws-vault, direnv, go, pre-commit, terraform-docs, and tfenv. If using Homebrew on macOS, you can install the dependencies using the following code.
```shell
brew install aws-vault direnv go pre-commit terraform-docs tfenv
pre-commit install --install-hooks
```If using `direnv`, add a `.envrc.local` that sets the default AWS region, e.g., `export AWS_DEFAULT_REGION=us-west-2`.
If using `tfenv`, then add a `.terraform-version` to the project root dir, with the version you would like to use.
## Requirements
| Name | Version |
|------|---------|
| [terraform](#requirement\_terraform) | >= 0.13 |
| [aws](#requirement\_aws) | ~> 3.0 |## Providers
| Name | Version |
|------|---------|
| [aws](#provider\_aws) | ~> 3.0 |## Modules
No modules.
## Resources
| Name | Type |
|------|------|
| [aws_caller_identity.current](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/caller_identity) | data source |
| [aws_iam_account_alias.current](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_account_alias) | data source |
| [aws_partition.current](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/partition) | data source |
| [aws_region.current](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/region) | data source |## Inputs
| Name | Description | Type | Default | Required |
|------|-------------|------|---------|:--------:|
| [tags](#input\_tags) | Tags applied to the AWS resources. | `map(string)` | `{}` | no |## Outputs
No outputs.