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

awscc_applicationsignals_service_level_objective failed to create ServiceLevelObjective: "Only one metric │ config must be populated" #2156

Open
anna-altruistiq opened this issue Jan 10, 2025 · 1 comment

Comments

@anna-altruistiq
Copy link

Description

I am trying to create availability SLO with awscc_applicationsignals_service_level_objective by defining 'total_request_count_metric' and 'bad_count_metric', but get an error that "Only one metric │ config must be populated".

Community Note

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
  • Please do not leave "+1" or other comments that do not add relevant new information or questions, they generate extra noise for issue followers and do not help prioritize the request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment
  • The resources and data sources in this provider are generated from the CloudFormation schema, so they can only support the actions that the underlying schema supports. For this reason submitted bugs should be limited to defects in the generation and runtime code of the provider. Customizing behavior of the resource, or noting a gap in behavior are not valid bugs and should be submitted as enhancements to AWS via the CloudFormation Open Coverage Roadmap.

Terraform CLI and Terraform AWS Cloud Control Provider Version

Terraform v1.10.4
on darwin_arm64
+ provider registry.terraform.io/hashicorp/aws v5.83.0
+ provider registry.terraform.io/hashicorp/awscc v1.24.0

Affected Resource(s)

awscc_applicationsignals_service_level_objective

Terraform Configuration Files

terraform {
  required_providers {
    aws = {
      source  = "hashicorp/aws"
      version = "~> 5.0"
    }
    awscc = {
      source  = "hashicorp/awscc"
      version = "~> 1.24.0"
    }
  }
}

provider "awscc" {
  region = "eu-west-1"
}

provider "aws" {
  region = "eu-west-1"
}

variable "period" {
  type        = number
  description = "The period in which to evaluate the SLO (seconds)"
  default     = 300
}

variable "api_name" {
  type        = string
  description = "The name of the API to monitor"
  default     = "status-page-test"
}

variable "stage_name" {
  type        = string
  description = "The name of the stage to monitor"
  default     = "default"
}

variable "methods" {
  type        = list(string)
  description = "The HTTP methods to monitor"
  default     = ["GET"]
}

resource "awscc_applicationsignals_service_level_objective" "availability-slo" {
  for_each    = toset(var.methods)
  name        = "api-availability-slo-${var.api_name}-${each.value}"
  description = "API availability SLO using CloudWatch metrics"

  # Set up a request-based SLI
  request_based_sli = {

    request_based_sli_metric = {
      key_attributes = {
        "Type" = "Service"
      }
      operation_name = each.value
      metric_type    = "AVAILABILITY"

      monitored_request_count_metric = {

        bad_count_metric = [{
          id          = "bad"
          return_data = false
          metric_stat = {
            period = var.period
            stat   = "Sum"
            unit   = "Count"
            metric = {
              namespace   = "AWS/ApiGateway"
              metric_name = "5XXError"
              dimensions = [
                {
                  name  = "ApiName"
                  value = var.api_name
                },
                {
                  name  = "Stage"
                  value = var.stage_name
                },
                {
                  name  = "Method"
                  value = each.value
                }
              ]
            }
          }
        }]

      }

      total_request_count_metric = [{
        id          = "total"
        return_data = false
        metric_stat = {
          period = var.period
          stat   = "Sum"
          //unit   = "Count"
          metric = {
            namespace   = "AWS/ApiGateway"
            metric_name = "Count"
            dimensions = [
              {
                name  = "ApiName"
                value = var.api_name
              },
              {
                name  = "Stage"
                value = var.stage_name
              },
              {
                name  = "Method"
                value = each.value
              }
            ]
          }
        }
      }]
    }
  }

  # Define the goal
  goal = {
    attainment_goal = 99.9
    interval = {
      rolling_interval = {
        duration      = 1
        duration_unit = "DAY"
      }
    }
    warning_threshold = 30.0
  }

  # Add burn rate configurations
  burn_rate_configurations = [
    {
      look_back_window_minutes = 60 # 1 hour
    },
    {
      look_back_window_minutes = 1440 # 24 hours
    }
  ]

  # Add tags
  tags = [
    {
      key   = "Environment"
      value = "Production"
    },
    {
      key   = "ModifiedBy"
      value = "AWSCC"
    }
  ]
}

Debug Output

https://gist.github.com/anna-altruistiq/ae790e6c608452eebeef740344d058e3

Panic Output

Expected Behavior

Resource "awscc_applicationsignals_service_level_objective" "availability-slo" is created, 'terraform apply' returned no errors.

Actual Behavior

awscc_applicationsignals_service_level_objective.availability-slo["GET"]: Creating...
╷
│ Error: AWS SDK Go Service Operation Incomplete
│ 
│   with awscc_applicationsignals_service_level_objective.availability-slo["GET"],
│   on for-report.tf line 46, in resource "awscc_applicationsignals_service_level_objective" "availability-slo":
│   46: resource "awscc_applicationsignals_service_level_objective" "availability-slo" {
│ 
│ Waiting for Cloud Control API service CreateResource operation completion returned: waiter state transitioned to FAILED. StatusMessage: Invalid request
│ provided: AWS::ApplicationSignals::ServiceLevelObjective. Only one metric config must be populated (Service: ApplicationSignals, Status Code: 400, Request
│ ID: 55135437-957f-48e1-8647-68ca33997d54). ErrorCode: InvalidRequest

Steps to Reproduce

  1. terraform apply
  2. See the error in the terminal

Important Factoids

References

  • #0000
@liunia-amazon
Copy link

"Only one metric config must be populated" Error message is thrown when both serviceConfig and advanced CloudWatchMetricConfig are populated. In your request, request_based_sli_metric sets both serviceSLI config (keyAttributes, operationName, metricType) and advanced CWconfig by specifying the CW metrics as below.

metric = {
              namespace   = "AWS/ApiGateway"
              metric_name = "5XXError"
              dimensions = [
                {
                  name  = "ApiName"
                  value = var.api_name
                },
                {
                  name  = "Stage"
                  value = var.stage_name
                },
                {
                  name  = "Method"
                  value = each.value
                }

If you only set one SLI config, for example, remove

key_attributes = {
        "Type" = "Service"
      }
      operation_name = each.value
      metric_type    = "AVAILABILITY"

and only keep CW metrics, then issue should be mitigated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants