Skip to content

Commit

Permalink
d/aws_eip: Add ipam_pool_id attribute.
Browse files Browse the repository at this point in the history
  • Loading branch information
ewbankkit committed Oct 8, 2024
1 parent acfca9e commit 313d512
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 1 deletion.
4 changes: 4 additions & 0 deletions .changelog/39604.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
```release-note:enhancement
resource/aws_eip: Add `ipam_pool_id` argument in support of [public IPAM pools](https://docs.aws.amazon.com/vpc/latest/ipam/tutorials-eip-pool.html)
```

```release-note:enhancement
data-source/aws_eip: Add `ipam_pool_id` attribute
```
8 changes: 8 additions & 0 deletions internal/service/ec2/ec2_eip_data_source.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ package ec2

import (
"context"
"strings"
"time"

"github.com/aws/aws-sdk-go-v2/aws"
Expand Down Expand Up @@ -65,6 +66,10 @@ func dataSourceEIP() *schema.Resource {
Type: schema.TypeString,
Computed: true,
},
"ipam_pool_id": {
Type: schema.TypeString,
Computed: true,
},
names.AttrNetworkInterfaceID: {
Type: schema.TypeString,
Computed: true,
Expand Down Expand Up @@ -162,6 +167,9 @@ func dataSourceEIPRead(ctx context.Context, d *schema.ResourceData, meta interfa
d.Set("customer_owned_ipv4_pool", eip.CustomerOwnedIpv4Pool)
d.Set(names.AttrDomain, eip.Domain)
d.Set(names.AttrInstanceID, eip.InstanceId)
if v := aws.ToString(eip.PublicIpv4Pool); strings.HasPrefix(v, publicIPv4PoolIDIPAMPoolPrefix) {
d.Set("ipam_pool_id", v)
}
d.Set(names.AttrNetworkInterfaceID, eip.NetworkInterfaceId)
d.Set("network_interface_owner_id", eip.NetworkInterfaceOwnerId)
d.Set("public_ipv4_pool", eip.PublicIpv4Pool)
Expand Down
3 changes: 2 additions & 1 deletion internal/service/ec2/ec2_eip_data_source_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,11 @@ func TestAccEC2EIPDataSource_publicIP(t *testing.T) {
{
Config: testAccEIPDataSourceConfig_publicIP(rName),
Check: resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttrPair(dataSourceName, names.AttrDomain, resourceName, names.AttrDomain),
resource.TestCheckResourceAttrPair(dataSourceName, names.AttrID, resourceName, names.AttrID),
resource.TestCheckResourceAttrPair(dataSourceName, "ipam_pool_id", resourceName, "ipam_pool_id"),
resource.TestCheckResourceAttrPair(dataSourceName, "public_dns", resourceName, "public_dns"),
resource.TestCheckResourceAttrPair(dataSourceName, "public_ip", resourceName, "public_ip"),
resource.TestCheckResourceAttrPair(dataSourceName, names.AttrDomain, resourceName, names.AttrDomain),
),
},
},
Expand Down
1 change: 1 addition & 0 deletions website/docs/d/eip.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ This data source exports the following attributes in addition to the arguments a
* `domain` - Whether the address is for use in EC2-Classic (standard) or in a VPC (vpc).
* `id` - If VPC Elastic IP, the allocation identifier. If EC2-Classic Elastic IP, the public IP address.
* `instance_id` - ID of the instance that the address is associated with (if any).
* `ipam_pool_id`- The ID of an IPAM pool which has an Amazon-provided or BYOIP public IPv4 CIDR provisioned to it.
* `network_interface_id` - The ID of the network interface.
* `network_interface_owner_id` - The ID of the AWS account that owns the network interface.
* `private_ip` - Private IP address associated with the Elastic IP address.
Expand Down

0 comments on commit 313d512

Please sign in to comment.