Skip to content

Commit 370bbb5

Browse files
authored
Bc compliance (#42)
* workflows updated * readme updated, code cleaned, BC compliance checks fixed
1 parent cb83481 commit 370bbb5

15 files changed

+222
-32
lines changed

.github/auto-release.yml

+8
Original file line numberDiff line numberDiff line change
@@ -43,3 +43,11 @@ change-template: |
4343
4444
template: |
4545
$CHANGES
46+
47+
replacers:
48+
# Remove irrelevant information from Renovate bot
49+
- search: '/---\s+^#.*Renovate configuration(?:.|\n)*?This PR has been generated .*/gm'
50+
replace: ''
51+
# Remove Renovate bot banner image
52+
- search: '/\[!\[[^\]]*Renovate\][^\]]*\](\([^)]*\))?\s*\n+/gm'
53+
replace: ''

.github/mergify.yml

+17-11
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,16 @@
1+
# https://docs.mergify.io/conditions.html
2+
# https://docs.mergify.io/actions.html
13
pull_request_rules:
24
- name: "approve automated PRs that have passed checks"
35
conditions:
4-
- "check-success~=test/bats"
5-
- "check-success~=test/readme"
6-
- "check-success~=test/terratest"
6+
- "author~=^(cloudpossebot|renovate\\[bot\\])$"
77
- "base=master"
8-
- "author=cloudpossebot"
9-
- "head~=auto-update/.*"
8+
- "-closed"
9+
- "head~=^(auto-update|renovate)/.*"
10+
- "check-success=test/bats"
11+
- "check-success=test/readme"
12+
- "check-success=test/terratest"
13+
- "check-success=validate-codeowners"
1014
actions:
1115
review:
1216
type: "APPROVE"
@@ -15,16 +19,17 @@ pull_request_rules:
1519

1620
- name: "merge automated PRs when approved and tests pass"
1721
conditions:
18-
- "check-success~=test/bats"
19-
- "check-success~=test/readme"
20-
- "check-success~=test/terratest"
22+
- "author~=^(cloudpossebot|renovate\\[bot\\])$"
2123
- "base=master"
22-
- "head~=auto-update/.*"
24+
- "-closed"
25+
- "head~=^(auto-update|renovate)/.*"
26+
- "check-success=test/bats"
27+
- "check-success=test/readme"
28+
- "check-success=test/terratest"
29+
- "check-success=validate-codeowners"
2330
- "#approved-reviews-by>=1"
2431
- "#changes-requested-reviews-by=0"
2532
- "#commented-reviews-by=0"
26-
- "base=master"
27-
- "author=cloudpossebot"
2833
actions:
2934
merge:
3035
method: "squash"
@@ -38,6 +43,7 @@ pull_request_rules:
3843
- name: "ask to resolve conflict"
3944
conditions:
4045
- "conflict"
46+
- "-closed"
4147
actions:
4248
comment:
4349
message: "This pull request is now in conflict. Could you fix it @{{author}}? 🙏"

.github/renovate.json

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"extends": [
3+
"config:base",
4+
":preserveSemverRanges"
5+
],
6+
"labels": ["auto-update"],
7+
"enabledManagers": ["terraform"],
8+
"terraform": {
9+
"ignorePaths": ["**/context.tf", "examples/**"]
10+
}
11+
}
12+

.github/workflows/auto-context.yml

+4-2
Original file line numberDiff line numberDiff line change
@@ -27,17 +27,19 @@ jobs:
2727
make init
2828
make github/init/context.tf
2929
make readme/build
30-
echo "::set-output name=create_pull_request=true"
30+
echo "::set-output name=create_pull_request::true"
3131
fi
3232
else
3333
echo "This module has not yet been updated to support the context.tf pattern! Please update in order to support automatic updates."
3434
fi
3535
3636
- name: Create Pull Request
37-
if: {{ steps.update.outputs.create_pull_request == 'true' }}
37+
if: steps.update.outputs.create_pull_request == 'true'
3838
uses: cloudposse/actions/github/[email protected]
3939
with:
4040
token: ${{ secrets.PUBLIC_REPO_ACCESS_TOKEN }}
41+
committer: 'cloudpossebot <[email protected]>'
42+
author: 'cloudpossebot <[email protected]>'
4143
commit-message: Update context.tf from origin source
4244
title: Update context.tf
4345
body: |-

.github/workflows/auto-format.yml

