Skip to content

Commit

Permalink
Feat: Context tags for subnets and routetables (#42)
Browse files Browse the repository at this point in the history
Co-authored-by: cloudpossebot <11232728+cloudpossebot@users.noreply.github.com>
  • Loading branch information
Brad Haynes and cloudpossebot authored Feb 25, 2022
1 parent f1b9570 commit cdf9ab5
Show file tree
Hide file tree
Showing 9 changed files with 79 additions and 30 deletions.
2 changes: 1 addition & 1 deletion .github/auto-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ template: |
replacers:
# Remove irrelevant information from Renovate bot
- search: '/(?<=---\s+)+^#.*(Renovate configuration|Configuration)(?:.|\n)*?This PR has been generated .*/gm'
- search: '/(?<=---\s)\s*^#.*(Renovate configuration|Configuration)(?:.|\n)*?This PR has been generated .*/gm'
replace: ''
# Remove Renovate bot banner image
- search: '/\[!\[[^\]]*Renovate\][^\]]*\](\([^)]*\))?\s*\n+/gm'
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/auto-context.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ jobs:
- name: Create Pull Request
if: steps.update.outputs.create_pull_request == 'true'
uses: cloudposse/actions/github/create-pull-request@0.22.0
uses: cloudposse/actions/github/create-pull-request@0.30.0
with:
token: ${{ secrets.PUBLIC_REPO_ACCESS_TOKEN }}
committer: 'cloudpossebot <11232728+cloudpossebot@users.noreply.github.com>'
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/auto-format.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ jobs:
fi
- name: Auto Test
uses: cloudposse/actions/github/repository-dispatch@0.22.0
uses: cloudposse/actions/github/repository-dispatch@0.30.0
# match users by ID because logins (user names) are inconsistent,
# for example in the REST API Renovate Bot is `renovate[bot]` but
# in GraphQL it is just `renovate`, plus there is a non-bot
Expand Down
55 changes: 55 additions & 0 deletions .github/workflows/auto-readme.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
name: "auto-readme"
on:
schedule:
# Example of job definition:
# .---------------- minute (0 - 59)
# | .------------- hour (0 - 23)
# | | .---------- day of month (1 - 31)
# | | | .------- month (1 - 12) OR jan,feb,mar,apr ...
# | | | | .---- day of week (0 - 6) (Sunday=0 or 7) OR sun,mon,tue,wed,thu,fri,sat
# | | | | |
# * * * * * user-name command to be executed

# Update README.md nightly at 4am UTC
- cron: '0 4 * * *'

jobs:
update:
if: github.event_name == 'schedule'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2

- name: Update readme
shell: bash
id: update
env:
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
run: |
make init
make readme/build
# Ignore changes if they are only whitespace
git diff --ignore-all-space --ignore-blank-lines --quiet README.md && { git restore README.md; echo Ignoring whitespace-only changes in README; }
- name: Create Pull Request
# This action will not create or change a pull request if there are no changes to make.
# If a PR of the auto-update/readme branch is open, this action will just update it, not create a new PR.
uses: cloudposse/actions/github/create-pull-request@0.30.0
with:
token: ${{ secrets.PUBLIC_REPO_ACCESS_TOKEN }}
commit-message: Update README.md and docs
title: Update README.md and docs
body: |-
## what
This is an auto-generated PR that updates the README.md and docs
## why
To have most recent changes of README.md and doc from origin templates
branch: auto-update/readme
base: main
delete-branch: true
labels: |
auto-update
no-release
readme
4 changes: 2 additions & 2 deletions .github/workflows/chatops.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:
steps:
- uses: actions/checkout@v2
- name: "Handle common commands"
uses: cloudposse/actions/github/slash-command-dispatch@0.22.0
uses: cloudposse/actions/github/slash-command-dispatch@0.30.0
with:
token: ${{ secrets.PUBLIC_REPO_ACCESS_TOKEN }}
reaction-token: ${{ secrets.GITHUB_TOKEN }}
Expand All @@ -24,7 +24,7 @@ jobs:
- name: "Checkout commit"
uses: actions/checkout@v2
- name: "Run tests"
uses: cloudposse/actions/github/slash-command-dispatch@0.22.0
uses: cloudposse/actions/github/slash-command-dispatch@0.30.0
with:
token: ${{ secrets.PUBLIC_REPO_ACCESS_TOKEN }}
reaction-token: ${{ secrets.GITHUB_TOKEN }}
Expand Down
6 changes: 4 additions & 2 deletions .github/workflows/validate-codeowners.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,20 @@ jobs:
steps:
- name: "Checkout source code at current commit"
uses: actions/checkout@v2
- uses: mszostok/codeowners-validator@v0.5.0
- uses: mszostok/codeowners-validator@v0.7.1
if: github.event.pull_request.head.repo.full_name == github.repository
name: "Full check of CODEOWNERS"
with:
# For now, remove "files" check to allow CODEOWNERS to specify non-existent
# files so we can use the same CODEOWNERS file for Terraform and non-Terraform repos
# checks: "files,syntax,owners,duppatterns"
checks: "syntax,owners,duppatterns"
owner_checker_allow_unowned_patterns: "false"
# GitHub access token is required only if the `owners` check is enabled
github_access_token: "${{ secrets.PUBLIC_REPO_ACCESS_TOKEN }}"
- uses: mszostok/codeowners-validator@v0.5.0
- uses: mszostok/codeowners-validator@v0.7.1
if: github.event.pull_request.head.repo.full_name != github.repository
name: "Syntax check of CODEOWNERS"
with:
checks: "syntax,duppatterns"
owner_checker_allow_unowned_patterns: "false"
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -549,7 +549,7 @@ In general, PRs are welcome. We follow the typical "fork-and-pull" Git workflow.

## Copyright

Copyright © 2017-2021 [Cloud Posse, LLC](https://cpco.io/copyright)
Copyright © 2017-2022 [Cloud Posse, LLC](https://cpco.io/copyright)



Expand Down
18 changes: 7 additions & 11 deletions private.tf
Original file line number Diff line number Diff line change
Expand Up @@ -18,24 +18,20 @@ resource "aws_subnet" "private" {
cidr_block = cidrsubnet(var.cidr_block, ceil(log(var.max_subnets, 2)), count.index)
map_public_ip_on_launch = var.map_public_ip_on_launch_enabled

tags = merge({
"Name" = "${module.private_label.id}${module.this.delimiter}${element(var.subnet_names, count.index)}"
"Stage" = module.private_label.stage
"Namespace" = module.private_label.namespace
"Named" = var.subnet_names[count.index]
"Type" = var.type
tags = merge(module.private_label.tags, {
"Name" = "${module.private_label.id}${module.this.delimiter}${element(var.subnet_names, count.index)}"
"Named" = var.subnet_names[count.index]
"Type" = var.type
}, var.tags)
}

resource "aws_route_table" "private" {
count = local.private_count
vpc_id = var.vpc_id

tags = {
"Name" = "${module.private_label.id}${module.this.delimiter}${element(var.subnet_names, count.index)}"
"Stage" = module.private_label.stage
"Namespace" = module.private_label.namespace
}
tags = merge(module.private_label.tags, {
"Name" = "${module.private_label.id}${module.this.delimiter}${element(var.subnet_names, count.index)}"
})
}

resource "aws_route" "private" {
Expand Down
18 changes: 7 additions & 11 deletions public.tf
Original file line number Diff line number Diff line change
Expand Up @@ -19,24 +19,20 @@ resource "aws_subnet" "public" {
cidr_block = cidrsubnet(var.cidr_block, ceil(log(var.max_subnets, 2)), count.index)
map_public_ip_on_launch = var.map_public_ip_on_launch_enabled

tags = merge({
"Name" = "${module.public_label.id}${module.this.delimiter}${element(var.subnet_names, count.index)}"
"Stage" = module.public_label.stage
"Namespace" = module.public_label.namespace
"Named" = var.subnet_names[count.index]
"Type" = var.type
tags = merge(module.public_label.tags, {
"Name" = "${module.public_label.id}${module.this.delimiter}${element(var.subnet_names, count.index)}"
"Named" = var.subnet_names[count.index]
"Type" = var.type
}, var.tags)
}

resource "aws_route_table" "public" {
count = local.public_count
vpc_id = var.vpc_id

tags = {
"Name" = "${module.public_label.id}${module.this.delimiter}${element(var.subnet_names, count.index)}"
"Stage" = module.public_label.stage
"Namespace" = module.public_label.namespace
}
tags = merge(module.public_label.tags, {
"Name" = "${module.public_label.id}${module.this.delimiter}${element(var.subnet_names, count.index)}"
})
}

resource "aws_route" "public" {
Expand Down

0 comments on commit cdf9ab5

Please sign in to comment.