Skip to content

Commit

Permalink
Merge pull request #22580 from hashicorp/f-subnet-az-id-iso
Browse files Browse the repository at this point in the history
ec2/subnet: Availability zone ID not supported in all partitions
  • Loading branch information
YakDriver authored Jan 13, 2022
2 parents d7bc984 + ffe4fb3 commit 722a96b
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 7 deletions.
3 changes: 3 additions & 0 deletions .changelog/22580.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:bug
resource/aws_subnet: Protect against errors when `availability_zone_id` is not supported in a partition (e.g., ISO)
```
14 changes: 10 additions & 4 deletions internal/service/ec2/subnet.go
Original file line number Diff line number Diff line change
Expand Up @@ -145,10 +145,16 @@ func resourceSubnetCreate(d *schema.ResourceData, meta interface{}) error {
tags := defaultTagsConfig.MergeTags(tftags.New(d.Get("tags").(map[string]interface{})))

input := &ec2.CreateSubnetInput{
AvailabilityZone: aws.String(d.Get("availability_zone").(string)),
AvailabilityZoneId: aws.String(d.Get("availability_zone_id").(string)),
TagSpecifications: ec2TagSpecificationsFromKeyValueTags(tags, ec2.ResourceTypeSubnet),
VpcId: aws.String(d.Get("vpc_id").(string)),
TagSpecifications: ec2TagSpecificationsFromKeyValueTags(tags, ec2.ResourceTypeSubnet),
VpcId: aws.String(d.Get("vpc_id").(string)),
}

if v, ok := d.GetOk("availability_zone"); ok {
input.AvailabilityZone = aws.String(v.(string))
}

if v, ok := d.GetOk("availability_zone_id"); ok {
input.AvailabilityZoneId = aws.String(v.(string))
}

if v, ok := d.GetOk("cidr_block"); ok {
Expand Down
2 changes: 1 addition & 1 deletion website/docs/d/subnet.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ The arguments of this data source act as filters for querying the available subn
The following arguments are optional:

* `availability_zone` - (Optional) Availability zone where the subnet must reside.
* `availability_zone_id` - (Optional) ID of the Availability Zone for the subnet.
* `availability_zone_id` - (Optional) ID of the Availability Zone for the subnet. This argument is not supported in all regions or partitions. If necessary, use `availability_zone` instead.
* `cidr_block` - (Optional) CIDR block of the desired subnet.
* `default_for_az` - (Optional) Whether the desired subnet must be the default subnet for its associated availability zone.
* `filter` - (Optional) Configuration block. Detailed below.
Expand Down
4 changes: 2 additions & 2 deletions website/docs/r/subnet.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ The following arguments are supported:
* `assign_ipv6_address_on_creation` - (Optional) Specify true to indicate
that network interfaces created in the specified subnet should be
assigned an IPv6 address. Default is `false`
* `availability_zone` - (Optional) The AZ for the subnet.
* `availability_zone_id` - (Optional) The AZ ID of the subnet.
* `availability_zone` - (Optional) AZ for the subnet.
* `availability_zone_id` - (Optional) AZ ID of the subnet. This argument is not supported in all regions or partitions. If necessary, use `availability_zone` instead.
* `cidr_block` - (Optional) The IPv4 CIDR block for the subnet.
* `customer_owned_ipv4_pool` - (Optional) The customer owned IPv4 address pool. Typically used with the `map_customer_owned_ip_on_launch` argument. The `outpost_arn` argument must be specified when configured.
* `enable_dns64` - (Optional) Indicates whether DNS queries made to the Amazon-provided DNS Resolver in this subnet should return synthetic IPv6 addresses for IPv4-only destinations. Default: `false`.
Expand Down

0 comments on commit 722a96b

Please sign in to comment.