diodonfrost / terraform-aws-lambda-nuke

Terraform module that creates a lambda to destroy all resources in an AWS account.
Apache License 2.0
20 stars 15 forks source link

Terraform > 0.14.x Warning: Interpolation-only expressions are deprecated #3

Closed exequielrafaela closed 3 years ago

exequielrafaela commented 3 years ago
SUMMARY

Warning: Interpolation-only expressions are deprecated

  on .terraform/modules/nuke_everything_daily_midnight/main.tf line 273, in locals:
 273:         "Resource": "${aws_cloudwatch_log_group.this.arn}",
ISSUE TYPE
TERRAFORM VERSION
Terraform v0.14.2
STEPS TO REPRODUCE

Apply the module ussing terraform > 0.14.x

module "nuke_everything_daily_midnight" {
  source = "github.com/binbashar/terraform-aws-lambda-nuke.git?ref=2.10.0"

  # Define name to use for lambda function, cloudwatch event and iam role"
  name        = "${var.project}-${var.environment}-cloud-nuke-everything"
  kms_key_arn = data.terraform_remote_state.keys.outputs.aws_kms_key_arn

  # Define the aws cloudwatch event rule schedule expression,
  # eg1: monday to friday at 22hs cron(0 22 ? * MON-FRI *)
  # eg2: once a week every friday at 00hs cron(0 00 ? * FRI *)
  # eg3: everyday at 00hs cron(0 00 * * ? *)
  cloudwatch_schedule_expression = "cron(0 00 * * ? *)"

  # Define the resources that will not be destroyed, eg: key_pair,eip,
  # network_security,autoscaling,ebs,ec2,ecr,eks,elasticbeanstalk,elb,spot,
  # dynamodb,elasticache,rds,redshift,cloudwatch,endpoint,efs,glacier,s3"
  exclude_resources = "cloudwatch,key_pair,s3,dynamodb,vpc"

  # Only destroy resources that were created before a certain period,
  # eg: 0d, 1d, ... ,7d etc
  older_than = "0d"
}
EXPECTED RESULTS

No warnings expected when applying

ACTUAL RESULTS
Warning: Interpolation-only expressions are deprecated

  on .terraform/modules/nuke_everything_daily_midnight/main.tf line 273, in locals:
 273:         "Resource": "${aws_cloudwatch_log_group.this.arn}",

Terraform 0.11 and earlier required all non-constant expressions to be
provided via interpolation syntax, but this pattern is now deprecated. To
silence this warning, remove the "${ sequence from the start and the }"
sequence from the end of this expression, leaving just the inner expression.

Template interpolation syntax is still used to construct strings from
expressions when the template includes multiple interpolation sequences or a
mixture of literal strings and interpolations. This deprecation applies only
to templates that consist entirely of a single interpolation sequence.

(and 2 more similar warnings elsewhere)
diodonfrost commented 3 years ago

Thanks for your report, I'm going to investigate and write a fix.

diodonfrost commented 3 years ago

Fixed with the latest release, thanks for your help.

exequielrafaela commented 3 years ago

@diodonfrost Thanks Antonie!