Skip to content

Commit 05b3362

Browse files
authored
Update to context.tf. Update provider pinning. Update Terratest. Update GitHub Actions. Add UDP ingress rule (#69)
* Update to `context.tf`. Update provider pinning. Update Terratest. Update GitHub Actions. Add UDP ingress rule * Update to `context.tf`. Update provider pinning. Update Terratest. Update GitHub Actions. Add UDP ingress rule
1 parent e9ce452 commit 05b3362

27 files changed

+1083
-280
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

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@
186186
same "printed page" as the copyright notice for easier
187187
identification within third-party archives.
188188

189-
Copyright 2017-2019 Cloud Posse, LLC
189+
Copyright 2017-2020 Cloud Posse, LLC
190190

191191
Licensed under the Apache License, Version 2.0 (the "License");
192192
you may not use this file except in compliance with the License.

README.md

Lines changed: 22 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -128,27 +128,30 @@ Available targets:
128128
129129
```
130130
<!-- markdownlint-restore -->
131+
<!-- markdownlint-disable -->
131132
## Requirements
132133

133134
| Name | Version |
134135
|------|---------|
135-
| terraform | >= 0.12.0, < 0.14.0 |
136-
| aws | ~> 2.0 |
137-
| null | ~> 2.0 |
136+
| terraform | >= 0.12.0 |
137+
| aws | >= 2.0 |
138+
| null | >= 2.0 |
138139

139140
## Providers
140141

141142
| Name | Version |
142143
|------|---------|
143-
| aws | ~> 2.0 |
144-
| null | ~> 2.0 |
144+
| aws | >= 2.0 |
145+
| null | >= 2.0 |
145146

146147
## Inputs
147148

148149
| Name | Description | Type | Default | Required |
149150
|------|-------------|------|---------|:--------:|
150151
| additional\_ips\_count | Count of additional EIPs | `number` | `0` | no |
151-
| allowed\_ports | List of allowed ingress ports | `list(number)` | `[]` | no |
152+
| additional\_tag\_map | Additional tags for appending to tags\_as\_list\_of\_maps. Not added to `tags`. | `map(string)` | `{}` | no |
153+
| allowed\_ports | List of allowed ingress TCP ports | `list(number)` | `[]` | no |
154+
| allowed\_ports\_udp | List of allowed ingress UDP ports | `list(number)` | `[]` | no |
152155
| ami | The AMI to use for the instance. By default it is the AMI provided by Amazon with Ubuntu 16.04 | `string` | `""` | no |
153156
| ami\_owner | Owner of the given AMI (ignored if `ami` unset) | `string` | `""` | no |
154157
| applying\_period | The period in seconds over which the specified statistic is applied | `number` | `60` | no |
@@ -157,43 +160,47 @@ Available targets:
157160
| attributes | Additional attributes (e.g. `1`) | `list(string)` | `[]` | no |
158161
| availability\_zone | Availability Zone the instance is launched in. If not set, will be launched in the first AZ of the region | `string` | `""` | no |
159162
| comparison\_operator | The arithmetic operation to use when comparing the specified Statistic and Threshold. Possible values are: GreaterThanOrEqualToThreshold, GreaterThanThreshold, LessThanThreshold, LessThanOrEqualToThreshold. | `string` | `"GreaterThanOrEqualToThreshold"` | no |
163+
| 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 |
160164
| create\_default\_security\_group | Create default Security Group with only Egress traffic allowed | `bool` | `true` | no |
161-
| default\_alarm\_action | Default alerm action | `string` | `"action/actions/AWS_EC2.InstanceId.Reboot/1.0"` | no |
165+
| default\_alarm\_action | Default alarm action | `string` | `"action/actions/AWS_EC2.InstanceId.Reboot/1.0"` | no |
162166
| delete\_on\_termination | Whether the volume should be destroyed on instance termination | `bool` | `true` | no |
163-
| delimiter | Delimiter to be used between `name`, `namespace`, `stage`, etc. | `string` | `"-"` | no |
167+
| 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 |
164168
| disable\_api\_termination | Enable EC2 Instance Termination Protection | `bool` | `false` | no |
165169
| ebs\_device\_name | Name of the EBS device to mount | `list(string)` | <pre>[<br> "/dev/xvdb",<br> "/dev/xvdc",<br> "/dev/xvdd",<br> "/dev/xvde",<br> "/dev/xvdf",<br> "/dev/xvdg",<br> "/dev/xvdh",<br> "/dev/xvdi",<br> "/dev/xvdj",<br> "/dev/xvdk",<br> "/dev/xvdl",<br> "/dev/xvdm",<br> "/dev/xvdn",<br> "/dev/xvdo",<br> "/dev/xvdp",<br> "/dev/xvdq",<br> "/dev/xvdr",<br> "/dev/xvds",<br> "/dev/xvdt",<br> "/dev/xvdu",<br> "/dev/xvdv",<br> "/dev/xvdw",<br> "/dev/xvdx",<br> "/dev/xvdy",<br> "/dev/xvdz"<br>]</pre> | no |
166170
| ebs\_iops | Amount of provisioned IOPS. This must be set with a volume\_type of io1 | `number` | `0` | no |
167171
| ebs\_optimized | Launched EC2 instance will be EBS-optimized | `bool` | `false` | no |
168172
| ebs\_volume\_count | Count of EBS volumes that will be attached to the instance | `number` | `0` | no |
169173
| ebs\_volume\_size | Size of the EBS volume in gigabytes | `number` | `10` | no |
170174
| ebs\_volume\_type | The type of EBS volume. Can be standard, gp2 or io1 | `string` | `"gp2"` | no |
171-
| environment | Environment, e.g. 'prod', 'staging', 'dev', 'pre-prod', 'UAT' | `string` | `""` | no |
175+
| enabled | Set to false to prevent the module from creating any resources | `bool` | `null` | no |
176+
| environment | Environment, e.g. 'uw2', 'us-west-2', OR 'prod', 'staging', 'dev', 'UAT' | `string` | `null` | no |
172177
| evaluation\_periods | The number of periods over which data is compared to the specified threshold. | `number` | `5` | no |
173-
| instance\_enabled | Flag to control the instance creation. Set to false if it is necessary to skip instance creation | `bool` | `true` | no |
178+
| 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 |
174179
| instance\_profile | A pre-defined profile to attach to the instance (default is to build our own) | `string` | `""` | no |
175180
| instance\_type | The type of the instance | `string` | `"t2.micro"` | no |
176181
| ipv6\_address\_count | Number of IPv6 addresses to associate with the primary network interface. Amazon EC2 chooses the IPv6 addresses from the range of your subnet (-1 to use subnet default) | `number` | `0` | no |
177182
| ipv6\_addresses | List of IPv6 addresses from the range of the subnet to associate with the primary network interface | `list(string)` | `[]` | no |
183+
| 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 |
178184
| metric\_name | The name for the alarm's associated metric. Allowed values can be found in https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/ec2-metricscollected.html | `string` | `"StatusCheckFailed_Instance"` | no |
179185
| metric\_namespace | The namespace for the alarm's associated metric. Allowed values can be found in https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/aws-namespaces.html | `string` | `"AWS/EC2"` | no |
180186
| metric\_threshold | The value against which the specified statistic is compared | `number` | `1` | no |
181187
| monitoring | Launched EC2 instance will have detailed monitoring enabled | `bool` | `true` | no |
182-
| name | Name (e.g. `bastion` or `db`) | `string` | n/a | yes |
183-
| namespace | Namespace (e.g. `cp` or `cloudposse`) | `string` | `""` | no |
188+
| name | Solution name, e.g. 'app' or 'jenkins' | `string` | `null` | no |
189+
| namespace | Namespace, which could be your organization name or abbreviation, e.g. 'eg' or 'cp' | `string` | `null` | no |
184190
| permissions\_boundary\_arn | Policy ARN to attach to instance role as a permissions boundary | `string` | `""` | no |
185191
| private\_ip | Private IP address to associate with the instance in the VPC | `string` | `""` | no |
192+
| 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 |
186193
| region | AWS Region the instance is launched in | `string` | `""` | no |
187194
| root\_iops | Amount of provisioned IOPS. This must be set if root\_volume\_type is set to `io1` | `number` | `0` | no |
188195
| root\_volume\_size | Size of the root volume in gigabytes | `number` | `10` | no |
189196
| root\_volume\_type | Type of root volume. Can be standard, gp2 or io1 | `string` | `"gp2"` | no |
190197
| security\_groups | List of Security Group IDs allowed to connect to the instance | `list(string)` | `[]` | no |
191198
| source\_dest\_check | Controls if traffic is routed to the instance when the destination address does not match the instance. Used for NAT or VPNs | `bool` | `true` | no |
192199
| ssh\_key\_pair | SSH key pair to be provisioned on the instance | `string` | n/a | yes |
193-
| stage | Stage (e.g. `prod`, `dev`, `staging` | `string` | `""` | no |
200+
| stage | Stage, e.g. 'prod', 'staging', 'dev', OR 'source', 'build', 'test', 'deploy', 'release' | `string` | `null` | no |
194201
| statistic\_level | The statistic to apply to the alarm's associated metric. Allowed values are: SampleCount, Average, Sum, Minimum, Maximum | `string` | `"Maximum"` | no |
195202
| subnet | VPC Subnet ID the instance is launched in | `string` | n/a | yes |
196-
| tags | Additional tags | `map(string)` | `{}` | no |
203+
| tags | Additional tags (e.g. `map('BusinessUnit','XYZ')` | `map(string)` | `{}` | no |
197204
| user\_data | Instance user data. Do not pass gzip-compressed data via this argument | `string` | `""` | no |
198205
| vpc\_id | The ID of the VPC that the instance security group belongs to | `string` | n/a | yes |
199206
| welcome\_message | Welcome message | `string` | `""` | no |
@@ -217,6 +224,7 @@ Available targets:
217224
| security\_group\_ids | IDs on the AWS Security Groups associated with the instance |
218225
| ssh\_key\_pair | Name of the SSH key pair provisioned on the instance |
219226

227+
<!-- markdownlint-restore -->
220228

221229

222230

cloud_watch_alarm.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ resource "null_resource" "check_alarm_action" {
1010

1111
resource "aws_cloudwatch_metric_alarm" "default" {
1212
count = local.instance_count
13-
alarm_name = module.label.id
13+
alarm_name = module.this.id
1414
comparison_operator = var.comparison_operator
1515
evaluation_periods = var.evaluation_periods
1616
metric_name = var.metric_name

context.tf

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

0 commit comments

Comments
 (0)