diff --git a/aws/data_source_aws_subnet.go b/aws/data_source_aws_subnet.go index cf0ee0f056e..371b995af11 100644 --- a/aws/data_source_aws_subnet.go +++ b/aws/data_source_aws_subnet.go @@ -106,6 +106,11 @@ func dataSourceAwsSubnet() *schema.Resource { Type: schema.TypeString, Computed: true, }, + + "available_ip_address_count": { + Type: schema.TypeInt, + Computed: true, + }, }, } } @@ -178,6 +183,7 @@ func dataSourceAwsSubnetRead(d *schema.ResourceData, meta interface{}) error { d.SetId(aws.StringValue(subnet.SubnetId)) d.Set("vpc_id", subnet.VpcId) + d.Set("available_ip_address_count", subnet.AvailableIpAddressCount) d.Set("availability_zone", subnet.AvailabilityZone) d.Set("availability_zone_id", subnet.AvailabilityZoneId) d.Set("cidr_block", subnet.CidrBlock) diff --git a/aws/data_source_aws_subnet_test.go b/aws/data_source_aws_subnet_test.go index 053309b8503..ca1b837d304 100644 --- a/aws/data_source_aws_subnet_test.go +++ b/aws/data_source_aws_subnet_test.go @@ -34,6 +34,7 @@ func TestAccDataSourceAwsSubnet_basic(t *testing.T) { resource.TestCheckResourceAttrPair(ds1ResourceName, "owner_id", snResourceName, "owner_id"), resource.TestCheckResourceAttrPair(ds1ResourceName, "availability_zone", snResourceName, "availability_zone"), resource.TestCheckResourceAttrPair(ds1ResourceName, "availability_zone_id", snResourceName, "availability_zone_id"), + resource.TestCheckResourceAttrPair(ds1ResourceName, "available_ip_address_count", snResourceName, "available_ip_address_count"), resource.TestCheckResourceAttrPair(ds1ResourceName, "vpc_id", vpcResourceName, "id"), resource.TestCheckResourceAttr(ds1ResourceName, "cidr_block", cidr), resource.TestCheckResourceAttr(ds1ResourceName, "tags.Name", tag), @@ -46,6 +47,7 @@ func TestAccDataSourceAwsSubnet_basic(t *testing.T) { resource.TestCheckResourceAttrPair(ds2ResourceName, "owner_id", snResourceName, "owner_id"), resource.TestCheckResourceAttrPair(ds2ResourceName, "availability_zone", snResourceName, "availability_zone"), resource.TestCheckResourceAttrPair(ds2ResourceName, "availability_zone_id", snResourceName, "availability_zone_id"), + resource.TestCheckResourceAttrPair(ds2ResourceName, "available_ip_address_count", snResourceName, "available_ip_address_count"), resource.TestCheckResourceAttrPair(ds2ResourceName, "vpc_id", vpcResourceName, "id"), resource.TestCheckResourceAttr(ds2ResourceName, "cidr_block", cidr), resource.TestCheckResourceAttr(ds2ResourceName, "tags.Name", tag), @@ -58,6 +60,7 @@ func TestAccDataSourceAwsSubnet_basic(t *testing.T) { resource.TestCheckResourceAttrPair(ds3ResourceName, "owner_id", snResourceName, "owner_id"), resource.TestCheckResourceAttrPair(ds3ResourceName, "availability_zone", snResourceName, "availability_zone"), resource.TestCheckResourceAttrPair(ds3ResourceName, "availability_zone_id", snResourceName, "availability_zone_id"), + resource.TestCheckResourceAttrPair(ds3ResourceName, "available_ip_address_count", snResourceName, "available_ip_address_count"), resource.TestCheckResourceAttrPair(ds3ResourceName, "vpc_id", vpcResourceName, "id"), resource.TestCheckResourceAttr(ds3ResourceName, "cidr_block", cidr), resource.TestCheckResourceAttr(ds3ResourceName, "tags.Name", tag), @@ -70,6 +73,7 @@ func TestAccDataSourceAwsSubnet_basic(t *testing.T) { resource.TestCheckResourceAttrPair(ds4ResourceName, "owner_id", snResourceName, "owner_id"), resource.TestCheckResourceAttrPair(ds4ResourceName, "availability_zone", snResourceName, "availability_zone"), resource.TestCheckResourceAttrPair(ds4ResourceName, "availability_zone_id", snResourceName, "availability_zone_id"), + resource.TestCheckResourceAttrPair(ds4ResourceName, "available_ip_address_count", snResourceName, "available_ip_address_count"), resource.TestCheckResourceAttrPair(ds4ResourceName, "vpc_id", vpcResourceName, "id"), resource.TestCheckResourceAttr(ds4ResourceName, "cidr_block", cidr), resource.TestCheckResourceAttr(ds4ResourceName, "tags.Name", tag), @@ -82,6 +86,7 @@ func TestAccDataSourceAwsSubnet_basic(t *testing.T) { resource.TestCheckResourceAttrPair(ds5ResourceName, "owner_id", snResourceName, "owner_id"), resource.TestCheckResourceAttrPair(ds5ResourceName, "availability_zone", snResourceName, "availability_zone"), resource.TestCheckResourceAttrPair(ds5ResourceName, "availability_zone_id", snResourceName, "availability_zone_id"), + resource.TestCheckResourceAttrPair(ds5ResourceName, "available_ip_address_count", snResourceName, "available_ip_address_count"), resource.TestCheckResourceAttrPair(ds5ResourceName, "vpc_id", vpcResourceName, "id"), resource.TestCheckResourceAttr(ds5ResourceName, "cidr_block", cidr), resource.TestCheckResourceAttr(ds5ResourceName, "tags.Name", tag), @@ -94,6 +99,7 @@ func TestAccDataSourceAwsSubnet_basic(t *testing.T) { resource.TestCheckResourceAttrPair(ds6ResourceName, "owner_id", snResourceName, "owner_id"), resource.TestCheckResourceAttrPair(ds6ResourceName, "availability_zone", snResourceName, "availability_zone"), resource.TestCheckResourceAttrPair(ds6ResourceName, "availability_zone_id", snResourceName, "availability_zone_id"), + resource.TestCheckResourceAttrPair(ds6ResourceName, "available_ip_address_count", snResourceName, "available_ip_address_count"), resource.TestCheckResourceAttrPair(ds6ResourceName, "vpc_id", vpcResourceName, "id"), resource.TestCheckResourceAttr(ds6ResourceName, "cidr_block", cidr), resource.TestCheckResourceAttr(ds6ResourceName, "tags.Name", tag), diff --git a/website/docs/d/subnet.html.markdown b/website/docs/d/subnet.html.markdown index db1d9a4d6e5..5a4c8b7df45 100644 --- a/website/docs/d/subnet.html.markdown +++ b/website/docs/d/subnet.html.markdown @@ -100,5 +100,6 @@ In addition the following attributes are exported: * `customer_owned_ipv4_pool` - Identifier of customer owned IPv4 address pool. * `map_customer_owned_ip_on_launch` - Whether customer owned IP addresses are assigned on network interface creation. * `map_public_ip_on_launch` - Whether public IP addresses are assigned on instance launch. +* `available_ip_address_count` - The available IP addresses of the subnet. * `owner_id` - The ID of the AWS account that owns the subnet. * `outpost_arn` - The Amazon Resource Name (ARN) of the Outpost.