Skip to content

Commit 7a796c6

Browse files
author
marcin
authored
Fix nat_gateway_id network_interface_id variable defaults conflict (#36)
1 parent 9e4585e commit 7a796c6

15 files changed

+205
-140
lines changed

.editorconfig

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# Unix-style newlines with a newline ending every file
2+
[*]
3+
charset = utf-8
4+
end_of_line = lf
5+
indent_size = 2
6+
indent_style = space
7+
insert_final_newline = true
8+
trim_trailing_whitespace = true
9+
10+
[*.{tf,tfvars}]
11+
indent_size = 2
12+
indent_style = space
13+
14+
[*.md]
15+
max_line_length = 0
16+
trim_trailing_whitespace = false
17+
18+
# Override for Makefile
19+
[{Makefile, makefile, GNUmakefile, Makefile.*}]
20+
tab_width = 2
21+
indent_style = tab
22+
indent_size = 4
23+
24+
[COMMIT_EDITMSG]
25+
max_line_length = 0

.github/CODEOWNERS

Lines changed: 2 additions & 2 deletions
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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ template: |
4646
4747
replacers:
4848
# Remove irrelevant information from Renovate bot
49-
- search: '/---\s+^#.*Renovate configuration(?:.|\n)*?This PR has been generated .*/gm'
49+
- search: '/---\s+^#.*(Renovate configuration|Configuration)(?:.|\n)*?This PR has been generated .*/gm'
5050
replace: ''
5151
# Remove Renovate bot banner image
5252
- search: '/\[!\[[^\]]*Renovate\][^\]]*\](\([^)]*\))?\s*\n+/gm'

.github/mergify.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,3 +56,10 @@ pull_request_rules:
5656
changes_requested: true
5757
approved: true
5858
message: "This Pull Request has been updated, so we're dismissing all reviews."
59+
60+
- name: "close Pull Requests without files changed"
61+
conditions:
62+
- "#files=0"
63+
actions:
64+
close:
65+
message: "This pull request has been automatically closed by Mergify because there are no longer any changes."

.github/workflows/auto-format.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ on:
66
jobs:
77
auto-format:
88
runs-on: ubuntu-latest
9-
container: cloudposse/build-harness:slim-latest
9+
container: cloudposse/build-harness:latest
1010
steps:
1111
# Checkout the pull request branch
1212
# "An action in a workflow run can’t trigger a new workflow run. For example, if an action pushes code using
@@ -29,6 +29,8 @@ jobs:
2929
- name: Auto Format
3030
if: github.event.pull_request.state == 'open'
3131
shell: bash
32+
env:
33+
GITHUB_TOKEN: "${{ secrets.PUBLIC_REPO_ACCESS_TOKEN }}"
3234
run: make BUILD_HARNESS_PATH=/build-harness PACKAGES_PREFER_HOST=true -f /build-harness/templates/Makefile.build-harness pr/auto-format/host
3335

3436
# Commit changes (if any) to the PR branch

.github/workflows/auto-release.yml

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,25 @@ name: auto-release
33
on:
44
push:
55
branches:
6-
- master
6+
- main
7+
- master
8+
- production
79

810
jobs:
911
publish:
1012
runs-on: ubuntu-latest
1113
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.PUBLIC_REPO_ACCESS_TOKEN }}
14+
# Get PR from merged commit to master
15+
- uses: actions-ecosystem/action-get-merged-pull-request@v1
16+
id: get-merged-pull-request
17+
with:
18+
github_token: ${{ secrets.PUBLIC_REPO_ACCESS_TOKEN }}
19+
# Drafts your next Release notes as Pull Requests are merged into "main"
20+
- uses: release-drafter/release-drafter@v5
21+
if: "!contains(steps.get-merged-pull-request.outputs.labels, 'no-release')"
22+
with:
23+
publish: true
24+
prerelease: false
25+
config-name: auto-release.yml
26+
env:
27+
GITHUB_TOKEN: ${{ secrets.PUBLIC_REPO_ACCESS_TOKEN }}

.github/workflows/validate-codeowners.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
name: Validate Codeowners
22
on:
3+
workflow_dispatch:
4+
35
pull_request:
46

57
jobs:

README.md

Lines changed: 61 additions & 57 deletions
Large diffs are not rendered by default.

docs/terraform.md

Lines changed: 60 additions & 55 deletions
Large diffs are not rendered by default.

examples/complete/fixtures.us-east-2.tfvars

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,3 @@ subnet_names = ["subnet1", "subnet2"]
1515
max_subnets = 2
1616

1717
type = "public"
18-
19-
nat_enabled = false

examples/complete/main.tf

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ module "vpc" {
1111
context = module.this.context
1212
}
1313

14+
# Verify we can make a public subnet with NAT for private subnet
1415
module "subnets" {
1516
source = "../../"
1617

@@ -19,9 +20,26 @@ module "subnets" {
1920
availability_zone = var.availability_zone
2021
vpc_id = module.vpc.vpc_id
2122
igw_id = module.vpc.igw_id
22-
cidr_block = module.vpc.vpc_cidr_block
23+
cidr_block = "172.16.128.0/17"
2324
subnet_names = var.subnet_names
2425
max_subnets = var.max_subnets
25-
nat_enabled = var.nat_enabled
26-
type = var.type
26+
nat_enabled = true
27+
type = "public"
28+
}
29+
30+
# Verify we can make private subnets connected to the public subnet
31+
module "subnets_private" {
32+
source = "../../"
33+
34+
context = module.this.context
35+
36+
availability_zone = var.availability_zone
37+
vpc_id = module.vpc.vpc_id
38+
igw_id = module.vpc.igw_id
39+
cidr_block = "172.16.0.0/17"
40+
subnet_names = ["private1"]
41+
max_subnets = var.max_subnets
42+
nat_enabled = false
43+
type = "private"
44+
ngw_id = module.subnets.ngw_id
2745
}

examples/complete/variables.tf

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,3 @@ variable "max_subnets" {
1717
variable "type" {
1818
type = string
1919
}
20-
21-
variable "nat_enabled" {
22-
type = bool
23-
}

private.tf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,8 @@ resource "aws_route_table" "private" {
4141
resource "aws_route" "private" {
4242
count = local.private_count
4343
route_table_id = aws_route_table.private.*.id[count.index]
44-
network_interface_id = var.eni_id
45-
nat_gateway_id = var.ngw_id
44+
network_interface_id = var.eni_id == "" ? null : var.eni_id
45+
nat_gateway_id = var.ngw_id == "" ? null : var.ngw_id
4646
destination_cidr_block = "0.0.0.0/0"
4747
}
4848

public.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ resource "aws_route_table" "public" {
4242
resource "aws_route" "public" {
4343
count = local.public_count
4444
route_table_id = aws_route_table.public.*.id[count.index]
45-
gateway_id = var.igw_id
45+
gateway_id = var.igw_id == "" ? null : var.igw_id
4646
destination_cidr_block = "0.0.0.0/0"
4747
}
4848

variables.tf

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,13 @@ variable "cidr_block" {
3232

3333
variable "igw_id" {
3434
type = string
35-
description = "Internet Gateway ID which will be used as a default route in public route tables (e.g. `igw-9c26a123`). Conflicts with `ngw_id`"
35+
description = "Internet Gateway ID which will be used as a default route in public route tables (e.g. `igw-9c26a123`)."
3636
default = ""
3737
}
3838

3939
variable "ngw_id" {
4040
type = string
41-
description = "NAT Gateway ID which will be used as a default route in private route tables (e.g. `igw-9c26a123`). Conflicts with `igw_id`"
41+
description = "NAT Gateway ID which will be used as a default route in private route tables (e.g. `igw-9c26a123`). Conflicts with `eni_id`."
4242
default = ""
4343
}
4444

@@ -159,7 +159,7 @@ variable "nat_enabled" {
159159
variable "eni_id" {
160160
type = string
161161
default = ""
162-
description = "An ID of a network interface which is used as a default route in private route tables (_e.g._ `eni-9c26a123`)"
162+
description = "An ID of a network interface which is used as a default route in private route tables (_e.g._ `eni-9c26a123`). Conflicts with `ngw_id`."
163163
}
164164

165165
variable "map_public_ip_on_launch_enabled" {

0 commit comments

Comments
 (0)