Skip to content

Commit

Permalink
Adding a random to the secret of eks
Browse files Browse the repository at this point in the history
  • Loading branch information
LeoDiazL committed Dec 12, 2023
1 parent f2b3e9f commit c88a030
Showing 1 changed file with 11 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ resource "aws_key_pair" "aws_key" {
// Creates a secret manager secret for the public key
resource "aws_secretsmanager_secret" "keys_sm_secret" {
count = var.aws_eks_ec2_key_pair == "" ? ( var.aws_eks_store_keypair_sm ? 1 : 0 ) : 0
name = "${var.aws_resource_identifier}-ec2kp-eks"
name = "${var.aws_resource_identifier}-ec2kp-eks-${random_string.random.result}"
}

resource "aws_secretsmanager_secret_version" "keys_sm_secret_version" {
Expand All @@ -30,4 +30,14 @@ resource "aws_secretsmanager_secret_version" "keys_sm_secret_version" {
"value": "${sensitive(tls_private_key.key[0].private_key_openssh)}"
}
EOF
}

resource "random_string" "random" {
length = 5
lower = true
special = false
numeric = false
lifecycle {
ignore_changes = all
}
}

0 comments on commit c88a030

Please sign in to comment.