Skip to content

Instantly share code, notes, and snippets.

@reschenburgIDBS
Created October 23, 2020 11:19
Show Gist options
  • Save reschenburgIDBS/39904d36055b532813fb00ca82ae9c2f to your computer and use it in GitHub Desktop.
Save reschenburgIDBS/39904d36055b532813fb00ca82ae9c2f to your computer and use it in GitHub Desktop.
terraform Global Accelerator Security Group in VPC workaround
resource "aws_vpc" "vpc" {
cidr_block = "10.0.0.0/16"
tags = {
Name = "test-vpc"
}
provisioner "local-exec" {
when = destroy
command = <<EOT
GA_SG=$(aws ec2 describe-security-groups --region ${var.region} --filters Name=vpc-id,Values=${self.id} Name=group-name,Values='GlobalAccelerator' --query 'SecurityGroups[*].[GroupId]' --output text)
if [[ $GA_SG != "" ]]; then
echo "Found a GA SG: $GS_SG - deleting it."
aws ec2 delete-security-group --group-id $GA_SG --region ${var.region}
fi
EOT
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment