Skip to content

Commit 0f51e4b

Browse files
authored
feat: introduce new option ignore_changes_enabled and update actions (#7)
1 parent e833eb7 commit 0f51e4b

File tree

14 files changed

+63
-47
lines changed

14 files changed

+63
-47
lines changed

.github/workflows/docs.yml

+4-4
Original file line numberDiff line numberDiff line change
@@ -6,28 +6,28 @@ jobs:
66
docs:
77
runs-on: ubuntu-latest
88
steps:
9-
- uses: actions/checkout@v2
9+
- uses: actions/checkout@v3
1010
with:
1111
ref: ${{ github.event.pull_request.head.ref }}
1212

1313
- name: Render terraform docs inside the examples/basic/README.md
14-
uses: terraform-docs/gh-actions@v0.11.0
14+
uses: terraform-docs/gh-actions@v1.0.0
1515
with:
1616
working-dir: ./examples/basic/
1717
git-push: "false"
1818
output-file: README.md
1919
config-file: ".terraform-docs.yml"
2020

2121
- name: Render terraform docs inside the examples/basic/README.md
22-
uses: terraform-docs/gh-actions@v0.11.0
22+
uses: terraform-docs/gh-actions@v1.0.0
2323
with:
2424
working-dir: ./examples/replicated/
2525
git-push: "false"
2626
output-file: README.md
2727
config-file: ".terraform-docs.yml"
2828

2929
- name: Render terraform docs inside the README.md
30-
uses: terraform-docs/gh-actions@v0.11.0
30+
uses: terraform-docs/gh-actions@v1.0.0
3131
with:
3232
working-dir: .
3333
git-push: "true"

.github/workflows/labeler.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ jobs:
88
name: Auto Label
99
runs-on: ubuntu-latest
1010
steps:
11-
- uses: fuxingloh/multi-labeler@v1.5.0
11+
- uses: fuxingloh/multi-labeler@v2.0.3
1212
with:
1313
github-token: ${{ secrets.GITHUB_TOKEN }}
14-
config-path: .github/labeler.yml
14+
config-path: .github/labeler.yml

.github/workflows/labels.yml

+3-3
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@ jobs:
1212
name: Sync labels in the declarative way
1313
runs-on: ubuntu-latest
1414
steps:
15-
- uses: actions/checkout@v2
16-
- uses: micnncim/action-label-syncer@v0.3.1
15+
- uses: actions/checkout@v3
16+
- uses: micnncim/action-label-syncer@v1.3.0
1717
env:
1818
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
1919
GITHUB_REPOSITORY: ${{ github.repository }}
2020
with:
21-
manifest: .github/labels.yml
21+
manifest: .github/labels.yml

.github/workflows/pr-lint.yml

+7-2
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,27 @@ name: PR title conformance
22

33
on:
44
pull_request_target:
5+
types:
6+
- opened
7+
- reopened
8+
- edited
9+
- synchronize
510

611
jobs:
712
lint-pr:
813
runs-on: ubuntu-latest
914

1015
steps:
1116
- name: Lint PR
12-
uses: aslafy-z/conventional-pr-title-action@v2.4.1
17+
uses: aslafy-z/conventional-pr-title-action@v3.0.1
1318
with:
1419
preset: conventional-changelog-angular@^5.0.6
1520
env:
1621
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
1722

1823
- name: Comment for PR title conformance
1924
if: failure()
20-
uses: peter-evans/create-or-update-comment@v1
25+
uses: peter-evans/create-or-update-comment@v3
2126
with:
2227
issue-number: ${{tojson(github.event.number)}}
2328
body: |

.github/workflows/release.yml

+7-8
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
name: Release Drafter
32

43
on:
@@ -11,10 +10,10 @@ jobs:
1110
publish:
1211
runs-on: ubuntu-latest
1312
steps:
14-
- uses: release-drafter/release-drafter@v5
15-
with:
16-
publish: true
17-
prerelease: false
18-
config-name: auto-release.yml
19-
env:
20-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
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.GITHUB_TOKEN }}

.github/workflows/stale.yml

+10-11
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,19 @@ name: Mark stale issues and pull requests
22

33
on:
44
schedule:
5-
- cron: "0 12 * * *"
5+
- cron: "0 12 * * *"
66

77
jobs:
88
stale:
9-
109
runs-on: ubuntu-latest
1110

