Skip to content

Commit

Permalink
Adds available_ip_address_count.
Browse files Browse the repository at this point in the history
  • Loading branch information
Sandor Irhazi authored and YakDriver committed Feb 18, 2021
1 parent 4a57068 commit e7fa342
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 0 deletions.
6 changes: 6 additions & 0 deletions aws/data_source_aws_subnet.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,11 @@ func dataSourceAwsSubnet() *schema.Resource {
Type: schema.TypeString,
Computed: true,
},

"available_ip_address_count": {
Type: schema.TypeInt,
Computed: true,
},
},
}
}
Expand Down Expand Up @@ -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)
Expand Down
6 changes: 6 additions & 0 deletions aws/data_source_aws_subnet_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand All @@ -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),
Expand All @@ -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),
Expand All @@ -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),
Expand All @@ -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),
Expand All @@ -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),
Expand Down
1 change: 1 addition & 0 deletions website/docs/d/subnet.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -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.

0 comments on commit e7fa342

Please sign in to comment.