Compute private ip addresses of ENIs if they are not specified
As AWS will assign the ENI an address
This commit is contained in:
parent
b6b3626f90
commit
affa09efdd
|
@ -34,6 +34,7 @@ func resourceAwsNetworkInterface() *schema.Resource {
|
|||
Type: schema.TypeSet,
|
||||
Optional: true,
|
||||
ForceNew: true,
|
||||
Computed: true,
|
||||
Elem: &schema.Schema{Type: schema.TypeString},
|
||||
Set: schema.HashString,
|
||||
},
|
||||
|
|
|
@ -77,6 +77,26 @@ func TestAccAWSENI_sourceDestCheck(t *testing.T) {
|
|||
})
|
||||
}
|
||||
|
||||
func TestAccAWSENI_computedIPs(t *testing.T) {
|
||||
var conf ec2.NetworkInterface
|
||||
|
||||
resource.Test(t, resource.TestCase{
|
||||
PreCheck: func() { testAccPreCheck(t) },
|
||||
Providers: testAccProviders,
|
||||
CheckDestroy: testAccCheckAWSENIDestroy,
|
||||
Steps: []resource.TestStep{
|
||||
resource.TestStep{
|
||||
Config: testAccAWSENIConfigWithNoPrivateIPs,
|
||||
Check: resource.ComposeTestCheckFunc(
|
||||
testAccCheckAWSENIExists("aws_network_interface.bar", &conf),
|
||||
resource.TestCheckResourceAttr(
|
||||
"aws_network_interface.bar", "private_ips.#", "1"),
|
||||
),
|
||||
},
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
func testAccCheckAWSENIExists(n string, res *ec2.NetworkInterface) resource.TestCheckFunc {
|
||||
return func(s *terraform.State) error {
|
||||
rs, ok := s.RootModule().Resources[n]
|
||||
|
@ -243,6 +263,23 @@ resource "aws_network_interface" "bar" {
|
|||
}
|
||||
`
|
||||
|
||||
const testAccAWSENIConfigWithNoPrivateIPs = `
|
||||
resource "aws_vpc" "foo" {
|
||||
cidr_block = "172.16.0.0/16"
|
||||
}
|
||||
|
||||
resource "aws_subnet" "foo" {
|
||||
vpc_id = "${aws_vpc.foo.id}"
|
||||
cidr_block = "172.16.10.0/24"
|
||||
availability_zone = "us-west-2a"
|
||||
}
|
||||
|
||||
resource "aws_network_interface" "bar" {
|
||||
subnet_id = "${aws_subnet.foo.id}"
|
||||
source_dest_check = false
|
||||
}
|
||||
`
|
||||
|
||||
const testAccAWSENIConfigWithAttachment = `
|
||||
resource "aws_vpc" "foo" {
|
||||
cidr_block = "172.16.0.0/16"
|
||||
|
|
Loading…
Reference in New Issue