Skip to content

Commit 34b3b51

Browse files
committed
add option for cross-account write access to helm repo
1 parent 1319023 commit 34b3b51

File tree

14 files changed

+83
-50
lines changed

14 files changed

+83
-50
lines changed

.github/workflows/pre-commit.yaml

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ jobs:
1919
- name: initialize Terraform
2020
run: terraform init --backend=false
2121
- name: pre-commit
22-
uses: pre-commit/[email protected].0
22+
uses: pre-commit/[email protected].3
2323
env:
2424
AWS_DEFAULT_REGION: us-east-1
2525
# many of these are covered by better reviewdog linters below
@@ -28,12 +28,3 @@ jobs:
2828
no-commit-to-branch,
2929
terraform_tflint_nocreds,
3030
terraform_tfsec
31-
- uses: stefanzweifel/git-auto-commit-action@v4
32-
if: ${{ failure() }}
33-
with:
34-
commit_message: Apply automatic changes
35-
commit_options: "--no-verify"
36-
# Optional commit user and author settings
37-
commit_user_name: Linter Bot
38-
commit_user_email: [email protected]
39-
commit_author: Linter Bot <[email protected]>

.github/workflows/pullRequest.yaml

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,8 @@ jobs:
3737
runs-on: ubuntu-latest
3838
steps:
3939
- uses: actions/checkout@v2
40-
- name: setup Terraform
41-
uses: hashicorp/setup-terraform@v1
42-
with:
43-
terraform_version: 0.12.26
40+
- name: Install prerequisites
41+
run: ./bin/install-ubuntu.sh
4442
- name: Terraform init
4543
run: terraform init --backend=false
4644
- name: tflint
@@ -55,10 +53,8 @@ jobs:
5553
runs-on: ubuntu-latest
5654
steps:
5755
- uses: actions/checkout@v2
58-
- name: setup Terraform
59-
uses: hashicorp/setup-terraform@v1
60-
with:
61-
terraform_version: 0.12.26
56+
- name: Install prerequisites
57+
run: ./bin/install-ubuntu.sh
6258
- name: Terraform init
6359
run: terraform init --backend=false
6460
- name: tfsec

.github/workflows/tflint.yaml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,8 @@ jobs:
1313
runs-on: ubuntu-latest
1414
steps:
1515
- uses: actions/checkout@v2
16-
- name: setup Terraform
17-
uses: hashicorp/setup-terraform@v1
18-
with:
19-
terraform_version: 0.12.26
16+
- name: Install prerequisites
17+
run: ./bin/install-ubuntu.sh
2018
- name: Terraform init
2119
run: terraform init --backend=false
2220
- name: tflint

.github/workflows/tfsec.yaml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,8 @@ jobs:
1313
runs-on: ubuntu-latest
1414
steps:
1515
- uses: actions/checkout@v2
16-
- name: setup Terraform
17-
uses: hashicorp/setup-terraform@v1
18-
with:
19-
terraform_version: 0.12.26
16+
- name: Install prerequisites
17+
run: ./bin/install-ubuntu.sh
2018
- name: Terraform init
2119
run: terraform init --backend=false
2220
- name: tfsec

.pre-commit-config.yaml

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,13 @@
1+
exclude: ".terraform"
12
repos:
23
- repo: https://github.com/antonbabenko/pre-commit-terraform
3-
rev: v1.31.0
4+
rev: v1.50.0
45
hooks:
56
- id: terraform_docs
67
always_run: true
78
args:
89
- --args=--sort-by-required
910
- id: terraform_fmt
10-
- id: terraform_tflint
11-
alias: terraform_tflint_deep
12-
name: terraform_tflint_deep
13-
args:
14-
- --args=--deep
1511
- id: terraform_tflint
1612
alias: terraform_tflint_nocreds
1713
name: terraform_tflint_nocreds
@@ -33,14 +29,15 @@ repos:
3329
cd $(dirname "$FILE")
3430
terraform init --backend=false
3531
terraform validate .
32+
cd ..
3633
done
3734
'
3835
language: system
3936
verbose: true
4037
files: \.tf(vars)?$
4138
exclude: examples
4239
- repo: https://github.com/pre-commit/pre-commit-hooks
43-
rev: v3.0.0
40+
rev: v3.4.0
4441
hooks:
4542
- id: check-case-conflict
4643
- id: check-json

.terraform-version

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
latest:^0.13

.tflint.hcl

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
config {
22
module = true
3-
deep_check = false
43
}
54

65
rule "terraform_deprecated_interpolation" {

README.md

Lines changed: 26 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,29 +20,45 @@ module {
2020

2121
| Name | Version |
2222
|------|---------|
23-
| terraform | >= 0.12.19 |
23+
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 0.12.19 |
24+
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 3.0.0 |
2425

2526
## Providers
2627

2728
| Name | Version |
2829
|------|---------|
29-
| aws | n/a |
30+
| <a name="provider_aws"></a> [aws](#provider\_aws) | >= 3.0.0 |
31+
32+
## Modules
33+
34+
No modules.
35+
36+
## Resources
37+
38+
| Name | Type |
39+
|------|------|
40+
| [aws_s3_bucket.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/s3_bucket) | resource |
41+
| [aws_s3_bucket_policy.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/s3_bucket_policy) | resource |
42+
| [aws_s3_bucket_public_access_block.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/s3_bucket_public_access_block) | resource |
43+
| [aws_caller_identity.current](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/caller_identity) | data source |
44+
| [aws_iam_policy_document.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document) | data source |
45+
| [aws_region.region](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/region) | data source |
3046

3147
## Inputs
3248

3349
| Name | Description | Type | Default | Required |
3450
|------|-------------|------|---------|:--------:|
35-
| allowed\_account\_ids | List of AWS account IDs to grant read-only access to the repo. Due to how policies are constructed, there's effectively a limit of about 9 accounts. | `list(string)` | `[]` | no |
36-
| logging\_bucket | S3 bucket name to log bucket access requests to (optional) | `string` | `null` | no |
37-
| logging\_bucket\_prefix | S3 bucket prefix to log bucket access requests to (optional). If blank but a `logging_bucket` is specified, this will be set to the name of the bucket | `string` | `null` | no |
38-
| name | Bucket name for the helm repo. Specify to control the exact name of the bucket, otherwise use `name_suffix` | `string` | `null` | no |
39-
| name\_suffix | Bucket suffix for the repo (bucket will be named `[ACCOUNT_ID]-[REGION]-[name_suffix]`, not used if `name` is specified) | `string` | `"helmrepo"` | no |
40-
| tags | Tags to add to supported resources | `map(string)` | `{}` | no |
51+
| <a name="input_allow_cross_account_write"></a> [allow\_cross\_account\_write](#input\_allow\_cross\_account\_write) | Allow write access to helm repo from `allowed_account_ids` | `bool` | `false` | no |
52+
| <a name="input_allowed_account_ids"></a> [allowed\_account\_ids](#input\_allowed\_account\_ids) | List of AWS account IDs to grant read-only access to the repo. Due to how policies are constructed, there's effectively a limit of about 9 accounts. | `list(string)` | `[]` | no |
53+
| <a name="input_logging_bucket"></a> [logging\_bucket](#input\_logging\_bucket) | S3 bucket name to log bucket access requests to (optional) | `string` | `null` | no |
54+
| <a name="input_logging_bucket_prefix"></a> [logging\_bucket\_prefix](#input\_logging\_bucket\_prefix) | S3 bucket prefix to log bucket access requests to (optional). If blank but a `logging_bucket` is specified, this will be set to the name of the bucket | `string` | `null` | no |
55+
| <a name="input_name"></a> [name](#input\_name) | Bucket name for the helm repo. Specify to control the exact name of the bucket, otherwise use `name_suffix` | `string` | `null` | no |
56+
| <a name="input_name_suffix"></a> [name\_suffix](#input\_name\_suffix) | Bucket suffix for the repo (bucket will be named `[ACCOUNT_ID]-[REGION]-[name_suffix]`, not used if `name` is specified) | `string` | `"helmrepo"` | no |
57+
| <a name="input_tags"></a> [tags](#input\_tags) | Tags to add to supported resources | `map(string)` | `{}` | no |
4158

4259
## Outputs
4360

4461
| Name | Description |
4562
|------|-------------|
46-
| s3\_bucket | Bucket name of the repo |
47-
63+
| <a name="output_s3_bucket"></a> [s3\_bucket](#output\_s3\_bucket) | Bucket name of the repo |
4864
<!-- END OF PRE-COMMIT-TERRAFORM DOCS HOOK -->

bin/install-macos.sh

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,4 @@ git config --global init.templateDir ~/.git-template
1414
pre-commit init-templatedir ~/.git-template
1515

1616
echo 'installing terraform with tfenv'
17-
tfenv install min-required
18-
tfenv use min-required
17+
tfenv install

bin/install-ubuntu.sh

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,9 @@
33
echo 'installing dependencies'
44
sudo apt install python3-pip gawk &&\
55
pip3 install pre-commit
6-
curl -L "$(curl -s https://api.github.com/repos/segmentio/terraform-docs/releases/latest | grep -o -E "https://.+?-linux-amd64")" > terraform-docs && chmod +x terraform-docs && sudo mv terraform-docs /usr/bin/
7-
curl -L "$(curl -s https://api.github.com/repos/terraform-linters/tflint/releases/latest | grep -o -E "https://.+?_linux_amd64.zip")" > tflint.zip && unzip tflint.zip && rm tflint.zip && sudo mv tflint /usr/bin/
6+
tfdocs_latest_dl_url=$(curl -sL https://api.github.com/repos/terraform-docs/terraform-docs/releases/latest | grep -o -E "https://.+?-linux-amd64" | tail -n1)
7+
curl -L "$tfdocs_latest_dl_url" > terraform-docs && chmod +x terraform-docs && sudo mv terraform-docs /usr/bin/
8+
curl -L "$(curl -sL https://api.github.com/repos/terraform-linters/tflint/releases/latest | grep -o -E "https://.+?_linux_amd64.zip")" > tflint.zip && unzip tflint.zip && rm tflint.zip && sudo mv tflint /usr/bin/
89
env GO111MODULE=on go get -u github.com/liamg/tfsec/cmd/tfsec
910
git clone https://github.com/tfutils/tfenv.git ~/.tfenv || true
1011
mkdir -p ~/.local/bin/
@@ -19,5 +20,4 @@ git config --global init.templateDir ~/.git-template
1920
pre-commit init-templatedir ~/.git-template
2021

2122
echo 'installing terraform with tfenv'
22-
tfenv install min-required
23-
tfenv use min-required
23+
tfenv install

0 commit comments

Comments
 (0)