Skip to content

Commit ebaae24

Browse files
authored
Merge pull request #2 from Exlabs/fix_policy_name_uniqueness
Fix policy name uniqueness
2 parents 89c067c + c4d6bda commit ebaae24

File tree

3 files changed

+12
-1
lines changed

3 files changed

+12
-1
lines changed

README.md

+3
Original file line numberDiff line numberDiff line change
@@ -45,12 +45,14 @@ After `terraform apply` you have to go to the AWS Console SecretsManager dashboa
4545
|------|---------|
4646
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 0.13.0 |
4747
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 3.30.0 |
48+
| <a name="requirement_random"></a> [random](#requirement\_random) | >= 3.5.0 |
4849

4950
## Providers
5051

5152
| Name | Version |
5253
|------|---------|
5354
| <a name="provider_aws"></a> [aws](#provider\_aws) | >= 3.30.0 |
55+
| <a name="provider_random"></a> [random](#provider\_random) | >= 3.5.0 |
5456

5557
## Modules
5658

@@ -61,6 +63,7 @@ No modules.
6163
| Name | Type |
6264
|------|------|
6365
| [aws_iam_policy.secrets_access](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_policy) | resource |
66+
| [random_id.secrets_access_policy_suffix](https://registry.terraform.io/providers/hashicorp/random/latest/docs/resources/id) | resource |
6467
| [aws_iam_role_policy_attachment.secret_access](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_role_policy_attachment) | resource |
6568
| [aws_secretsmanager_secret.default](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/secretsmanager_secret) | resource |
6669
| [aws_iam_policy_document.secrets_policy](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document) | data source |

main.tf

+5-1
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,12 @@ resource "aws_secretsmanager_secret" "default" {
2222
policy = data.aws_iam_policy_document.secrets_policy.json
2323
}
2424

25+
resource "random_id" "secrets_access_policy_suffix" {
26+
byte_length = 8
27+
}
28+
2529
resource aws_iam_policy secrets_access {
26-
name = "secrets_access"
30+
name = "secrets_access_${random_id.secrets_access_policy_suffix.hex}"
2731
description = "Access rights to SecretsManager Secret created by terraform-aws-ecs-secrets-manager module"
2832

2933
policy = <<-POLICY

versions.tf

+4
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,9 @@ terraform {
66
source = "hashicorp/aws"
77
version = ">= 3.30.0"
88
}
9+
random = {
10+
source = "hashicorp/random"
11+
version = ">= 3.5.0"
12+
}
913
}
1014
}

0 commit comments

Comments
 (0)