+86
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
name: Auto Format
2+
on:
3+
pull_request_target:
4+
types: [opened, synchronize]
5+
6+
jobs:
7+
auto-format:
8+
runs-on: ubuntu-latest
9+
container: cloudposse/build-harness:slim-latest
10+
steps:
11+
# Checkout the pull request branch
12+
# "An action in a workflow run can’t trigger a new workflow run. For example, if an action pushes code using
13+
# the repository’s GITHUB_TOKEN, a new workflow will not run even when the repository contains
14+
# a workflow configured to run when push events occur."
15+
# However, using a personal access token will cause events to be triggered.
16+
# We need that to ensure a status gets posted after the auto-format commit.
17+
# We also want to trigger tests if the auto-format made no changes.
18+
- uses: actions/checkout@v2
19+
if: github.event.pull_request.state == 'open'
20+
name: Privileged Checkout
21+
with:
22+
token: ${{ secrets.PUBLIC_REPO_ACCESS_TOKEN }}
23+
repository: ${{ github.event.pull_request.head.repo.full_name }}
24+
# Check out the PR commit, not the merge commit
25+
# Use `ref` instead of `sha` to enable pushing back to `ref`
26+
ref: ${{ github.event.pull_request.head.ref }}
27+
28+
# Do all the formatting stuff
29+
- name: Auto Format
30+
if: github.event.pull_request.state == 'open'
31+
shell: bash
32+
run: make BUILD_HARNESS_PATH=/build-harness PACKAGES_PREFER_HOST=true -f /build-harness/templates/Makefile.build-harness pr/auto-format/host
33+
34+
# Commit changes (if any) to the PR branch
35+
- name: Commit changes to the PR branch
36+
if: github.event.pull_request.state == 'open'
37+
shell: bash
38+
id: commit
39+
env:
40+
SENDER: ${{ github.event.sender.login }}
41+
run: |
42+
set -x
43+
output=$(git diff --name-only)
44+
45+
if [ -n "$output" ]; then
46+
echo "Changes detected. Pushing to the PR branch"
47+
git config --global user.name 'cloudpossebot'
48+
git config --global user.email '[email protected]'
49+
git add -A
50+
git commit -m "Auto Format"
51+
# Prevent looping by not pushing changes in response to changes from cloudpossebot
52+
[[ $SENDER == "cloudpossebot" ]] || git push
53+
# Set status to fail, because the push should trigger another status check,
54+
# and we use success to indicate the checks are finished.
55+
printf "::set-output name=%s::%s\n" "changed" "true"
56+
exit 1
57+
else
58+
printf "::set-output name=%s::%s\n" "changed" "false"
59+
echo "No changes detected"
60+
fi
61+
62+
- name: Auto Test
63+
uses: cloudposse/actions/github/[email protected]
64+
# match users by ID because logins (user names) are inconsistent,
65+
# for example in the REST API Renovate Bot is `renovate[bot]` but
66+
# in GraphQL it is just `renovate`, plus there is a non-bot
67+
# user `renovate` with ID 1832810.
68+
# Mergify bot: 37929162
69+
# Renovate bot: 29139614
70+
# Cloudpossebot: 11232728
71+
# Need to use space separators to prevent "21" from matching "112144"
72+
if: >
73+
contains(' 37929162 29139614 11232728 ', format(' {0} ', github.event.pull_request.user.id))
74+
&& steps.commit.outputs.changed == 'false' && github.event.pull_request.state == 'open'
75+
with:
76+
token: ${{ secrets.PUBLIC_REPO_ACCESS_TOKEN }}
77+
repository: cloudposse/actions
78+
event-type: test-command
79+
client-payload: |-
80+
{ "slash_command":{"args": {"unnamed": {"all": "all", "arg1": "all"}}},
81+
"pull_request": ${{ toJSON(github.event.pull_request) }},
82+
"github":{"payload":{"repository": ${{ toJSON(github.event.repository) }},
83+
"comment": {"id": ""}
84+
}
85+
}
86+
}

.github/workflows/auto-release.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ on:
66
- master
77

88
jobs:
9-
semver:
9+
publish:
1010
runs-on: ubuntu-latest
1111
steps:
1212
# Drafts your next Release notes as Pull Requests are merged into "master"

.github/workflows/validate-codeowners.yml