1211
steps:
13-
- uses: actions/stale@v1
14-
with:
15-
repo-token: ${{ secrets.GITHUB_TOKEN }}
16-
stale-issue-message: 'This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days'
17-
stale-pr-message: 'This pull-request is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days'
18-
stale-issue-label: 'no-issue-activity'
19-
stale-pr-label: 'no-pr-activity'
20-
days-before-stale: 30
21-
days-before-close: 5
12+
- uses: actions/stale@v8
13+
with:
14+
repo-token: ${{ secrets.GITHUB_TOKEN }}
15+
stale-issue-message: "This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days"
16+
stale-pr-message: "This pull-request is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days"
17+
stale-issue-label: "no-issue-activity"
18+
stale-pr-label: "no-pr-activity"
19+
days-before-stale: 30
20+
days-before-close: 5

.github/workflows/terraform.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@ jobs:
99
runs-on: ubuntu-latest
1010
steps:
1111
- name: Checkout
12-
uses: actions/checkout@v2
12+
uses: actions/checkout@v3
1313

1414
- name: Setup Terraform
15-
uses: hashicorp/setup-terraform@v1
15+
uses: hashicorp/setup-terraform@v2
1616
with:
1717
terraform_version: 1.3.0
1818

.github/workflows/tflint.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@ jobs:
99
runs-on: ubuntu-latest
1010
steps:
1111
- name: Checkout
12-
uses: actions/checkout@v2
12+
uses: actions/checkout@v3
1313

1414
- name: Setup Terraform
15-
uses: hashicorp/setup-terraform@v1
15+
uses: hashicorp/setup-terraform@v2
1616
with:
1717
terraform_version: 1.3.0
1818

.github/workflows/tfsec.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@ jobs:
1010

1111
steps:
1212
- name: Checkout
13-
uses: actions/checkout@v2
13+
uses: actions/checkout@v3
1414

1515
- name: Setup Terraform
16-
uses: hashicorp/setup-terraform@v1
16+
uses: hashicorp/setup-terraform@v2
1717
with:
1818
terraform_version: 1.3.0
1919

