Skip to content

Commit

Permalink
Add EFS mount target DNS helper function.
Browse files Browse the repository at this point in the history
Signed-off-by: Krzysztof Wilczynski <[email protected]>
  • Loading branch information
kwilczynski committed Aug 29, 2016
1 parent 5569046 commit 09c37b0
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
6 changes: 5 additions & 1 deletion builtin/providers/aws/resource_aws_efs_mount_target.go
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ func resourceAwsEfsMountTargetRead(d *schema.ResourceData, meta interface{}) err
}

region := meta.(*AWSClient).region
err = d.Set("dns_name", fmt.Sprintf("%s.%s.efs.%s.amazonaws.com", az, *mt.FileSystemId, region))
err = d.Set("dns_name", resourceAwsEfsMountTargetDnsName(az, *mt.FileSystemId, region))
if err != nil {
return err
}
Expand Down Expand Up @@ -284,3 +284,7 @@ func resourceAwsEfsMountTargetDelete(d *schema.ResourceData, meta interface{}) e

return nil
}

func resourceAwsEfsMountTargetDnsName(az, fileSystemId, region string) string {
return fmt.Sprintf("%s.%s.efs.%s.amazonaws.com", az, fileSystemId, region)
}
11 changes: 11 additions & 0 deletions builtin/providers/aws/resource_aws_efs_mount_target_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,17 @@ func TestAccAWSEFSMountTarget_basic(t *testing.T) {
})
}

func TestResourceAWSEFSMountTarget_dnsName(t *testing.T) {
actual := resourceAwsEfsMountTargetDnsName("non-existant-1c",
"fs-123456ab", "non-existant-1")

expected := "non-existant-1c.fs-123456ab.efs.non-existant-1.amazonaws.com"
if actual != expected {
t.Fatalf("Expected EFS mount target DNS name to be %s, got %s",
expected, actual)
}
}

func testAccCheckEfsMountTargetDestroy(s *terraform.State) error {
conn := testAccProvider.Meta().(*AWSClient).efsconn
for _, rs := range s.RootModule().Resources {
Expand Down

0 comments on commit 09c37b0

Please sign in to comment.