diff --git a/aws/data_source_aws_efs_file_system.go b/aws/data_source_aws_efs_file_system.go index 7665c12e954..9f35dab93a7 100644 --- a/aws/data_source_aws_efs_file_system.go +++ b/aws/data_source_aws_efs_file_system.go @@ -5,6 +5,7 @@ import ( "log" "github.com/aws/aws-sdk-go/aws" + "github.com/aws/aws-sdk-go/aws/arn" "github.com/aws/aws-sdk-go/service/efs" "github.com/hashicorp/terraform/helper/schema" "github.com/hashicorp/terraform/helper/validation" @@ -15,6 +16,10 @@ func dataSourceAwsEfsFileSystem() *schema.Resource { Read: dataSourceAwsEfsFileSystemRead, Schema: map[string]*schema.Schema{ + "arn": { + Type: schema.TypeString, + Computed: true, + }, "creation_token": { Type: schema.TypeString, Optional: true, @@ -120,6 +125,16 @@ func dataSourceAwsEfsFileSystemRead(d *schema.ResourceData, meta interface{}) er d.Set("creation_token", fs.CreationToken) d.Set("performance_mode", fs.PerformanceMode) + + fsARN := arn.ARN{ + AccountID: meta.(*AWSClient).accountid, + Partition: meta.(*AWSClient).partition, + Region: meta.(*AWSClient).region, + Resource: fmt.Sprintf("file-system/%s", aws.StringValue(fs.FileSystemId)), + Service: "elasticfilesystem", + }.String() + + d.Set("arn", fsARN) d.Set("file_system_id", fs.FileSystemId) d.Set("encrypted", fs.Encrypted) d.Set("kms_key_id", fs.KmsKeyId) diff --git a/aws/data_source_aws_efs_file_system_test.go b/aws/data_source_aws_efs_file_system_test.go index fc28034bf10..3545ac99ae6 100644 --- a/aws/data_source_aws_efs_file_system_test.go +++ b/aws/data_source_aws_efs_file_system_test.go @@ -17,6 +17,7 @@ func TestAccDataSourceAwsEfsFileSystem(t *testing.T) { { Config: testAccDataSourceAwsEfsFileSystemConfig, Check: resource.ComposeTestCheckFunc( + resource.TestCheckResourceAttrPair("data.aws_efs_file_system.by_id", "arn", "aws_efs_file_system.test", "arn"), testAccDataSourceAwsEfsFileSystemCheck("data.aws_efs_file_system.by_creation_token"), testAccDataSourceAwsEfsFileSystemCheck("data.aws_efs_file_system.by_id"), resource.TestMatchResourceAttr("data.aws_efs_file_system.by_creation_token", "dns_name", regexp.MustCompile("^[^.]+.efs.([a-z]{2}-(gov-)?[a-z]+-\\d{1})?.amazonaws.com$")), diff --git a/aws/data_source_aws_efs_mount_target.go b/aws/data_source_aws_efs_mount_target.go index 21d40f1285b..88e4dcf8828 100644 --- a/aws/data_source_aws_efs_mount_target.go +++ b/aws/data_source_aws_efs_mount_target.go @@ -5,6 +5,7 @@ import ( "log" "github.com/aws/aws-sdk-go/aws" + "github.com/aws/aws-sdk-go/aws/arn" "github.com/aws/aws-sdk-go/service/efs" "github.com/hashicorp/terraform/helper/schema" ) @@ -19,7 +20,10 @@ func dataSourceAwsEfsMountTarget() *schema.Resource { Required: true, ForceNew: true, }, - + "file_system_arn": { + Type: schema.TypeString, + Computed: true, + }, "file_system_id": { Type: schema.TypeString, Computed: true, @@ -71,6 +75,16 @@ func dataSourceAwsEfsMountTargetRead(d *schema.ResourceData, meta interface{}) e log.Printf("[DEBUG] Found EFS mount target: %#v", mt) d.SetId(*mt.MountTargetId) + + fsARN := arn.ARN{ + AccountID: meta.(*AWSClient).accountid, + Partition: meta.(*AWSClient).partition, + Region: meta.(*AWSClient).region, + Resource: fmt.Sprintf("file-system/%s", aws.StringValue(mt.FileSystemId)), + Service: "elasticfilesystem", + }.String() + + d.Set("file_system_arn", fsARN) d.Set("file_system_id", mt.FileSystemId) d.Set("ip_address", mt.IpAddress) d.Set("subnet_id", mt.SubnetId) diff --git a/aws/data_source_aws_efs_mount_target_test.go b/aws/data_source_aws_efs_mount_target_test.go index 9227c381550..109b335fd1f 100644 --- a/aws/data_source_aws_efs_mount_target_test.go +++ b/aws/data_source_aws_efs_mount_target_test.go @@ -17,6 +17,7 @@ func TestAccDataSourceAwsEfsMountTargetByMountTargetId(t *testing.T) { { Config: testAccAwsEfsMountTargetConfigByMountTargetId(rName), Check: resource.ComposeTestCheckFunc( + resource.TestCheckResourceAttrPair("data.aws_efs_mount_target.by_mount_target_id", "file_system_arn", "aws_efs_mount_target.alpha", "file_system_arn"), resource.TestCheckResourceAttrSet("data.aws_efs_mount_target.by_mount_target_id", "file_system_id"), resource.TestCheckResourceAttrSet("data.aws_efs_mount_target.by_mount_target_id", "ip_address"), resource.TestCheckResourceAttrSet("data.aws_efs_mount_target.by_mount_target_id", "subnet_id"), diff --git a/aws/resource_aws_efs_file_system.go b/aws/resource_aws_efs_file_system.go index 2caf27e1c50..4e06fe6e598 100644 --- a/aws/resource_aws_efs_file_system.go +++ b/aws/resource_aws_efs_file_system.go @@ -7,6 +7,7 @@ import ( "time" "github.com/aws/aws-sdk-go/aws" + "github.com/aws/aws-sdk-go/aws/arn" "github.com/aws/aws-sdk-go/aws/awserr" "github.com/aws/aws-sdk-go/service/efs" "github.com/hashicorp/terraform/helper/resource" @@ -26,6 +27,10 @@ func resourceAwsEfsFileSystem() *schema.Resource { }, Schema: map[string]*schema.Schema{ + "arn": { + Type: schema.TypeString, + Computed: true, + }, "creation_token": { Type: schema.TypeString, Optional: true, @@ -279,6 +284,15 @@ func resourceAwsEfsFileSystemRead(d *schema.ResourceData, meta interface{}) erro return nil } + fsARN := arn.ARN{ + AccountID: meta.(*AWSClient).accountid, + Partition: meta.(*AWSClient).partition, + Region: meta.(*AWSClient).region, + Resource: fmt.Sprintf("file-system/%s", aws.StringValue(fs.FileSystemId)), + Service: "elasticfilesystem", + }.String() + + d.Set("arn", fsARN) d.Set("creation_token", fs.CreationToken) d.Set("encrypted", fs.Encrypted) d.Set("kms_key_id", fs.KmsKeyId) diff --git a/aws/resource_aws_efs_file_system_test.go b/aws/resource_aws_efs_file_system_test.go index b693d12feab..24245a7f3f5 100644 --- a/aws/resource_aws_efs_file_system_test.go +++ b/aws/resource_aws_efs_file_system_test.go @@ -87,6 +87,7 @@ func TestAccAWSEFSFileSystem_basic(t *testing.T) { { Config: testAccAWSEFSFileSystemConfig, Check: resource.ComposeTestCheckFunc( + testAccMatchResourceAttrRegionalARN("aws_efs_file_system.foo", "arn", "elasticfilesystem", regexp.MustCompile(`file-system/fs-.+`)), resource.TestCheckResourceAttr( "aws_efs_file_system.foo", "performance_mode", diff --git a/aws/resource_aws_efs_mount_target.go b/aws/resource_aws_efs_mount_target.go index fe1d87bf18d..ee1d8e0cb7f 100644 --- a/aws/resource_aws_efs_mount_target.go +++ b/aws/resource_aws_efs_mount_target.go @@ -6,6 +6,7 @@ import ( "time" "github.com/aws/aws-sdk-go/aws" + "github.com/aws/aws-sdk-go/aws/arn" "github.com/aws/aws-sdk-go/aws/awserr" "github.com/aws/aws-sdk-go/service/ec2" "github.com/aws/aws-sdk-go/service/efs" @@ -25,6 +26,10 @@ func resourceAwsEfsMountTarget() *schema.Resource { }, Schema: map[string]*schema.Schema{ + "file_system_arn": { + Type: schema.TypeString, + Computed: true, + }, "file_system_id": { Type: schema.TypeString, Required: true, @@ -182,6 +187,16 @@ func resourceAwsEfsMountTargetRead(d *schema.ResourceData, meta interface{}) err log.Printf("[DEBUG] Found EFS mount target: %#v", mt) d.SetId(*mt.MountTargetId) + + fsARN := arn.ARN{ + AccountID: meta.(*AWSClient).accountid, + Partition: meta.(*AWSClient).partition, + Region: meta.(*AWSClient).region, + Resource: fmt.Sprintf("file-system/%s", aws.StringValue(mt.FileSystemId)), + Service: "elasticfilesystem", + }.String() + + d.Set("file_system_arn", fsARN) d.Set("file_system_id", mt.FileSystemId) d.Set("ip_address", mt.IpAddress) d.Set("subnet_id", mt.SubnetId) diff --git a/aws/resource_aws_efs_mount_target_test.go b/aws/resource_aws_efs_mount_target_test.go index 9b2a4d55375..fd1c79c84d2 100644 --- a/aws/resource_aws_efs_mount_target_test.go +++ b/aws/resource_aws_efs_mount_target_test.go @@ -49,6 +49,7 @@ func TestAccAWSEFSMountTarget_basic(t *testing.T) { { Config: testAccAWSEFSMountTargetConfig(ct), Check: resource.ComposeTestCheckFunc( + testAccMatchResourceAttrRegionalARN("aws_efs_mount_target.alpha", "file_system_arn", "elasticfilesystem", regexp.MustCompile(`file-system/fs-.+`)), testAccCheckEfsMountTarget( "aws_efs_mount_target.alpha", &mount, diff --git a/website/docs/d/efs_file_system.html.markdown b/website/docs/d/efs_file_system.html.markdown index 80c5510ad24..07dca5d6606 100644 --- a/website/docs/d/efs_file_system.html.markdown +++ b/website/docs/d/efs_file_system.html.markdown @@ -34,6 +34,7 @@ The following arguments are supported: In addition to all arguments above, the following attributes are exported: +* `arn` - Amazon Resource Name of the file system. * `performance_mode` - The PerformanceMode of the file system. * `tags` - The list of tags assigned to the file system. * `encrypted` - Whether EFS is encrypted. diff --git a/website/docs/d/efs_mount_target.html.markdown b/website/docs/d/efs_mount_target.html.markdown index 9dceb195527..5def4af6cab 100644 --- a/website/docs/d/efs_mount_target.html.markdown +++ b/website/docs/d/efs_mount_target.html.markdown @@ -33,6 +33,7 @@ The following arguments are supported: In addition to all arguments above, the following attributes are exported: +* `file_system_arn` - Amazon Resource Name of the file system for which the mount target is intended. * `file_system_id` - ID of the file system for which the mount target is intended. * `subnet_id` - ID of the mount target's subnet. * `ip_address` - Address at which the file system may be mounted via the mount target. diff --git a/website/docs/index.html.markdown b/website/docs/index.html.markdown index 438d805358d..fd4528b2775 100644 --- a/website/docs/index.html.markdown +++ b/website/docs/index.html.markdown @@ -231,6 +231,10 @@ In addition to [generic `provider` arguments](https://www.terraform.io/docs/conf - [`aws_ebs_volume` data source](/docs/providers/aws/d/ebs_volume.html) - [`aws_ecs_cluster` resource (import)](/docs/providers/aws/r/ecs_cluster.html) - [`aws_ecs_service` resource (import)](/docs/providers/aws/r/ecs_service.html) + - [`aws_efs_file_system` data source](/docs/providers/aws/d/efs_file_system.html) + - [`aws_efs_file_system` resource](/docs/providers/aws/r/efs_file_system.html) + - [`aws_efs_mount_target` data source](/docs/providers/aws/d/efs_mount_target.html) + - [`aws_efs_mount_target` resource](/docs/providers/aws/r/efs_mount_target.html) - [`aws_elasticache_cluster` data source](/docs/providers/aws/d/elasticache_cluster.html) - [`aws_elasticache_cluster` resource](/docs/providers/aws/r/elasticache_cluster.html) - [`aws_elb` resource](/docs/providers/aws/r/elb.html) diff --git a/website/docs/r/efs_file_system.html.markdown b/website/docs/r/efs_file_system.html.markdown index 99c2dd79d04..de119bdcff9 100644 --- a/website/docs/r/efs_file_system.html.markdown +++ b/website/docs/r/efs_file_system.html.markdown @@ -47,6 +47,7 @@ default generated by Terraform. In addition to all arguments above, the following attributes are exported: +* `arn` - Amazon Resource Name of the file system. * `id` - The ID that identifies the file system (e.g. fs-ccfc0d65). * `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). diff --git a/website/docs/r/efs_mount_target.html.markdown b/website/docs/r/efs_mount_target.html.markdown index ae7a17c0f0a..6f32914311f 100644 --- a/website/docs/r/efs_mount_target.html.markdown +++ b/website/docs/r/efs_mount_target.html.markdown @@ -50,6 +50,7 @@ In addition to all arguments above, the following attributes are exported: * `id` - The ID of the mount target. * `dns_name` - The DNS name for the given subnet/AZ per [documented convention](http://docs.aws.amazon.com/efs/latest/ug/mounting-fs-mount-cmd-dns-name.html). +* `file_system_arn` - Amazon Resource Name of the file system. * `network_interface_id` - The ID of the network interface that Amazon EFS created when it created the mount target. ## Import