Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

r/aws_eip - support NetworkBorderGroup attribute #14028

Merged
merged 6 commits into from
Nov 5, 2020
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions aws/resource_aws_eip.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,12 @@ func resourceAwsEip() *schema.Resource {
Computed: true,
},

"network_border_group": {
drexler marked this conversation as resolved.
Show resolved Hide resolved
Type: schema.TypeString,
Optional: true,
Computed: true,
},

"tags": tagsSchema(),
},
}
Expand All @@ -134,6 +140,10 @@ func resourceAwsEipCreate(d *schema.ResourceData, meta interface{}) error {
allocOpts.CustomerOwnedIpv4Pool = aws.String(v.(string))
}

if v, ok := d.GetOk("network_border_group"); ok {
allocOpts.NetworkBorderGroup = aws.String(v.(string))
}

log.Printf("[DEBUG] EIP create configuration: %#v", allocOpts)
allocResp, err := ec2conn.AllocateAddress(allocOpts)
if err != nil {
Expand Down Expand Up @@ -274,6 +284,7 @@ func resourceAwsEipRead(d *schema.ResourceData, meta interface{}) error {
d.Set("public_ipv4_pool", address.PublicIpv4Pool)
d.Set("customer_owned_ipv4_pool", address.CustomerOwnedIpv4Pool)
d.Set("customer_owned_ip", address.CustomerOwnedIp)
d.Set("network_border_group", address.NetworkBorderGroup)

// On import (domain never set, which it must've been if we created),
// set the 'vpc' attribute depending on if we're in a VPC.
Expand Down
37 changes: 37 additions & 0 deletions aws/resource_aws_eip_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -425,6 +425,34 @@ func TestAccAWSEIP_PublicIpv4Pool_default(t *testing.T) {
})
}

func TestAccAWSEIP_NetworkBorderGroup(t *testing.T) {
var conf ec2.Address
resourceName := "aws_eip.test"

resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
IDRefreshName: resourceName,
Providers: testAccProviders,
CheckDestroy: testAccCheckAWSEIPDestroy,
Steps: []resource.TestStep{
{
Config: testAccAWSEIPConfigNetworkBorderGroup,
Check: resource.ComposeTestCheckFunc(
testAccCheckAWSEIPExists(resourceName, &conf),
testAccCheckAWSEIPAttributes(&conf),
resource.TestCheckResourceAttr(resourceName, "public_ipv4_pool", "amazon"),
resource.TestCheckResourceAttr(resourceName, "network_border_group", "us-west-2"),
drexler marked this conversation as resolved.
Show resolved Hide resolved
),
},
{
ResourceName: resourceName,
ImportState: true,
ImportStateVerify: true,
},
},
})
}

func TestAccAWSEIP_PublicIpv4Pool_custom(t *testing.T) {
if os.Getenv("AWS_EC2_EIP_PUBLIC_IPV4_POOL") == "" {
t.Skip("Environment variable AWS_EC2_EIP_PUBLIC_IPV4_POOL is not set")
Expand Down Expand Up @@ -1171,3 +1199,12 @@ resource "aws_eip" "test" {
}
`
}

const testAccAWSEIPConfigNetworkBorderGroup = `
data "aws_region" current {}

resource "aws_eip" "test" {
vpc = "true"
network_border_group = data.aws_region.current.name
bflad marked this conversation as resolved.
Show resolved Hide resolved
}
`
1 change: 1 addition & 0 deletions website/docs/r/eip.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ The following arguments are supported:
* `tags` - (Optional) A map of tags to assign to the resource.
* `public_ipv4_pool` - (Optional) EC2 IPv4 address pool identifier or `amazon`. This option is only available for VPC EIPs.
* `customer_owned_ipv4_pool` - The ID of a customer-owned address pool. For more on customer owned IP addressed check out [Customer-owned IP addresses guide](https://docs.aws.amazon.com/outposts/latest/userguide/outposts-networking-components.html#ip-addressing)
* `network_border_group` - The location from which the IP address is advertised. Use this parameter to limit the address to this location.

~> **NOTE:** You can specify either the `instance` ID or the `network_interface` ID,
but not both. Including both will **not** return an error from the AWS API, but will
Expand Down