Skip to content

Commit 83874fa

Browse files
authored
Update testing framework, other maintenance (#18)
1 parent d7c0277 commit 83874fa

14 files changed

+1052
-324
lines changed

.github/CODEOWNERS

+2-2
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@
1515

1616
# Cloud Posse must review any changes to standard context definition,
1717
# but some changes can be rubber-stamped.
18-
**/*.tf @cloudposse/engineering @cloudposse/approvers
19-
README.yaml @cloudposse/engineering @cloudposse/approvers
18+
**/*.tf @cloudposse/engineering @cloudposse/contributors @cloudposse/approvers
19+
README.yaml @cloudposse/engineering @cloudposse/contributors @cloudposse/approvers
2020
README.md @cloudposse/engineering @cloudposse/contributors @cloudposse/approvers
2121
docs/*.md @cloudposse/engineering @cloudposse/contributors @cloudposse/approvers
2222

.github/auto-release.yml

+2-1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ version-resolver:
1717
- 'bugfix'
1818
- 'bug'
1919
- 'hotfix'
20+
- 'no-release'
2021
default: 'minor'
2122

2223
categories:
@@ -46,7 +47,7 @@ template: |
4647
4748
replacers:
4849
# Remove irrelevant information from Renovate bot
49-
- search: '/---\s+^#.*Renovate configuration(?:.|\n)*?This PR has been generated .*/gm'
50+
- search: '/(?<=---\s)\s*^#.*(Renovate configuration|Configuration)(?:.|\n)*?This PR has been generated .*/gm'
5051
replace: ''
5152
# Remove Renovate bot banner image
5253
- search: '/\[!\[[^\]]*Renovate\][^\]]*\](\([^)]*\))?\s*\n+/gm'

README.md

+20-121
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11

22
<!-- markdownlint-disable -->
3-
# terraform-example-module [![Latest Release](https://img.shields.io/github/release/cloudposse/terraform-example-module.svg)](https://github.com/cloudposse/terraform-example-module/releases/latest) [![Slack Community](https://slack.cloudposse.com/badge.svg)](https://slack.cloudposse.com) [![Discourse Forum](https://img.shields.io/discourse/https/ask.sweetops.com/posts.svg)](https://ask.sweetops.com/)
3+
# terraform-example-module
44
<!-- markdownlint-restore -->
55

66
[![README Header][readme_header_img]][readme_header_link]
@@ -28,8 +28,9 @@
2828
2929
-->
3030

31-
This is `terraform-example-module` project provides all the scaffolding for a typical well-built Cloud Posse module. It's a template repository you can
32-
use when creating new repositories.
31+
This is an example project to provide all the scaffolding for a typical well-built Cloud Posse
32+
Terraform module for AWS resources. It's a template repository you can
33+
use when creating new repositories. This is not a useful module by itself.
3334

3435
---
3536

@@ -80,113 +81,22 @@ Security scanning is graciously provided by Bridgecrew. Bridgecrew is the leadin
8081

8182

8283

83-
## Usage
8484

85+
## Quick Start
8586

86-
**IMPORTANT:** We do not pin modules to versions in our examples because of the
87-
difficulty of keeping the versions in the documentation in sync with the latest released versions.
88-
We highly recommend that in your code you pin the version to the exact version you are
89-
using so that your infrastructure remains stable, and update versions in a
90-
systematic way so that they do not catch you by surprise.
87+
1. Use this repo as a template for a new repo.
88+
2. Check out the new repo and create a `git` branch to work on.
89+
3. Replace the Terraform code at the root of the repo with the code you want to publish.
90+
4. Replace the code in `examples/complete` with Terraform code that will make a good automated test.
91+
Please keep `context.tf` and `fixtures.us-east-2.tfvars` in place and change only `name`, leaving
92+
`region`, `namespace`, `environment`, and `stage` as is. Provide outputs that will be useful for testing.
93+
5. Update `test/src/examples_complete_test.go` to verify the outputs of running `terraform apply` on `examples/complete`.
94+
6. Run `make github/init` to update the repo with the current Cloud Posse framework files (e.g. `CODEOWNERS`).
95+
7. Run `make pr/auto-format` to format the Terraform code and generate documentation.
96+
8. Commit everything to `git` and open your first PR on the new repo.
9197

92-
Also, because of a bug in the Terraform registry ([hashicorp/terraform#21417](https://github.com/hashicorp/terraform/issues/21417)),
93-
the registry shows many of our inputs as required when in fact they are optional.
94-
The table below correctly indicates which inputs are required.
9598

9699

97-
For a complete example, see [examples/complete](examples/complete).
98-
99-
For automated tests of the complete example using [bats](https://github.com/bats-core/bats-core) and [Terratest](https://github.com/gruntwork-io/terratest)
100-
(which tests and deploys the example on AWS), see [test](test).
101-
102-
```hcl
103-
module "example" {
104-
source = "https://github.com/cloudposse/terraform-example-module.git?ref=master"
105-
example = "Hello world!"
106-
}
107-
```
108-
109-
110-
111-
112-
## Examples
113-
114-
Here is an example of using this module:
115-
- [`examples/complete`](https://github.com/cloudposse/terraform-example-module/) - complete example of using this module
116-
117-
118-
119-
<!-- markdownlint-disable -->
120-
## Makefile Targets
121-
```text
122-
Available targets:
123-
124-
help Help screen
125-
help/all Display help for all targets
126-
help/short This help short screen
127-
lint Lint terraform code
128-
129-
```
130-
<!-- markdownlint-restore -->
131-
<!-- markdownlint-disable -->
132-
## Requirements
133-
134-
| Name | Version |
135-
|------|---------|
136-
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 0.13 |
137-
| <a name="requirement_local"></a> [local](#requirement\_local) | >= 1.2 |
138-
| <a name="requirement_random"></a> [random](#requirement\_random) | >= 2.2 |
139-
140-
## Providers
141-
142-
| Name | Version |
143-
|------|---------|
144-
| <a name="provider_random"></a> [random](#provider\_random) | >= 2.2 |
145-
146-
## Modules
147-
148-
| Name | Source | Version |
149-
|------|--------|---------|
150-
| <a name="module_this"></a> [this](#module\_this) | cloudposse/label/null | 0.25.0 |
151-
152-
## Resources
153-
154-
| Name | Type |
155-
|------|------|
156-
| [random_integer.example](https://registry.terraform.io/providers/hashicorp/random/latest/docs/resources/integer) | resource |
157-
158-
## Inputs
159-
160-
| Name | Description | Type | Default | Required |
161-
|------|-------------|------|---------|:--------:|
162-
| <a name="input_additional_tag_map"></a> [additional\_tag\_map](#input\_additional\_tag\_map) | Additional key-value pairs to add to each map in `tags_as_list_of_maps`. Not added to `tags` or `id`.<br>This is for some rare cases where resources want additional configuration of tags<br>and therefore take a list of maps with tag key, value, and additional configuration. | `map(string)` | `{}` | no |
163-
| <a name="input_attributes"></a> [attributes](#input\_attributes) | ID element. Additional attributes (e.g. `workers` or `cluster`) to add to `id`,<br>in the order they appear in the list. New attributes are appended to the<br>end of the list. The elements of the list are joined by the `delimiter`<br>and treated as a single ID element. | `list(string)` | `[]` | no |
164-
| <a name="input_context"></a> [context](#input\_context) | Single object for setting entire context at once.<br>See description of individual variables for details.<br>Leave string and numeric variables as `null` to use default value.<br>Individual variable settings (non-null) override settings in context object,<br>except for attributes, tags, and additional\_tag\_map, which are merged. | `any` | <pre>{<br> "additional_tag_map": {},<br> "attributes": [],<br> "delimiter": null,<br> "descriptor_formats": {},<br> "enabled": true,<br> "environment": null,<br> "id_length_limit": null,<br> "label_key_case": null,<br> "label_order": [],<br> "label_value_case": null,<br> "labels_as_tags": [<br> "unset"<br> ],<br> "name": null,<br> "namespace": null,<br> "regex_replace_chars": null,<br> "stage": null,<br> "tags": {},<br> "tenant": null<br>}</pre> | no |
165-
| <a name="input_delimiter"></a> [delimiter](#input\_delimiter) | Delimiter to be used between ID elements.<br>Defaults to `-` (hyphen). Set to `""` to use no delimiter at all. | `string` | `null` | no |
166-
| <a name="input_descriptor_formats"></a> [descriptor\_formats](#input\_descriptor\_formats) | Describe additional descriptors to be output in the `descriptors` output map.<br>Map of maps. Keys are names of descriptors. Values are maps of the form<br>`{<br> format = string<br> labels = list(string)<br>}`<br>(Type is `any` so the map values can later be enhanced to provide additional options.)<br>`format` is a Terraform format string to be passed to the `format()` function.<br>`labels` is a list of labels, in order, to pass to `format()` function.<br>Label values will be normalized before being passed to `format()` so they will be<br>identical to how they appear in `id`.<br>Default is `{}` (`descriptors` output will be empty). | `any` | `{}` | no |
167-
| <a name="input_enabled"></a> [enabled](#input\_enabled) | Set to false to prevent the module from creating any resources | `bool` | `null` | no |
168-
| <a name="input_environment"></a> [environment](#input\_environment) | ID element. Usually used for region e.g. 'uw2', 'us-west-2', OR role 'prod', 'staging', 'dev', 'UAT' | `string` | `null` | no |
169-
| <a name="input_example"></a> [example](#input\_example) | Example variable | `string` | `"hello world"` | no |
170-
| <a name="input_id_length_limit"></a> [id\_length\_limit](#input\_id\_length\_limit) | Limit `id` to this many characters (minimum 6).<br>Set to `0` for unlimited length.<br>Set to `null` for keep the existing setting, which defaults to `0`.<br>Does not affect `id_full`. | `number` | `null` | no |
171-
| <a name="input_label_key_case"></a> [label\_key\_case](#input\_label\_key\_case) | Controls the letter case of the `tags` keys (label names) for tags generated by this module.<br>Does not affect keys of tags passed in via the `tags` input.<br>Possible values: `lower`, `title`, `upper`.<br>Default value: `title`. | `string` | `null` | no |
172-
| <a name="input_label_order"></a> [label\_order](#input\_label\_order) | The order in which the labels (ID elements) appear in the `id`.<br>Defaults to ["namespace", "environment", "stage", "name", "attributes"].<br>You can omit any of the 6 labels ("tenant" is the 6th), but at least one must be present. | `list(string)` | `null` | no |
173-
| <a name="input_label_value_case"></a> [label\_value\_case](#input\_label\_value\_case) | Controls the letter case of ID elements (labels) as included in `id`,<br>set as tag values, and output by this module individually.<br>Does not affect values of tags passed in via the `tags` input.<br>Possible values: `lower`, `title`, `upper` and `none` (no transformation).<br>Set this to `title` and set `delimiter` to `""` to yield Pascal Case IDs.<br>Default value: `lower`. | `string` | `null` | no |
174-
| <a name="input_labels_as_tags"></a> [labels\_as\_tags](#input\_labels\_as\_tags) | Set of labels (ID elements) to include as tags in the `tags` output.<br>Default is to include all labels.<br>Tags with empty values will not be included in the `tags` output.<br>Set to `[]` to suppress all generated tags.<br>**Notes:**<br> The value of the `name` tag, if included, will be the `id`, not the `name`.<br> Unlike other `null-label` inputs, the initial setting of `labels_as_tags` cannot be<br> changed in later chained modules. Attempts to change it will be silently ignored. | `set(string)` | <pre>[<br> "default"<br>]</pre> | no |
175-
| <a name="input_name"></a> [name](#input\_name) | ID element. Usually the component or solution name, e.g. 'app' or 'jenkins'.<br>This is the only ID element not also included as a `tag`.<br>The "name" tag is set to the full `id` string. There is no tag with the value of the `name` input. | `string` | `null` | no |
176-
| <a name="input_namespace"></a> [namespace](#input\_namespace) | ID element. Usually an abbreviation of your organization name, e.g. 'eg' or 'cp', to help ensure generated IDs are globally unique | `string` | `null` | no |
177-
| <a name="input_regex_replace_chars"></a> [regex\_replace\_chars](#input\_regex\_replace\_chars) | Terraform regular expression (regex) string.<br>Characters matching the regex will be removed from the ID elements.<br>If not set, `"/[^a-zA-Z0-9-]/"` is used to remove all characters other than hyphens, letters and digits. | `string` | `null` | no |
178-
| <a name="input_stage"></a> [stage](#input\_stage) | ID element. Usually used to indicate role, e.g. 'prod', 'staging', 'source', 'build', 'test', 'deploy', 'release' | `string` | `null` | no |
179-
| <a name="input_tags"></a> [tags](#input\_tags) | Additional tags (e.g. `{'BusinessUnit': 'XYZ'}`).<br>Neither the tag keys nor the tag values will be modified by this module. | `map(string)` | `{}` | no |
180-
| <a name="input_tenant"></a> [tenant](#input\_tenant) | ID element \_(Rarely used, not included by default)\_. A customer identifier, indicating who this instance of a resource is for | `string` | `null` | no |
181-
182-
## Outputs
183-
184-
| Name | Description |
185-
|------|-------------|
186-
| <a name="output_example"></a> [example](#output\_example) | Example output |
187-
| <a name="output_id"></a> [id](#output\_id) | ID of the created example |
188-
| <a name="output_random"></a> [random](#output\_random) | Stable random number for this example |
189-
<!-- markdownlint-restore -->
190100

191101

192102

@@ -202,17 +112,17 @@ Are you using this project or any of our other projects? Consider [leaving a tes
202112

203113
Check out these related projects.
204114

205-
- [terraform-null-label](https://github.com/cloudposse/terraform-null-label) - Terraform module designed to generate consistent names and tags for resources. Use terraform-null-label to implement a strict naming convention.
115+
- [Example App](https://github.com/cloudposse/example-app) - Example application for CI/CD demonstrations of Codefresh
206116

207117

208118
## References
209119

210120
For additional context, refer to some of these links.
211121

212-
- [Terraform Standard Module Structure](https://www.terraform.io/docs/modules/index.html#standard-module-structure) - HashiCorp's standard module structure is a file and directory layout we recommend for reusable modules distributed in separate repositories.
122+
- [Cloud Posse Documentation](https://docs.cloudposse.com) - The Cloud Posse Developer Hub (documentation)
123+
- [Terraform Standard Module Structure](https://www.terraform.io/docs/language/modules/develop/structure.html) - HashiCorp's standard module structure is a file and directory layout we recommend for reusable modules distributed in separate repositories.
213124
- [Terraform Module Requirements](https://www.terraform.io/docs/registry/modules/publish.html#requirements) - HashiCorp's guidance on all the requirements for publishing a module. Meeting the requirements for publishing a module is extremely easy.
214-
- [Terraform `random_integer` Resource](https://registry.terraform.io/providers/hashicorp/random/latest/docs/resources/integer) - The resource random_integer generates random values from a given range, described by the min and max attributes of a given resource.
215-
- [Terraform Version Pinning](https://www.terraform.io/docs/configuration/terraform.html#specifying-a-required-terraform-version) - The required_version setting can be used to constrain which versions of the Terraform CLI can be used with your configuration
125+
- [Terraform Version Pinning](https://www.terraform.io/docs/language/settings/index.html#specifying-a-required-terraform-version) - The required_version setting can be used to constrain which versions of the Terraform CLI can be used with your configuration
216126

217127

218128
## Help
@@ -287,7 +197,7 @@ In general, PRs are welcome. We follow the typical "fork-and-pull" Git workflow.
287197

288198
## Copyrights
289199

290-
Copyright © 2020-2021 [Cloud Posse, LLC](https://cloudposse.com)
200+
Copyright © 2021-2021 [Cloud Posse, LLC](https://cloudposse.com)
291201

292202

293203

@@ -343,17 +253,6 @@ We offer [paid support][commercial_support] on all of our projects.
343253
Check out [our other projects][github], [follow us on twitter][twitter], [apply for a job][jobs], or [hire us][hire] to help with your cloud strategy and implementation.
344254

345255

346-
347-
### Contributors
348-
349-
<!-- markdownlint-disable -->
350-
| [![Erik Osterman][osterman_avatar]][osterman_homepage]<br/>[Erik Osterman][osterman_homepage] |
351-
|---|
352-
<!-- markdownlint-restore -->
353-
354-
[osterman_homepage]: https://github.com/osterman
355-
[osterman_avatar]: https://img.cloudposse.com/150x150/https://github.com/osterman.png
356-
357256
[![README Footer][readme_footer_img]][readme_footer_link]
358257
[![Beacon][beacon]][website]
359258

0 commit comments

Comments
 (0)