Associates a Web ACL with an AWS AppSync GraphQL API for enhanced security.

Terraform Template

resource "aws_appsync_graphql_api" "example" {
  authentication_type = "API_KEY"
  name = "example"
}

resource "aws_wafv2_web_acl" "example" {
  description = "Example of a managed rule."
  name = "managed-rule-example"

  rule {
    name = "rule-1"
    priority = 1

    visibility_config {
      cloudwatch_metrics_enabled = false
      metric_name = "friendly-rule-metric-name"
      sampled_requests_enabled = false
    }
  }
  scope = "REGIONAL"

  visibility_config {
    cloudwatch_metrics_enabled = false
    metric_name = "friendly-metric-name"
    sampled_requests_enabled = false
  }
}

resource "aws_wafv2_web_acl_association" "example" {
  resource_arn = aws_appsync_graphql_api.example.arn
  web_acl_arn = aws_wafv2_web_acl.example.arn
}