Skip to content

Commit

Permalink
Merge pull request #1599 from adbglobal/master
Browse files Browse the repository at this point in the history
Added private_dns_name to network_interface
  • Loading branch information
Ninir authored Sep 7, 2017
2 parents 02934d9 + b4c39a2 commit 490897d
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 6 deletions.
6 changes: 6 additions & 0 deletions aws/resource_aws_network_interface.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,11 @@ func resourceAwsNetworkInterface() *schema.Resource {
Computed: true,
},

"private_dns_name": &schema.Schema{
Type: schema.TypeString,
Computed: true,
},

"private_ips": &schema.Schema{
Type: schema.TypeSet,
Optional: true,
Expand Down Expand Up @@ -162,6 +167,7 @@ func resourceAwsNetworkInterfaceRead(d *schema.ResourceData, meta interface{}) e
eni := describeResp.NetworkInterfaces[0]
d.Set("subnet_id", eni.SubnetId)
d.Set("private_ip", eni.PrivateIpAddress)
d.Set("private_dns_name", eni.PrivateDnsName)
d.Set("private_ips", flattenNetworkInterfacesPrivateIPAddresses(eni.PrivateIpAddresses))
d.Set("security_groups", flattenGroupIdentifiers(eni.Groups))
d.Set("source_dest_check", eni.SourceDestCheck)
Expand Down
28 changes: 22 additions & 6 deletions aws/resource_aws_network_interface_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ func TestAccAWSENI_basic(t *testing.T) {
testAccCheckAWSENIAttributes(&conf),
resource.TestCheckResourceAttr(
"aws_network_interface.bar", "private_ips.#", "1"),
resource.TestCheckResourceAttrSet(
"aws_network_interface.bar", "private_dns_name"),
resource.TestCheckResourceAttr(
"aws_network_interface.bar", "tags.Name", "bar_interface"),
resource.TestCheckResourceAttr(
Expand Down Expand Up @@ -205,6 +207,10 @@ func testAccCheckAWSENIAttributes(conf *ec2.NetworkInterface) resource.TestCheck
return fmt.Errorf("expected private ip to be 172.16.10.100, but was %s", *conf.PrivateIpAddress)
}

if *conf.PrivateDnsName != "ip-172-16-10-100.us-west-2.compute.internal" {
return fmt.Errorf("expected private dns name to be ip-172-16-10-100.us-west-2.compute.internal, but was %s", *conf.PrivateDnsName)
}

if *conf.SourceDestCheck != true {
return fmt.Errorf("expected source_dest_check to be true, but was %t", *conf.SourceDestCheck)
}
Expand Down Expand Up @@ -240,6 +246,10 @@ func testAccCheckAWSENIAttributesWithAttachment(conf *ec2.NetworkInterface) reso
return fmt.Errorf("expected private ip to be 172.16.10.100, but was %s", *conf.PrivateIpAddress)
}

if *conf.PrivateDnsName != "ip-172-16-10-100.us-west-2.compute.internal" {
return fmt.Errorf("expected private dns name to be ip-172-16-10-100.us-west-2.compute.internal, but was %s", *conf.PrivateDnsName)
}

return nil
}
}
Expand Down Expand Up @@ -290,7 +300,8 @@ func testAccCheckAWSENIMakeExternalAttachment(n string, conf *ec2.NetworkInterfa

const testAccAWSENIConfig = `
resource "aws_vpc" "foo" {
cidr_block = "172.16.0.0/16"
cidr_block = "172.16.0.0/16"
enable_dns_hostnames = true
tags {
Name = "testAccAWSENIConfig"
}
Expand Down Expand Up @@ -328,7 +339,8 @@ resource "aws_network_interface" "bar" {

const testAccAWSENIConfigUpdatedDescription = `
resource "aws_vpc" "foo" {
cidr_block = "172.16.0.0/16"
cidr_block = "172.16.0.0/16"
enable_dns_hostnames = true
tags {
Name = "testAccAWSENIConfigUpdatedDescription"
}
Expand Down Expand Up @@ -366,7 +378,8 @@ resource "aws_network_interface" "bar" {

const testAccAWSENIConfigWithSourceDestCheck = `
resource "aws_vpc" "foo" {
cidr_block = "172.16.0.0/16"
cidr_block = "172.16.0.0/16"
enable_dns_hostnames = true
tags {
Name = "testAccAWSENIConfigWithSourceDestCheck"
}
Expand All @@ -387,7 +400,8 @@ resource "aws_network_interface" "bar" {

const testAccAWSENIConfigWithNoPrivateIPs = `
resource "aws_vpc" "foo" {
cidr_block = "172.16.0.0/16"
cidr_block = "172.16.0.0/16"
enable_dns_hostnames = true
tags {
Name = "testAccAWSENIConfigWithNoPrivateIPs"
}
Expand All @@ -407,7 +421,8 @@ resource "aws_network_interface" "bar" {

const testAccAWSENIConfigWithAttachment = `
resource "aws_vpc" "foo" {
cidr_block = "172.16.0.0/16"
cidr_block = "172.16.0.0/16"
enable_dns_hostnames = true
tags {
Name = "tf-eni-test"
}
Expand Down Expand Up @@ -464,7 +479,8 @@ resource "aws_network_interface" "bar" {

const testAccAWSENIConfigExternalAttachment = `
resource "aws_vpc" "foo" {
cidr_block = "172.16.0.0/16"
cidr_block = "172.16.0.0/16"
enable_dns_hostnames = true
tags {
Name = "tf-eni-test"
}
Expand Down

0 comments on commit 490897d

Please sign in to comment.