Skip to content

Commit 6d8b558

Browse files
Update module to support conditions and modernize frameworks
- update policy object to support condition statements - update tests to validate condition application - update github workflows to latest versions - update go modules - update pre-commit configuration
1 parent 699de7d commit 6d8b558

23 files changed

+738
-1173
lines changed

.github/workflows/pull-request-label.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,5 @@ jobs:
1111
contents: read
1212
issues: write
1313
pull-requests: write
14-
uses: launchbynttdata/launch-workflows/.github/workflows/reusable-pr-label-by-branch.yml@0.8.0
14+
uses: launchbynttdata/launch-workflows/.github/workflows/reusable-pr-label-by-branch.yml@0.11.0
1515
secrets: inherit # pragma: allowlist secret

.github/workflows/pull-request-terraform-check.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ jobs:
1515
permissions:
1616
contents: read
1717
id-token: write
18-
uses: launchbynttdata/launch-workflows/.github/workflows/reusable-terraform-check-aws.yml@0.8.0
18+
uses: launchbynttdata/launch-workflows/.github/workflows/reusable-terraform-check-aws.yml@0.11.0
1919
with:
2020
assume_role_arn: ${{ vars.TERRAFORM_CHECK_AWS_ASSUME_ROLE_ARN }}
2121
region: ${{ vars.TERRAFORM_CHECK_AWS_REGION }}

.github/workflows/release-publish.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,5 @@ jobs:
1414
permissions:
1515
contents: write
1616
pull-requests: write
17-
uses: launchbynttdata/launch-workflows/.github/workflows/reusable-release-on-merge.yml@0.8.0
17+
uses: launchbynttdata/launch-workflows/.github/workflows/reusable-release-on-merge.yml@0.11.0
1818
secrets: inherit # pragma: allowlist secret

.gitignore

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@ terraform.*
22
.repo/
33
components/
44
.semverbot.toml
5-
.tflint.hcl
6-
.golangci.yaml
75

86
.idea
97
!examples/*.tfvars
@@ -59,10 +57,7 @@ terraform.rc
5957
# Files from common modules
6058
azure_env.sh
6159
.releaserc.json
62-
.tflint.hcl
6360

64-
# Pre-commit hook
65-
.pre-commit-config.yaml
6661

6762
# VS Code
6863
.vscode/
@@ -75,3 +70,7 @@ azure_env.sh
7570
**/*.egg-info
7671

7772
vendor/
73+
74+
.envrc
75+
.env.local
76+
.env

.golangci.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
version: "2"
2+
run:
3+
# Timeout for analysis, e.g. 30s, 5m.
4+
timeout: 5m
5+
allow-parallel-runners: true

.pre-commit-config.yaml

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
# .pre-commit-config.yaml
2+
repos:
3+
- repo: local
4+
hooks:
5+
- id: forbidden-files
6+
name: forbidden files
7+
entry:
8+
found Copier update rejection files; review and remove them before
9+
merging.
10+
language: fail
11+
files: "\\.rej$"
12+
- repo: https://github.com/pre-commit/pre-commit-hooks
13+
rev: v4.5.0
14+
hooks:
15+
- id: trailing-whitespace
16+
- id: check-case-conflict
17+
- id: check-executables-have-shebangs
18+
- id: check-json
19+
- id: check-merge-conflict
20+
args: [--assume-in-merge]
21+
- id: check-shebang-scripts-are-executable
22+
- id: check-yaml
23+
args:
24+
- --allow-multiple-documents
25+
- id: end-of-file-fixer
26+
- id: mixed-line-ending
27+
args:
28+
- --fix=auto
29+
- repo: https://github.com/antonbabenko/pre-commit-terraform
30+
rev: v1.99.0
31+
hooks:
32+
- id: terraform_fmt
33+
- id: terraform_validate
34+
- id: terraform_docs
35+
args:
36+
- --hook-config=--path-to-file=README.md
37+
- --hook-config=--add-to-existing-file=true
38+
- --hook-config=--create-file-if-not-exist=true
39+
- --args=--sort=false
40+
- repo: https://github.com/golangci/golangci-lint
41+
rev: v2.6.2
42+
hooks:
43+
- id: golangci-lint
44+
name: golangci-lint
45+
description: Fast linters runner for Go.
46+
entry: golangci-lint run --fix
47+
types: [go]
48+
language: golang
49+
pass_filenames: false
50+
- repo: https://github.com/alessandrojcm/commitlint-pre-commit-hook
51+
rev: v9.22.0
52+
hooks:
53+
- id: commitlint
54+
stages: [commit-msg]
55+
additional_dependencies: ["@commitlint/config-conventional"]
56+
- repo: https://github.com/Yelp/detect-secrets
57+
rev: v1.5.0
58+
hooks:
59+
- id: detect-secrets
60+
args: ["--baseline", ".secrets.baseline"]
61+
exclude: package.lock.json

