Search code examples
amazon-web-servicesterraformterraform-provider-aws

Terraform : Error reason: The ARN isn't valid. A valid ARN begins with arn: and includes other information separated by colons or slashes


I am attempting to integrate the aws_wafv2_web_acl_logging_configuration resource with the aws_cloudwatch_log_group resource in my Terraform configuration. However, I am encountering an error that states:

Error reason: The ARN isn't valid. A valid ARN begins with arn: and includes other information separated by colons or slashes

According to the error aws_cloudwatch_log_group arn is incorrect.

But I followed correct format according to the Terraform documentation. https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/wafv2_web_acl_logging_configuration

Anybody knows the reason for this error? My code as below.

resource "aws_cloudwatch_log_group" "test_waf_log_group" {
  name              = var.waf_log_group_name
  retention_in_days = 14

}

resource "aws_wafv2_web_acl_logging_configuration" "log_test_waf" {
  depends_on = [aws_cloudwatch_log_group.test_waf_log_group]

  log_destination_configs = [aws_cloudwatch_log_group.test_waf_log_group.arn]
  resource_arn            = aws_wafv2_web_acl.test_waf.arn

}

Solution

  • var.waf_log_group_name can't be a random name. It must must include aws-waf-logs- as explained in the AWS docs.