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

v0.6.0 breaks aws_cloudwatch_log_group names #78

Closed
MaxymVlasov opened this issue Aug 28, 2024 · 4 comments · Fixed by #79
Closed

v0.6.0 breaks aws_cloudwatch_log_group names #78

MaxymVlasov opened this issue Aug 28, 2024 · 4 comments · Fixed by #79
Labels
bug 🐛 An issue with the system

Comments

@MaxymVlasov
Copy link

MaxymVlasov commented Aug 28, 2024

Describe the Bug

#74 actually breaks aws_cloudwatch_log_group names

# module.lambda_cloudtrail_lookup[0].module.cloudwatch_log_group.aws_cloudwatch_log_group.default[0] must be replaced
-/+ resource "aws_cloudwatch_log_group" "default" {
      ~ arn               = "arn:aws:logs:us-east-1:012345678910:log-group:/aws/lambda/compromised-keys-cloudtrail-lookup" -> (known after apply)
      ~ id                = "/aws/lambda/compromised-keys-cloudtrail-lookup" -> (known after apply)
      ~ log_group_class   = "STANDARD" -> (known after apply)
      ~ name              = "/aws/lambda/compromised-keys-cloudtrail-lookup" -> "namespace-environment-stage-/aws/lambda/compromised-keys-cloudtrail-lookup" # forces replacement
      + name_prefix       = (known after apply)
      ~ tags              = {
          ~ "Name"                         = "namespace-environment-stage-compromised-keys" -> "namespace-environment-stage-/aws/lambda/compromised-keys-cloudtrail-lookup"
        }
      ~ tags_all          = {
          ~ "Name"                         = "namespace-environment-stage-compromised-keys" -> "namespace-environment-stage-/aws/lambda/compromised-keys-cloudtrail-lookup"
            # (15 unchanged elements hidden)
        }
        # (2 unchanged attributes hidden)
    }

  # module.lambda_delete_key[0].module.cloudwatch_log_group.aws_cloudwatch_log_group.default[0] must be replaced
-/+ resource "aws_cloudwatch_log_group" "default" {
      ~ arn               = "arn:aws:logs:us-east-1:012345678910:log-group:/aws/lambda/compromised-keys-delete-key" -> (known after apply)
      ~ id                = "/aws/lambda/compromised-keys-delete-key" -> (known after apply)
      ~ log_group_class   = "STANDARD" -> (known after apply)
      ~ name              = "/aws/lambda/compromised-keys-delete-key" -> "namespace-environment-stage-/aws/lambda/compromised-keys-delete-key" # forces replacement
      + name_prefix       = (known after apply)
      ~ tags              = {
          ~ "Name"                         = "namespace-environment-stage-compromised-keys" -> "namespace-environment-stage-/aws/lambda/compromised-keys-delete-key"
        }
      ~ tags_all          = {
          ~ "Name"                         = "namespace-environment-stage-compromised-keys" -> "namespace-environment-stage-/aws/lambda/compromised-keys-delete-key"
            # (15 unchanged elements hidden)
        }
        # (2 unchanged attributes hidden)
    }

  # module.lambda_notify_security[0].module.cloudwatch_log_group.aws_cloudwatch_log_group.default[0] must be replaced
-/+ resource "aws_cloudwatch_log_group" "default" {
      ~ arn               = "arn:aws:logs:us-east-1:012345678910:log-group:/aws/lambda/compromised-keys-notify-security" -> (known after apply)
      ~ id                = "/aws/lambda/compromised-keys-notify-security" -> (known after apply)
      ~ log_group_class   = "STANDARD" -> (known after apply)
      ~ name              = "/aws/lambda/compromised-keys-notify-security" -> "namespace-environment-stage-/aws/lambda/compromised-keys-notify-security" # forces replacement
      + name_prefix       = (known after apply)
      ~ tags              = {
          ~ "Name"                         = "namespace-environment-stage-compromised-keys" -> "namespace-environment-stage-/aws/lambda/compromised-keys-notify-security"
        }
      ~ tags_all          = {
          ~ "Name"                         = "namespace-environment-stage-compromised-keys" -> "namespace-environment-stage-/aws/lambda/compromised-keys-notify-security"
            # (15 unchanged elements hidden)
        }
        # (2 unchanged attributes hidden)
    }

Plan: 3 to add, 0 to change, 3 to destroy.

Expected Behavior

name should be not changed
https://github.com/cloudposse/terraform-aws-lambda-function/pull/74/files#diff-dc46acf24afd63ef8c556b77c126ccc6e578bc87e3aa09a931f33d9bf2532fbbR15

Possible solution: Provide all context variables except name

Steps to Reproduce

  1. Create https://github.com/cloudposse/terraform-aws-lambda-function/blob/main/examples/complete/main.tf on v0.5.5
  2. Update to v0.6.0

Screenshots

No response

Environment

No response

Additional Context

No response

@MaxymVlasov MaxymVlasov added the bug 🐛 An issue with the system label Aug 28, 2024
@MaxymVlasov
Copy link
Author

MaxymVlasov commented Aug 28, 2024

@milldr also I'm curious - do you have tests that check upgrade (print out tf plan changes) from current version to changes in PR, or only test that PR pass creation-removal resources tests?

@milldr
Copy link
Member

milldr commented Aug 28, 2024

@milldr also I'm curious - do you have tests that check upgrade (print out tf plan changes) from current version to changes in PR, or only test that PR pass creation-removal resources tests?

In most modules we do, but looks like we don't here. I'll revert the last release

@nnsense
Copy link
Contributor

nnsense commented Aug 28, 2024

To be honest, I think hardcoding /aws/lambda/ is creating issues. I understand that's by default what lambda does if you create it on the UI but we have the freedom to allow the user to chose their pattern if they wish. I will propose a new PR trying to deal with that, let me give another go :)

@milldr
Copy link
Member

milldr commented Aug 28, 2024

I've opened PR #79 to revert the changes and add tests and necessary outputs to catch any breaking changes going forward

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 🐛 An issue with the system
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants