Skip to content

Commit

Permalink
Merge pull request #1825 from alewando/efs_filesystem_dns_name
Browse files Browse the repository at this point in the history
Add 'dns_name' attribute to aws_efs_file_system resource
  • Loading branch information
radeksimko authored Oct 9, 2017
2 parents d9e6b0c + ad3fc4f commit 227d68f
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 0 deletions.
15 changes: 15 additions & 0 deletions aws/resource_aws_efs_file_system.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,11 @@ func resourceAwsEfsFileSystem() *schema.Resource {
ValidateFunc: validateArn,
},

"dns_name": {
Type: schema.TypeString,
Computed: true,
},

"tags": tagsSchema(),
},
}
Expand Down Expand Up @@ -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
}

Expand Down Expand Up @@ -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)
}
5 changes: 5 additions & 0 deletions aws/resource_aws_efs_file_system_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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$"),
),
),
},
{
Expand Down
1 change: 1 addition & 0 deletions website/docs/d/efs_file_system.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -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).

0 comments on commit 227d68f

Please sign in to comment.