diff --git a/aws/resource_aws_efs_file_system.go b/aws/resource_aws_efs_file_system.go index a0f5a59b6fda..9edb3c1540c5 100644 --- a/aws/resource_aws_efs_file_system.go +++ b/aws/resource_aws_efs_file_system.go @@ -64,6 +64,11 @@ func resourceAwsEfsFileSystem() *schema.Resource { ValidateFunc: validateArn, }, + "dns_name": { + Type: schema.TypeString, + Computed: true, + }, + "tags": tagsSchema(), }, } @@ -230,6 +235,12 @@ func resourceAwsEfsFileSystemRead(d *schema.ResourceData, meta interface{}) erro d.Set("encrypted", fs.Encrypted) d.Set("kms_key_id", fs.KmsKeyId) + region := meta.(*AWSClient).region + err = d.Set("dns_name", resourceAwsEfsDnsName(*fs.FileSystemId, region)) + if err != nil { + return err + } + return nil } @@ -305,3 +316,7 @@ func hasEmptyFileSystems(fs *efs.DescribeFileSystemsOutput) bool { } return true } + +func resourceAwsEfsDnsName(fileSystemId, region string) string { + return fmt.Sprintf("%s.efs.%s.amazonaws.com", fileSystemId, region) +} diff --git a/aws/resource_aws_efs_file_system_test.go b/aws/resource_aws_efs_file_system_test.go index c003fd79257b..17254dc1a62b 100644 --- a/aws/resource_aws_efs_file_system_test.go +++ b/aws/resource_aws_efs_file_system_test.go @@ -103,6 +103,11 @@ func TestAccAWSEFSFileSystem_basic(t *testing.T) { "aws_efs_file_system.foo", "generalPurpose", ), + resource.TestMatchResourceAttr( + "aws_efs_file_system.foo", + "dns_name", + regexp.MustCompile("^[^.]+.efs.us-west-2.amazonaws.com$"), + ), ), }, { diff --git a/website/docs/d/efs_file_system.html.markdown b/website/docs/d/efs_file_system.html.markdown index 1a3fc70542ac..240634e7d185 100644 --- a/website/docs/d/efs_file_system.html.markdown +++ b/website/docs/d/efs_file_system.html.markdown @@ -38,3 +38,4 @@ The following attributes are exported: * `tags` - The list of tags assigned to the file system. * `encrypted` - Whether EFS is encrypted. * `kms_key_id` - The ARN for the KMS encryption key. +* `dns_name` - The DNS name for the filesystem per [documented convention](http://docs.aws.amazon.com/efs/latest/ug/mounting-fs-mount-cmd-dns-name.html).