Skip to content

Commit 9e96d46

Browse files
authored
Update to standard context, go mods, and GitHub config (#97)
1 parent ace20c4 commit 9e96d46

File tree

23 files changed

+576
-355
lines changed

23 files changed

+576
-355
lines changed

.github/CODEOWNERS

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,6 @@
1212

1313
# Cloud Posse must review any changes to GitHub actions
1414
.github/* @cloudposse/engineering
15+
16+
# Cloud Posse must review any changes to standard context definition
17+
**/context.tf @cloudposse/engineering

.github/auto-release.yml

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
name-template: 'v$RESOLVED_VERSION'
2+
tag-template: '$RESOLVED_VERSION'
3+
version-template: '$MAJOR.$MINOR.$PATCH'
4+
version-resolver:
5+
major:
6+
labels:
7+
- 'major'
8+
minor:
9+
labels:
10+
- 'minor'
11+
- 'enhancement'
12+
patch:
13+
labels:
14+
- 'patch'
15+
- 'fix'
16+
- 'bugfix'
17+
- 'bug'
18+
- 'hotfix'
19+
default: 'minor'
20+
21+
categories:
22+
- title: '🚀 Enhancements'
23+
labels:
24+
- 'enhancement'
25+
- title: '🐛 Bug Fixes'
26+
labels:
27+
- 'fix'
28+
- 'bugfix'
29+
- 'bug'
30+
- 'hotfix'
31+
32+
change-template: |
33+
<details>
34+
<summary>$TITLE @$AUTHOR (#$NUMBER)</summary>
35+
36+
$BODY
37+
</details>
38+
39+
template: |
40+
$CHANGES

.github/workflows/auto-release.yml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
name: auto-release
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
8+
jobs:
9+
semver:
10+
runs-on: ubuntu-latest
11+
steps:
12+
# Drafts your next Release notes as Pull Requests are merged into "master"
13+
- uses: release-drafter/release-drafter@v5
14+
with:
15+
publish: true
16+
prerelease: false
17+
config-name: auto-release.yml
18+
env:
19+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/chatops.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,13 @@ jobs:
99
steps:
1010
- uses: actions/checkout@v2
1111
- name: "Handle common commands"
12-
uses: cloudposse/actions/github/slash-command-dispatch@0.15.0
12+
uses: cloudposse/actions/github/slash-command-dispatch@0.16.0
1313
with:
1414
token: ${{ secrets.PUBLIC_REPO_ACCESS_TOKEN }}
1515
reaction-token: ${{ secrets.GITHUB_TOKEN }}
1616
repository: cloudposse/actions
1717
commands: rebuild-readme, terraform-fmt
18-
permission: none
18+
permission: triage
1919
issue-type: pull-request
2020

2121
test:
@@ -24,13 +24,13 @@ jobs:
2424
- name: "Checkout commit"
2525
uses: actions/checkout@v2
2626
- name: "Run tests"
27-
uses: cloudposse/actions/github/slash-command-dispatch@0.15.0
27+
uses: cloudposse/actions/github/slash-command-dispatch@0.16.0
2828
with:
2929
token: ${{ secrets.PUBLIC_REPO_ACCESS_TOKEN }}
3030
reaction-token: ${{ secrets.GITHUB_TOKEN }}
3131
repository: cloudposse/actions
3232
commands: test
33-
permission: none
33+
permission: triage
3434
issue-type: pull-request
3535
reactions: false
3636

README.md

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ Available targets:
178178
| Name | Version |
179179
|------|---------|
180180
| terraform | >= 0.12.0, < 0.14.0 |
181-
| aws | ~> 2.0 |
181+
| aws | >= 2.0, < 4.0 |
182182
| local | ~> 1.2 |
183183
| null | ~> 2.0 |
184184
| template | ~> 2.0 |
@@ -187,41 +187,42 @@ Available targets:
187187

188188
| Name | Version |
189189
|------|---------|
190-
| aws | ~> 2.0 |
190+
| aws | >= 2.0, < 4.0 |
191191

192192
## Inputs
193193

194194
| Name | Description | Type | Default | Required |
195195
|------|-------------|------|---------|:--------:|
196-
| additional\_tag\_map | Additional tags for appending to each tag map | `map(string)` | `{}` | no |
197-
| attributes | Any extra attributes for naming these resources | `list(string)` | `[]` | no |
196+
| additional\_tag\_map | Additional tags for appending to tags\_as\_list\_of\_maps. Not added to `tags`. | `map(string)` | `{}` | no |
197+
| attributes | Additional attributes (e.g. `1`) | `list(string)` | `[]` | no |
198198
| availability\_zones | List of Availability Zones where subnets will be created | `list(string)` | n/a | yes |
199199
| aws\_route\_create\_timeout | Time to wait for AWS route creation specifed as a Go Duration, e.g. `2m` | `string` | `"2m"` | no |
200200
| aws\_route\_delete\_timeout | Time to wait for AWS route deletion specifed as a Go Duration, e.g. `5m` | `string` | `"5m"` | no |
201201
| cidr\_block | Base CIDR block which will be divided into subnet CIDR blocks (e.g. `10.0.0.0/16`) | `string` | n/a | yes |
202-
| context | Default context to use for passing state between label invocations | <pre>object({<br> namespace = string<br> environment = string<br> stage = string<br> name = string<br> enabled = bool<br> delimiter = string<br> attributes = list(string)<br> label_order = list(string)<br> tags = map(string)<br> additional_tag_map = map(string)<br> regex_replace_chars = string<br> })</pre> | <pre>{<br> "additional_tag_map": {},<br> "attributes": [],<br> "delimiter": "",<br> "enabled": true,<br> "environment": "",<br> "label_order": [],<br> "name": "",<br> "namespace": "",<br> "regex_replace_chars": "",<br> "stage": "",<br> "tags": {}<br>}</pre> | no |
203-
| delimiter | Delimiter to be used between `namespace`, `stage`, `name` and `attributes` | `string` | `"-"` | no |
204-
| enabled | Set to false to prevent the module from creating any resources | `bool` | `true` | no |
205-
| environment | The environment name if not using stage | `string` | `""` | no |
202+
| 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. | <pre>object({<br> enabled = bool<br> namespace = string<br> environment = string<br> stage = string<br> name = string<br> delimiter = string<br> attributes = list(string)<br> tags = map(string)<br> additional_tag_map = map(string)<br> regex_replace_chars = string<br> label_order = list(string)<br> id_length_limit = number<br> })</pre> | <pre>{<br> "additional_tag_map": {},<br> "attributes": [],<br> "delimiter": null,<br> "enabled": true,<br> "environment": null,<br> "id_length_limit": null,<br> "label_order": [],<br> "name": null,<br> "namespace": null,<br> "regex_replace_chars": null,<br> "stage": null,<br> "tags": {}<br>}</pre> | no |
203+
| delimiter | Delimiter to be used between `namespace`, `environment`, `stage`, `name` and `attributes`.<br>Defaults to `-` (hyphen). Set to `""` to use no delimiter at all. | `string` | `null` | no |
204+
| enabled | Set to false to prevent the module from creating any resources | `bool` | `null` | no |
205+
| environment | Environment, e.g. 'uw2', 'us-west-2', OR 'prod', 'staging', 'dev', 'UAT' | `string` | `null` | no |
206206
| existing\_nat\_ips | Existing Elastic IPs to attach to the NAT Gateway or Instance instead of creating a new one. | `list(string)` | `[]` | no |
207+
| id\_length\_limit | Limit `id` to this many characters.<br>Set to `0` for unlimited length.<br>Set to `null` for default, which is `0`.<br>Does not affect `id_full`. | `number` | `null` | no |
207208
| igw\_id | Internet Gateway ID the public route table will point to (e.g. `igw-9c26a123`) | `string` | n/a | yes |
208-
| label\_order | The naming order of the ID output and Name tag | `list(string)` | `[]` | no |
209+
| label\_order | The naming order of the id output and Name tag.<br>Defaults to ["namespace", "environment", "stage", "name", "attributes"].<br>You can omit any of the 5 elements, but at least one must be present. | `list(string)` | `null` | no |
209210
| map\_public\_ip\_on\_launch | Instances launched into a public subnet should be assigned a public IP address | `bool` | `true` | no |
210211
| max\_subnet\_count | Sets the maximum amount of subnets to deploy. 0 will deploy a subnet for every provided availablility zone (in `availability_zones` variable) within the region | `number` | `0` | no |
211-
| name | Solution name, e.g. 'app' or 'cluster' | `string` | `""` | no |
212-
| namespace | Namespace, which could be your organization name or abbreviation, e.g. 'eg' or 'cp' | `string` | `""` | no |
212+
| name | Solution name, e.g. 'app' or 'jenkins' | `string` | `null` | no |
213+
| namespace | Namespace, which could be your organization name or abbreviation, e.g. 'eg' or 'cp' | `string` | `null` | no |
213214
| nat\_gateway\_enabled | Flag to enable/disable NAT Gateways to allow servers in the private subnets to access the Internet | `bool` | `true` | no |
214215
| nat\_instance\_enabled | Flag to enable/disable NAT Instances to allow servers in the private subnets to access the Internet | `bool` | `false` | no |
215216
| nat\_instance\_type | NAT Instance type | `string` | `"t3.micro"` | no |
216217
| private\_network\_acl\_id | Network ACL ID that will be added to private subnets. If empty, a new ACL will be created | `string` | `""` | no |
217218
| private\_subnets\_additional\_tags | Additional tags to be added to private subnets | `map(string)` | `{}` | no |
218219
| public\_network\_acl\_id | Network ACL ID that will be added to public subnets. If empty, a new ACL will be created | `string` | `""` | no |
219220
| public\_subnets\_additional\_tags | Additional tags to be added to public subnets | `map(string)` | `{}` | no |
220-
| regex\_replace\_chars | Regex to replace chars with empty string in `namespace`, `environment`, `stage` and `name`. By default only hyphens, letters and digits are allowed, all other chars are removed | `string` | `"/[^a-zA-Z0-9-]/"` | no |
221-
| stage | Stage, e.g. 'prod', 'staging', 'dev', or 'test' | `string` | `""` | no |
221+
| regex\_replace\_chars | Regex to replace chars with empty string in `namespace`, `environment`, `stage` and `name`.<br>If not set, `"/[^a-zA-Z0-9-]/"` is used to remove all characters other than hyphens, letters and digits. | `string` | `null` | no |
222+
| stage | Stage, e.g. 'prod', 'staging', 'dev', OR 'source', 'build', 'test', 'deploy', 'release' | `string` | `null` | no |
222223
| subnet\_type\_tag\_key | Key for subnet type tag to provide information about the type of subnets, e.g. `cpco.io/subnet/type=private` or `cpco.io/subnet/type=public` | `string` | `"cpco.io/subnet/type"` | no |
223224
| subnet\_type\_tag\_value\_format | This is using the format interpolation symbols to allow the value of the subnet\_type\_tag\_key to be modified. | `string` | `"%s"` | no |
224-
| tags | Additional tags to apply to all resources that use this label module | `map(string)` | `{}` | no |
225+
| tags | Additional tags (e.g. `map('BusinessUnit','XYZ')` | `map(string)` | `{}` | no |
225226
| vpc\_default\_route\_table\_id | Default route table for public subnets. If not set, will be created. (e.g. `rtb-f4f0ce12`) | `string` | `""` | no |
226227
| vpc\_id | VPC ID where subnets will be created (e.g. `vpc-aceb2723`) | `string` | n/a | yes |
227228

context.tf

Lines changed: 172 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,172 @@
1+
#
2+
# Copy this file from https://github.com/cloudposse/terraform-null-label/blob/master/exports/context.tf
3+
# and then place it in your Terraform module to automatically get
4+
# Cloud Posse's standard configuration inputs suitable for passing
5+
# to Cloud Posse modules.
6+
#
7+
# Modules should access the whole context as `module.this.context`
8+
# to get the input variables with nulls for defaults,
9+
# for example `context = module.this.context`,
10+
# and access individual variables as `module.this.<var>`,
11+
# with final values filled in.
12+
#
13+
# For example, when using defaults, `module.this.context.delimiter`
14+
# will be null, and `module.this.delimiter` will be `-` (hyphen).
15+
#
16+
# ONLY EDIT THIS FILE IN github.com/cloudposse/terraform-null-label
17+
# All other instances of this file should be a copy of that one
18+
#
19+
20+
# Copy contents of cloudposse/terraform-null-label/variables.tf here
21+
variable "context" {
22+
type = object({
23+
enabled = bool
24+
namespace = string
25+
environment = string
26+
stage = string
27+
name = string
28+
delimiter = string
29+
attributes = list(string)
30+
tags = map(string)
31+
additional_tag_map = map(string)
32+
regex_replace_chars = string
33+
label_order = list(string)
34+
id_length_limit = number
35+
})
36+
default = {
37+
enabled = true
38+
namespace = null
39+
environment = null
40+
stage = null
41+
name = null
42+
delimiter = null
43+
attributes = []
44+
tags = {}
45+
additional_tag_map = {}
46+
regex_replace_chars = null
47+
label_order = []
48+
id_length_limit = null
49+
}
50+
description = <<-EOT
51+
Single object for setting entire context at once.
52+
See description of individual variables for details.
53+
Leave string and numeric variables as `null` to use default value.
54+
Individual variable settings (non-null) override settings in context object,
55+
except for attributes, tags, and additional_tag_map, which are merged.
56+
EOT
57+
}
58+
59+
variable "enabled" {
60+
type = bool
61+
default = null
62+
description = "Set to false to prevent the module from creating any resources"
63+
}
64+
65+
variable "namespace" {
66+
type = string
67+
default = null
68+
description = "Namespace, which could be your organization name or abbreviation, e.g. 'eg' or 'cp'"
69+
}
70+
71+
variable "environment" {
72+
type = string
73+
default = null
74+
description = "Environment, e.g. 'uw2', 'us-west-2', OR 'prod', 'staging', 'dev', 'UAT'"
75+
}
76+
77+
variable "stage" {
78+
type = string
79+
default = null
80+
description = "Stage, e.g. 'prod', 'staging', 'dev', OR 'source', 'build', 'test', 'deploy', 'release'"
81+
}
82+
83+
variable "name" {
84+
type = string
85+
default = null
86+
description = "Solution name, e.g. 'app' or 'jenkins'"
87+
}
88+
89+
variable "delimiter" {
90+
type = string
91+
default = null
92+
description = <<-EOT
93+
Delimiter to be used between `namespace`, `environment`, `stage`, `name` and `attributes`.
94+
Defaults to `-` (hyphen). Set to `""` to use no delimiter at all.
95+
EOT
96+
}
97+
98+
variable "attributes" {
99+
type = list(string)
100+
default = []
101+
description = "Additional attributes (e.g. `1`)"
102+
}
103+
104+
variable "tags" {
105+
type = map(string)
106+
default = {}
107+
description = "Additional tags (e.g. `map('BusinessUnit','XYZ')`"
108+
}
109+
110+
variable "additional_tag_map" {
111+
type = map(string)
112+
default = {}
113+
description = "Additional tags for appending to tags_as_list_of_maps. Not added to `tags`."
114+
}
115+
116+
variable "label_order" {
117+
type = list(string)
118+
default = null
119+
description = <<-EOT
120+
The naming order of the id output and Name tag.
121+
Defaults to ["namespace", "environment", "stage", "name", "attributes"].
122+
You can omit any of the 5 elements, but at least one must be present.
123+
EOT
124+
}
125+
126+
variable "regex_replace_chars" {
127+
type = string
128+
default = null
129+
description = <<-EOT
130+
Regex to replace chars with empty string in `namespace`, `environment`, `stage` and `name`.
131+
If not set, `"/[^a-zA-Z0-9-]/"` is used to remove all characters other than hyphens, letters and digits.
132+
EOT
133+
}
134+
135+
variable "id_length_limit" {
136+
type = number
137+
default = null
138+
description = <<-EOT
139+
Limit `id` to this many characters.
140+
Set to `0` for unlimited length.
141+
Set to `null` for default, which is `0`.
142+
Does not affect `id_full`.
143+
EOT
144+
}
145+
146+
#### End of copy of cloudposse/terraform-null-label/variables.tf
147+
148+
#
149+
# Ensure all variables above are includes in input to module "this" below
150+
#
151+
# Modules should access the whole context as `module.this.context`
152+
# and access individual variables as `module.this.context.<var>`,
153+
# for example, `module.this.context.enabled`
154+
#
155+
module "this" {
156+
source = "git::https://github.com/cloudposse/terraform-null-label.git?ref=tags/0.19.1"
157+
158+
enabled = var.enabled
159+
namespace = var.namespace
160+
environment = var.environment
161+
stage = var.stage
162+
name = var.name
163+
delimiter = var.delimiter
164+
attributes = var.attributes
165+
tags = var.tags
166+
additional_tag_map = var.additional_tag_map
167+
label_order = var.label_order
168+
regex_replace_chars = var.regex_replace_chars
169+
id_length_limit = var.id_length_limit
170+
171+
context = var.context
172+
}

0 commit comments

Comments
 (0)