README.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ module "secrets" {
6868
| [aws_secretsmanager_secret.default](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/secretsmanager_secret) | resource |
6969
| [aws_secretsmanager_secret_rotation.default](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/secretsmanager_secret_rotation) | resource |
7070
| [aws_secretsmanager_secret_version.default](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/secretsmanager_secret_version) | resource |
71+
| [aws_secretsmanager_secret_version.ignore_changes](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/secretsmanager_secret_version) | resource |
7172

7273
## Inputs
7374

@@ -96,7 +97,7 @@ module "secrets" {
9697
| <a name="input_regex_replace_chars"></a> [regex\_replace\_chars](#input\_regex\_replace\_chars) | Terraform regular expression (regex) string.<br>Characters matching the regex will be removed from the ID elements.<br>If not set, `"/[^a-zA-Z0-9-]/"` is used to remove all characters other than hyphens, letters and digits. | `string` | `null` | no |
9798
| <a name="input_replicas"></a> [replicas](#input\_replicas) | kms\_key\_id:<br> ARN, Key ID, or Alias of the AWS KMS key within the region secret is replicated to.<br>region:<br> Region for replicating the secret. | <pre>list(<br> object(<br> {<br> kms_key_id = string<br> region = string<br> }<br> )<br> )</pre> | `[]` | no |
9899
| <a name="input_rotation"></a> [rotation](#input\_rotation) | enabled:<br> Whether to create secret rotation rule. <br> Default value: `false`<br>lambda\_arn:<br> Specifies the ARN of the Lambda function that can rotate the secret.<br>automatically\_after\_days:<br> Specifies the number of days between automatic scheduled rotations of the secret. | <pre>object({<br> enabled = optional(bool, false)<br> lambda_arn = string<br> automatically_after_days = number<br> })</pre> | <pre>{<br> "automatically_after_days": 0,<br> "lambda_arn": ""<br>}</pre> | no |
99-
| <a name="input_secret_version"></a> [secret\_version](#input\_secret\_version) | enabled:<br> Whether to create secret version. <br> Default value: `false`<br>secret\_string:<br> Specifies text data that you want to encrypt and store in this version of the secret. <br> This is required if `secret_binary` is not set.<br>secret\_binary:<br> Specifies binary data that you want to encrypt and store in this version of the secret. <br> This is required if `secret_string` is not set. <br> Needs to be encoded to base64. | <pre>object({<br> enabled = optional(bool, true)<br> secret_string = optional(string)<br> secret_binary = optional(string)<br> })</pre> | `{}` | no |
100+
| <a name="input_secret_version"></a> [secret\_version](#input\_secret\_version) | ignore\_changes\_enabled:<br> Whether to ignore changes in `secret_string` and `secret_binary`.<br> Default value: `false`<br>secret\_string:<br> Specifies text data that you want to encrypt and store in this version of the secret. <br> This is required if `secret_binary` is not set.<br>secret\_binary:<br> Specifies binary data that you want to encrypt and store in this version of the secret. <br> This is required if `secret_string` is not set. <br> Needs to be encoded to base64. | <pre>object({<br> secret_string = optional(string, "{}")<br> secret_binary = optional(string)<br> ignore_changes_enabled = optional(bool, false)<br> })</pre> | `{}` | no |
100101
| <a name="input_stage"></a> [stage](#input\_stage) | ID element. Usually used to indicate role, e.g. 'prod', 'staging', 'source', 'build', 'test', 'deploy', 'release' | `string` | `null` | no |
101102
| <a name="input_tags"></a> [tags](#input\_tags) | Additional tags (e.g. `{'BusinessUnit': 'XYZ'}`).<br>Neither the tag keys nor the tag values will be modified by this module. | `map(string)` | `{}` | no |
102103
| <a name="input_tenant"></a> [tenant](#input\_tenant) | ID element \_(Rarely used, not included by default)\_. A customer identifier, indicating who this instance of a resource is for | `string` | `null` | no |

examples/basic/main.tf

-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ module "secrets" {
2121
source = "../../"
2222

2323
secret_version = {
24-
enabled = true
2524
secret_string = jsonencode(
2625
{
2726
ssh_public_key = base64encode(module.ssh_key_pair.public_key)

examples/replicated/main.tf

-1
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,6 @@ module "secrets" {
5656
source = "../../"
5757

5858
secret_version = {
59-
enabled = true
6059
secret_string = jsonencode(
6160
{
6261
ssh_public_key = base64encode(module.ssh_key_pair.public_key)

main.tf

+17-3
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,7 @@ locals {
33
secret_name = one(aws_secretsmanager_secret.default[*].name)
44
secret_id = one(aws_secretsmanager_secret.default[*].id)
55
secret_arn = one(aws_secretsmanager_secret.default[*].arn)
6-
version_id = one(aws_secretsmanager_secret_version.default[*].version_id)
7-
secret_version_enabled = local.enabled && var.secret_version["enabled"]
6+
version_id = local.enabled && !var.secret_version["ignore_changes_enabled"] ? one(aws_secretsmanager_secret_version.default[*].version_id) : one(aws_secretsmanager_secret_version.ignore_changes[*].version_id)
87
secret_rotation_enabled = local.enabled && var.rotation["enabled"]
98
kms_key_enabled = local.enabled && var.kms_key["enabled"]
109
kms_key_id = var.kms_key["enabled"] ? module.kms_key.key_id : var.kms_key_id
@@ -45,13 +44,28 @@ resource "aws_secretsmanager_secret" "default" {
4544
}
4645

4746
resource "aws_secretsmanager_secret_version" "default" {
48-
count = local.secret_version_enabled ? 1 : 0
47+
count = local.enabled && !var.secret_version["ignore_changes_enabled"] ? 1 : 0
4948

5049
secret_id = local.secret_id
5150
secret_string = var.secret_version["secret_string"]
5251
secret_binary = var.secret_version["secret_binary"]
5352
}
5453

54+
resource "aws_secretsmanager_secret_version" "ignore_changes" {
55+
count = local.enabled && var.secret_version["ignore_changes_enabled"] ? 1 : 0
56+
57+
secret_id = local.secret_id
58+
secret_string = var.secret_version["secret_string"]
59+
secret_binary = var.secret_version["secret_binary"]
60+
61+
lifecycle {
62+
ignore_changes = [
63+
secret_string,
64+
secret_binary,
65+
]
66+
}
67+
}
68+
5569
resource "aws_secretsmanager_secret_rotation" "default" {
5670
count = local.secret_rotation_enabled ? 1 : 0
5771

variables.tf

+5-5
Original file line numberDiff line numberDiff line change
@@ -75,15 +75,15 @@ variable "kms_key" {
7575

7676
variable "secret_version" {
7777
type = object({
78-
enabled = optional(bool, true)
79-
secret_string = optional(string)
80-
secret_binary = optional(string)
78+
secret_string = optional(string, "{}")
79+
secret_binary = optional(string)
80+
ignore_changes_enabled = optional(bool, false)
8181
})
8282
sensitive = true
8383
default = {}
8484
description = <<-DOC
85-
enabled:
86-
Whether to create secret version.
85+
ignore_changes_enabled:
86+
Whether to ignore changes in `secret_string` and `secret_binary`.
8787
Default value: `false`
8888
secret_string:
8989
Specifies text data that you want to encrypt and store in this version of the secret.

0 commit comments

Comments
 (0)