Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace null_resource with terraform_data #40

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 5 additions & 6 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ resource "aws_lambda_function" "this" {

depends_on = [
aws_cloudwatch_log_group.this,
null_resource.watch_iam_role_policy_secretsmanager_get_secret_value,
terraform_data.watch_iam_role_policy_secretsmanager_get_secret_value,
]
}

Expand Down Expand Up @@ -224,13 +224,12 @@ resource "aws_iam_role_policy" "secretsmanager-get-secret-value" {
# first, then we need to wait for a few seconds and only then update the lambda function itself.
# Waiting is necessary because otherwise the during initialization of the lambda function
# it will not yet have the permissions for fetching the secret values.
resource "null_resource" "watch_iam_role_policy_secretsmanager_get_secret_value" {
resource "terraform_data" "watch_iam_role_policy_secretsmanager_get_secret_value" {
count = length(var.secret_environment_variables) > 0 ? 1 : 0

# null_resource is replaced every time the policy changes
triggers = {
secretsmanager_get_secret_value_policy = aws_iam_role_policy.secretsmanager-get-secret-value[count.index].policy
}
triggers_replace = [
aws_iam_role_policy.secretsmanager-get-secret-value[count.index].policy
]

provisioner "local-exec" {
command = "sleep 15"
Expand Down
Loading