cloudposse / terraform-aws-lambda-function

A module for launching Lambda Fuctions
https://cloudposse.com/accelerate
Apache License 2.0
29 stars 39 forks source link

Churn with `aws_iam_role.this` #62

Open kevcube opened 3 months ago

kevcube commented 3 months ago

Describe the Bug

There is a permanent name change with aws_iam_role.this which is causing the resource to be recreated on every apply.

This is causing further issues with KMS permissions in the lambda function being revoked, including permissions to the default KMS key.

See https://github.com/serverless/examples/issues/279 for context regarding KMS key

Expected Behavior

IAM role should not be constantly recreated.

Steps to Reproduce

Apply module, apply again.

Screenshots

No response

Environment

No response

Additional Context

No response

kevcube commented 3 months ago

It appears this is only a problem when using this module with...

module "lambda" {
  ...
  ...

  depends_on = [data.archive_file.lambda_zip]
}

Because the zip file gets refreshed on every deploy, then the data sources for region, partition etc are refreshed

causing the roles to think they must be re-created because they depend on apply-time stuff.

this is a tricky one to fix. I am going to implement a workaround in my infra now so I can continue moving forward. Idk if I will find time to implement a fix.