.tflint.hcl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
plugin "terraform" {
2+
enabled = true
3+
preset = "recommended"
4+
}

.tool-versions

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
conftest 0.56.0
2-
golang 1.24.2
2+
golang 1.24.10
33
golangci-lint 2.2.1
44
pre-commit 4.2.0
55
regula 3.2.1 # https://github.com/launchbynttdata/asdf-regula

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ No modules.
3030
| Name | Description | Type | Default | Required |
3131
|------|-------------|------|---------|:--------:|
3232
| <a name="input_key_id"></a> [key\_id](#input\_key\_id) | (Required) The ID of the KMS Key to attach the policy. | `string` | n/a | yes |
33-
| <a name="input_policy"></a> [policy](#input\_policy) | A JSON-formatted string that represents the key policy to attach to the KMS key. | <pre>map(object({<br/> sid = string<br/> effect = string<br/> principals = map(list(string))<br/> actions = list(string)<br/> resources = list(string)<br/> }))</pre> | `null` | no |
33+
| <a name="input_policy"></a> [policy](#input\_policy) | A JSON-formatted string that represents the key policy to attach to the KMS key. | <pre>map(object({<br/> sid = string<br/> effect = string<br/> principals = map(list(string))<br/> actions = list(string)<br/> resources = list(string)<br/> condition = optional(list(object({<br/> test = string<br/> variable = string<br/> values = list(string)<br/> })))<br/> }))</pre> | n/a | yes |
3434
| <a name="input_bypass_policy_lockout_safety_check"></a> [bypass\_policy\_lockout\_safety\_check](#input\_bypass\_policy\_lockout\_safety\_check) | (Optional) A boolean flag to indicate whether to bypass the KMS key policy lockout safety check. Defaults to false. | `bool` | `false` | no |
3535

3636
## Outputs

examples/simple/README.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,16 @@
1818

1919
| Name | Source | Version |
2020
|------|--------|---------|
21+
| <a name="module_kms_key"></a> [kms\_key](#module\_kms\_key) | terraform.registry.launch.nttdata.com/module_primitive/kms_key/aws | ~> 0.1 |
2122
| <a name="module_kms_key_policy"></a> [kms\_key\_policy](#module\_kms\_key\_policy) | ../../ | n/a |
2223

2324
## Resources
2425

2526
| Name | Type |
2627
|------|------|
27-
| [aws_kms_key.example](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/kms_key) | resource |
2828
| [aws_caller_identity.current](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/caller_identity) | data source |
29+
| [aws_iam_roles.administrator_access](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_roles) | data source |
30+
| [aws_region.current](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/region) | data source |
2931

3032
## Inputs
3133

@@ -38,4 +40,7 @@
3840
| Name | Description |
3941
|------|-------------|
4042
| <a name="output_policy_id"></a> [policy\_id](#output\_policy\_id) | The ID of the KMS Key Policy resource. |
43+
| <a name="output_kms_key_region"></a> [kms\_key\_region](#output\_kms\_key\_region) | Region where the KMS key and policy are managed. |
44+
| <a name="output_key_id"></a> [key\_id](#output\_key\_id) | The ID of the KMS Key associated with the policy. |
45+
| <a name="output_key_arn"></a> [key\_arn](#output\_key\_arn) | The ARN of the KMS Key associated with the policy. |
4146
<!-- END_TF_DOCS -->

0 commit comments

Comments
 (0)