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

Add 'dns_name' attribute to aws_efs_file_system resource #1825

Merged
merged 1 commit into from
Oct 9, 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
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).