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

Added private_dns_name to network_interface #1599

Merged
merged 1 commit into from
Sep 7, 2017
Merged
Show file tree
Hide file tree
Changes from all 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
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