Skip to content

fix(terraform/k8s-secrets): filtering secrets without versions#423

Open
micheledellipaoli-pagopa wants to merge 3 commits intomainfrom
fix-terraform-k8s-secrets-automation
Open

fix(terraform/k8s-secrets): filtering secrets without versions#423
micheledellipaoli-pagopa wants to merge 3 commits intomainfrom
fix-terraform-k8s-secrets-automation

Conversation

@micheledellipaoli-pagopa
Copy link
Copy Markdown
Contributor

@micheledellipaoli-pagopa micheledellipaoli-pagopa commented Nov 26, 2025

This PR allows to handle secrets with no secret versions (PIN-8629).

In details, the aws_secretsmanager_secret_version.filtered data source uses a for_each meta argument to obtain the latest secret version for every secret obtained by the aws_secretsmanager_secret.tagged_object data source.
However, if a secret has no secret versions, the aws_secretsmanager_secret_version.filtered data source ends up in error.
Unfortunately, there is no way to understand if a secret has a secret version based on its attributes.

The only way to filter secrets to get only those with at least one secret version is to use a data external that runs a bash script.
Such script checks, for each secret taken as input, if the secret has at least one version: if so, it adds the name of the secret to the output list.
Finally, it returns the output list (containing the name of the secrets having at least one version) as json string.

@micheledellipaoli-pagopa micheledellipaoli-pagopa changed the title fix(terraform): filtering secrets with NoSecretVersion tag fix(terraform): filtering secrets without versions by using a data external that runs a bash script Nov 28, 2025
@micheledellipaoli-pagopa micheledellipaoli-pagopa marked this pull request as ready for review November 28, 2025 14:40
@micheledellipaoli-pagopa micheledellipaoli-pagopa changed the title fix(terraform): filtering secrets without versions by using a data external that runs a bash script fix(terraform/k8s-secrets): filtering secrets without versions Nov 28, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant