Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Terraform error creating a pattern of a aws_cloudwatch_log_metric_filter

Im trying to create a metric filter like this:

resource "aws_cloudwatch_log_metric_filter" "name_resource" {
  name           = "MetricName"
  pattern        = "{($.errorCode="*UnauthorizedOperation") || ($.errorCode="AccessDenied*")}"
  log_group_name = var.log_group_cloudtrail_name


  metric_transformation {
    name          = "MetricName"
    namespace     = "MetricNameSpace"
    value         = "1"
    default_value = "0"
  }
}

However Im getting this error:

│ Error: Missing newline after argument
│
│   on metric_filter.tf line 3, in resource "aws_cloudwatch_log_metric_filter" "name_resource":
│    3:   pattern        = "{($.errorCode="*UnauthorizedOperation") || ($.errorCode="AccessDenied*")}"
│
│ An argument definition must end with a newline.

I think that the problem is the quotes, but if I try to use single quotes, I get another error because they are not available.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

How can I deal with this problem?

>Solution :

You have to escape the quotes:

pattern        = "{($.errorCode=\"*UnauthorizedOperation\") || ($.errorCode=\"AccessDenied*\")}"
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading