Skip to content

Commit

Permalink
Merge pull request #43 from lgallard/fix/issue-42
Browse files Browse the repository at this point in the history
fix: not defined index in context
  • Loading branch information
lgallard authored Oct 30, 2023
2 parents 02935c7 + 80c12a7 commit 2232af1
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@ resource "aws_secretsmanager_secret" "sm" {
for_each = lookup(each.value, "replica_regions", {})
content {
region = try(replica.value.region, replica.key)
kms_key_id = try(replica.value.kms_key_id, null)
kms_key_id = try(replica.value.kms_key_id, null)
}
}
}

resource "aws_secretsmanager_secret_version" "sm-sv" {
for_each = { for k, v in var.secrets : k => v if !var.unmanaged }
secret_id = aws_secretsmanager_secret.sm[index].arn
secret_id = aws_secretsmanager_secret.sm[each.key].arn
secret_string = lookup(each.value, "secret_string", null) != null ? lookup(each.value, "secret_string", null) : (lookup(each.value, "secret_key_value", null) != null ? jsonencode(lookup(each.value, "secret_key_value", {})) : null)
secret_binary = lookup(each.value, "secret_binary", null) != null ? base64encode(lookup(each.value, "secret_binary")) : null
depends_on = [aws_secretsmanager_secret.sm]
Expand All @@ -32,7 +32,7 @@ resource "aws_secretsmanager_secret_version" "sm-sv" {

resource "aws_secretsmanager_secret_version" "sm-svu" {
for_each = { for k, v in var.secrets : k => v if var.unmanaged }
secret_id = aws_secretsmanager_secret.sm[index].arn
secret_id = aws_secretsmanager_secret.sm[each.key].arn
secret_string = lookup(each.value, "secret_string", null) != null ? lookup(each.value, "secret_string") : (lookup(each.value, "secret_key_value", null) != null ? jsonencode(lookup(each.value, "secret_key_value", {})) : null)
secret_binary = lookup(each.value, "secret_binary", null) != null ? base64encode(lookup(each.value, "secret_binary")) : null
depends_on = [aws_secretsmanager_secret.sm]
Expand Down Expand Up @@ -61,7 +61,7 @@ resource "aws_secretsmanager_secret" "rsm" {

resource "aws_secretsmanager_secret_version" "rsm-sv" {
for_each = { for k, v in var.rotate_secrets : k => v if !var.unmanaged }
secret_id = aws_secretsmanager_secret.rsm[index].arn
secret_id = aws_secretsmanager_secret.rsm[each.key].arn
secret_string = lookup(each.value, "secret_string", null) != null ? lookup(each.value, "secret_string") : (lookup(each.value, "secret_key_value", null) != null ? jsonencode(lookup(each.value, "secret_key_value", {})) : null)
secret_binary = lookup(each.value, "secret_binary", null) != null ? base64encode(lookup(each.value, "secret_binary")) : null
depends_on = [aws_secretsmanager_secret.rsm]
Expand All @@ -74,7 +74,7 @@ resource "aws_secretsmanager_secret_version" "rsm-sv" {

resource "aws_secretsmanager_secret_version" "rsm-svu" {
for_each = { for k, v in var.rotate_secrets : k => v if var.unmanaged }
secret_id = aws_secretsmanager_secret.rsm[index].arn
secret_id = aws_secretsmanager_secret.rsm[each.key].arn
secret_string = lookup(each.value, "secret_string", null) != null ? lookup(each.value, "secret_string") : (lookup(each.value, "secret_key_value", null) != null ? jsonencode(lookup(each.value, "secret_key_value", {})) : null)
secret_binary = lookup(each.value, "secret_binary", null) != null ? base64encode(lookup(each.value, "secret_binary")) : null
depends_on = [aws_secretsmanager_secret.rsm]
Expand All @@ -90,7 +90,7 @@ resource "aws_secretsmanager_secret_version" "rsm-svu" {

resource "aws_secretsmanager_secret_rotation" "rsm-sr" {
for_each = var.rotate_secrets
secret_id = aws_secretsmanager_secret.rsm[index].arn
secret_id = aws_secretsmanager_secret.rsm[each.key].arn
rotation_lambda_arn = lookup(each.value, "rotation_lambda_arn")

rotation_rules {
Expand Down

0 comments on commit 2232af1

Please sign in to comment.