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

service/efs: Add File System ARN attributes #6371

Merged
merged 1 commit into from
Nov 6, 2018
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/data_source_aws_efs_file_system.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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,
Expand Down Expand Up @@ -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)
Expand Down
1 change: 1 addition & 0 deletions aws/data_source_aws_efs_file_system_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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$")),
Expand Down
16 changes: 15 additions & 1 deletion aws/data_source_aws_efs_mount_target.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
Expand All @@ -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,
Expand Down Expand Up @@ -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)
Expand Down
1 change: 1 addition & 0 deletions aws/data_source_aws_efs_mount_target_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
Expand Down
14 changes: 14 additions & 0 deletions aws/resource_aws_efs_file_system.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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,
Expand Down Expand Up @@ -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)
Expand Down
1 change: 1 addition & 0 deletions aws/resource_aws_efs_file_system_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
15 changes: 15 additions & 0 deletions aws/resource_aws_efs_mount_target.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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,
Expand Down Expand Up @@ -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)
Expand Down
1 change: 1 addition & 0 deletions aws/resource_aws_efs_mount_target_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
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 @@ -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.
Expand Down
1 change: 1 addition & 0 deletions website/docs/d/efs_mount_target.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
4 changes: 4 additions & 0 deletions website/docs/index.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
1 change: 1 addition & 0 deletions website/docs/r/efs_file_system.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -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).

Expand Down
1 change: 1 addition & 0 deletions website/docs/r/efs_mount_target.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down