Skip to content

Commit

Permalink
resource/aws_efs_file_system and resource/aws_efs_mount_target: Suppo…
Browse files Browse the repository at this point in the history
…rt for cn-north-1 and cn-northwest-1 (#11746)

Output from acceptance testing:

```
--- PASS: TestAccAWSEFSFileSystem_basic (129.11s)
--- PASS: TestAccAWSEFSFileSystem_disappears (47.50s)
--- PASS: TestAccAWSEFSFileSystem_kmsConfigurationWithoutEncryption (27.34s)
--- PASS: TestAccAWSEFSFileSystem_kmsKey (77.16s)
--- PASS: TestAccAWSEFSFileSystem_lifecyclePolicy (82.54s)
--- PASS: TestAccAWSEFSFileSystem_lifecyclePolicy_removal (57.93s)
--- PASS: TestAccAWSEFSFileSystem_lifecyclePolicy_update (134.72s)
--- PASS: TestAccAWSEFSFileSystem_pagedTags (103.28s)
--- PASS: TestAccAWSEFSFileSystem_ProvisionedThroughputInMibps (93.37s)
--- PASS: TestAccAWSEFSFileSystem_tags (79.55s)
--- PASS: TestAccAWSEFSFileSystem_ThroughputMode (149.82s)

--- PASS: TestAccAWSEFSMountTarget_basic (243.16s)
--- PASS: TestAccAWSEFSMountTarget_disappears (173.77s)

--- PASS: TestAccDataSourceAwsEfsFileSystem_id (203.85s)
--- PASS: TestAccDataSourceAwsEfsFileSystem_name (226.40s)

--- PASS: TestAccDataSourceAwsEfsMountTargetByMountTargetId (221.82s)
```
  • Loading branch information
fl0ge authored and bflad committed Jan 24, 2020
1 parent 983b2d5 commit 605737e
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 10 deletions.
3 changes: 2 additions & 1 deletion aws/data_source_aws_efs_file_system.go
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ func dataSourceAwsEfsFileSystemRead(d *schema.ResourceData, meta interface{}) er
}

region := meta.(*AWSClient).region
err = d.Set("dns_name", resourceAwsEfsDnsName(*fs.FileSystemId, region))
dnsSuffix := meta.(*AWSClient).dnsSuffix
err = d.Set("dns_name", resourceAwsEfsDnsName(*fs.FileSystemId, region, dnsSuffix))
return err
}
2 changes: 1 addition & 1 deletion aws/data_source_aws_efs_mount_target.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ func dataSourceAwsEfsMountTargetRead(d *schema.ResourceData, meta interface{}) e
return err
}

if err := d.Set("dns_name", resourceAwsEfsMountTargetDnsName(*mt.FileSystemId, meta.(*AWSClient).region)); err != nil {
if err := d.Set("dns_name", resourceAwsEfsMountTargetDnsName(*mt.FileSystemId, meta.(*AWSClient).region, meta.(*AWSClient).dnsSuffix)); err != nil {
return fmt.Errorf("Error setting dns_name error: %#v", err)
}

Expand Down
7 changes: 4 additions & 3 deletions aws/resource_aws_efs_file_system.go
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,8 @@ func resourceAwsEfsFileSystemRead(d *schema.ResourceData, meta interface{}) erro
}

region := meta.(*AWSClient).region
if err := d.Set("dns_name", resourceAwsEfsDnsName(aws.StringValue(fs.FileSystemId), region)); err != nil {
dnsSuffix := meta.(*AWSClient).dnsSuffix
if err := d.Set("dns_name", resourceAwsEfsDnsName(aws.StringValue(fs.FileSystemId), region, dnsSuffix)); err != nil {
return fmt.Errorf("error setting dns_name: %s", err)
}

Expand Down Expand Up @@ -385,8 +386,8 @@ func hasEmptyFileSystems(fs *efs.DescribeFileSystemsOutput) bool {
return true
}

func resourceAwsEfsDnsName(fileSystemId, region string) string {
return fmt.Sprintf("%s.efs.%s.amazonaws.com", fileSystemId, region)
func resourceAwsEfsDnsName(fileSystemId, region string, dnsSuffix string) string {
return fmt.Sprintf("%s.efs.%s.%s", fileSystemId, region, dnsSuffix)
}

func resourceEfsFileSystemCreateUpdateRefreshFunc(id string, conn *efs.EFS) resource.StateRefreshFunc {
Expand Down
7 changes: 4 additions & 3 deletions aws/resource_aws_efs_mount_target.go
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,8 @@ func resourceAwsEfsMountTargetRead(d *schema.ResourceData, meta interface{}) err
}

region := meta.(*AWSClient).region
if err := d.Set("dns_name", resourceAwsEfsMountTargetDnsName(aws.StringValue(mt.FileSystemId), region)); err != nil {
dnsSuffix := meta.(*AWSClient).dnsSuffix
if err := d.Set("dns_name", resourceAwsEfsMountTargetDnsName(aws.StringValue(mt.FileSystemId), region, dnsSuffix)); err != nil {
return fmt.Errorf("error setting dns_name: %s", err)
}

Expand Down Expand Up @@ -303,8 +304,8 @@ func waitForDeleteEfsMountTarget(conn *efs.EFS, id string, timeout time.Duration
return err
}

func resourceAwsEfsMountTargetDnsName(fileSystemId, region string) string {
return fmt.Sprintf("%s.efs.%s.amazonaws.com", fileSystemId, region)
func resourceAwsEfsMountTargetDnsName(fileSystemId, region string, dnsSuffix string) string {
return fmt.Sprintf("%s.efs.%s.%s", fileSystemId, region, dnsSuffix)
}

func hasEmptyMountTargets(mto *efs.DescribeMountTargetsOutput) bool {
Expand Down
4 changes: 2 additions & 2 deletions aws/resource_aws_efs_mount_target_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -171,9 +171,9 @@ func TestAccAWSEFSMountTarget_disappears(t *testing.T) {
}

func TestResourceAWSEFSMountTarget_mountTargetDnsName(t *testing.T) {
actual := resourceAwsEfsMountTargetDnsName("fs-123456ab", "non-existent-1")
actual := resourceAwsEfsMountTargetDnsName("fs-123456ab", "us-west-2", "amazonaws.com")

expected := "fs-123456ab.efs.non-existent-1.amazonaws.com"
expected := "fs-123456ab.efs.us-west-2.amazonaws.com"
if actual != expected {
t.Fatalf("Expected EFS mount target DNS name to be %s, got %s",
expected, actual)
Expand Down

0 comments on commit 605737e

Please sign in to comment.