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 a7e5953
Show file tree
Hide file tree
Showing 2 changed files with 20 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)
}
15 changes: 15 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,21 @@ func TestAccAWSEFSMountTarget_basic(t *testing.T) {
})
}

func TestResourceAWSEFSMountTarget_dnsName(t *testing.T) {
// Seed values.
az := "non-existant-1c"
region := "non-existant-1"
id := "fs-123456ab"

expected := fmt.Sprintf("%s.%s.efs.%s.amazonaws.com", az, id, region)
actual := resourceAwsEfsMountTargetDnsName(az, id, region)

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 a7e5953

Please sign in to comment.