Created
October 23, 2020 11:19
-
-
Save reschenburgIDBS/39904d36055b532813fb00ca82ae9c2f to your computer and use it in GitHub Desktop.
terraform Global Accelerator Security Group in VPC workaround
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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