This template configures an AWS Shield Application Layer Automatic Response to perform a COUNT action on a specified CloudFront distribution for DDoS mitigation.

Terraform Template

variable "distribution_id" {
  description = "The Cloudfront Distribution on which to enable the Application Layer Automatic Response."
  type = "string"
}

data "aws_caller_identity" "current" {
}

data "aws_partition" "current" {
}

data "aws_region" "current" {
}

resource "aws_shield_application_layer_automatic_response" "example" {
  action = "COUNT"
  resource_arn = "arn:${data.aws_partition.current.partition}:cloudfront:${data.aws_caller_identity.current.account_id}:distribution/${var.distribution_id}"
}