+7
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,17 @@ jobs:
99
- name: "Checkout source code at current commit"
1010
uses: actions/checkout@v2
1111
- uses: mszostok/[email protected]
12+
if: github.event.pull_request.head.repo.full_name == github.repository
13+
name: "Full check of CODEOWNERS"
1214
with:
1315
# For now, remove "files" check to allow CODEOWNERS to specify non-existent
1416
# files so we can use the same CODEOWNERS file for Terraform and non-Terraform repos
1517
# checks: "files,syntax,owners,duppatterns"
1618
checks: "syntax,owners,duppatterns"
1719
# GitHub access token is required only if the `owners` check is enabled
1820
github_access_token: "${{ secrets.PUBLIC_REPO_ACCESS_TOKEN }}"
21+
- uses: mszostok/[email protected]
22+
if: github.event.pull_request.head.repo.full_name != github.repository
23+
name: "Syntax check of CODEOWNERS"
24+
with:
25+
checks: "syntax,duppatterns"

.gitignore

+2-1
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,5 @@
77
.idea
88
terraform-aws-cloudtrail.iml
99
.build-harness
10-
build-harness
10+
build-harness
11+
**/.terraform.lock.hcl

README.md

+1-3
Original file line numberDiff line numberDiff line change
@@ -155,8 +155,6 @@ Available targets:
155155
|------|---------|
156156
| terraform | >= 0.12.26 |
157157
| aws | >= 2.0 |
158-
| local | >= 1.2 |
159-
| null | >= 2.0 |
160158

161159
## Providers
162160

@@ -181,7 +179,7 @@ Available targets:
181179
| event\_selector | Specifies an event selector for enabling data event logging. See: https://www.terraform.io/docs/providers/aws/r/cloudtrail.html for details on this variable | <pre>list(object({<br> include_management_events = bool<br> read_write_type = string<br><br> data_resource = list(object({<br> type = string<br> values = list(string)<br> }))<br> }))</pre> | `[]` | no |
182180
| 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 |
183181
| include\_global\_service\_events | Specifies whether the trail is publishing events from global services such as IAM to the log files | `bool` | `false` | no |
184-
| is\_multi\_region\_trail | Specifies whether the trail is created in the current region or in all regions | `bool` | `false` | no |
182+
| is\_multi\_region\_trail | Specifies whether the trail is created in the current region or in all regions | `bool` | `true` | no |
185183
| is\_organization\_trail | The trail is an AWS Organizations trail | `bool` | `false` | no |
186184
| kms\_key\_arn | Specifies the KMS key ARN to use to encrypt the logs delivered by CloudTrail | `string` | `""` | no |
187185
| 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 |

docs/terraform.md

+1-3
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@
55
|------|---------|
66
| terraform | >= 0.12.26 |
77
| aws | >= 2.0 |
8-
| local | >= 1.2 |
9-
| null | >= 2.0 |
108

119
## Providers
1210

@@ -31,7 +29,7 @@
3129
| event\_selector | Specifies an event selector for enabling data event logging. See: https://www.terraform.io/docs/providers/aws/r/cloudtrail.html for details on this variable | <pre>list(object({<br> include_management_events = bool<br> read_write_type = string<br><br> data_resource = list(object({<br> type = string<br> values = list(string)<br> }))<br> }))</pre> | `[]` | no |
3230
| 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 |
3331
| include\_global\_service\_events | Specifies whether the trail is publishing events from global services such as IAM to the log files | `bool` | `false` | no |
34-
| is\_multi\_region\_trail | Specifies whether the trail is created in the current region or in all regions | `bool` | `false` | no |
32+
| is\_multi\_region\_trail | Specifies whether the trail is created in the current region or in all regions | `bool` | `true` | no |
3533
| is\_organization\_trail | The trail is an AWS Organizations trail | `bool` | `false` | no |
3634
| kms\_key\_arn | Specifies the KMS key ARN to use to encrypt the logs delivered by CloudTrail | `string` | `""` | no |
3735
| 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 |

examples/complete/main.tf

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ module "cloudtrail" {
1717

1818
module "cloudtrail_s3_bucket" {
1919
source = "cloudposse/cloudtrail-s3-bucket/aws"
20-
version = "0.12.0"
20+
version = "0.14.0"
2121

2222
force_destroy = true
2323

test/src/go.mod

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@ module github.com/cloudposse/terraform-aws-cloudtrail
33
go 1.14
44

55
require (
6-
github.com/gruntwork-io/terratest v0.29.0
6+
github.com/gruntwork-io/terratest v0.31.4
77
github.com/stretchr/testify v1.6.1
88
)

0 commit comments

Comments
 (0)