Resource: aws_shield_protection_group

Creates a grouping of protected resources so they can be handled as a collective. This resource grouping improves the accuracy of detection and reduces false positives. For more information see Managing AWS Shield Advanced protection groups

Example Usage

Create protection group for all resources

resource "aws_shield_protection_group" "example" {
  protection_group_id = "example"
  aggregation         = "MAX"
  pattern             = "ALL"
}

Create protection group for arbitrary number of resources

data "aws_region" "current" {}
data "aws_caller_identity" "current" {}

resource "aws_eip" "example" {
  domain = "vpc"
}

resource "aws_shield_protection" "example" {
  name         = "example"
  resource_arn = "arn:aws:ec2:${data.aws_region.current.name}:${data.aws_caller_identity.current.account_id}:eip-allocation/${aws_eip.example.id}"
}

resource "aws_shield_protection_group" "example" {
  depends_on = [aws_shield_protection.example]

  protection_group_id = "example"
  aggregation         = "MEAN"
  pattern             = "ARBITRARY"
  members             = ["arn:aws:ec2:${data.aws_region.current.name}:${data.aws_caller_identity.current.account_id}:eip-allocation/${aws_eip.example.id}"]
}

Create protection group for a type of resource

resource "aws_shield_protection_group" "example" {
  protection_group_id = "example"
  aggregation         = "SUM"
  pattern             = "BY_RESOURCE_TYPE"
  resource_type       = "ELASTIC_IP_ALLOCATION"
}

Argument Reference

This resource supports the following arguments:

Attribute Reference

This resource exports the following attributes in addition to the arguments above:

Import

In Terraform v1.5.0 and later, use an import block to import Shield protection group resources using their protection group id. For example:

import {
  to = aws_shield_protection_group.example
  id = "example"
}

Using terraform import, import Shield protection group resources using their protection group id. For example:

% terraform import aws_shield_protection_group.example example