Skip to content

Commit

Permalink
Filter out opt-in AZs in terraform-aws
Browse files Browse the repository at this point in the history
When finding an AZ, filter out local and any opt-in zones, otherwise we
might end up with a zone that does not support certain features (e.g.
mapping public IPs in Wavelength zones).
  • Loading branch information
ldx committed Oct 28, 2020
1 parent 9df9e3e commit 71f5cab
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions deploy/terraform-aws/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,21 @@ locals {
}

data "aws_availability_zones" "available_azs" {
state = "available"
exclude_zone_ids = var.excluded_azs
state = "available"
exclude_zone_ids = var.excluded_azs

filter {
name = "opt-in-status"
values = ["opt-in-not-required"]
}
}

resource "random_shuffle" "azs" {
input = data.aws_availability_zones.available_azs.names
result_count = 1
keepers = {
availables_azs = join(",", data.aws_availability_zones.available_azs.names)
}
}

resource "aws_vpc" "main" {
Expand Down

0 comments on commit 71f5cab

Please sign in to comment.