provider/aws: Add documentation for the EFS File System DataSource

This commit is contained in:
stack72 2017-04-29 11:38:10 +12:00
parent 6f4f13e462
commit be002d9345
No known key found for this signature in database
GPG Key ID: 8619A619B085CB16
4 changed files with 56 additions and 16 deletions

View File

@ -19,34 +19,35 @@ func dataSourceAwsEfsFileSystem() *schema.Resource {
Type: schema.TypeString,
Optional: true,
Computed: true,
ForceNew: true,
ValidateFunc: validateMaxLength(64),
},
"id": {
"file_system_id": {
Type: schema.TypeString,
Optional: true,
Computed: true,
ForceNew: true,
},
"performance_mode": {
Type: schema.TypeString,
Optional: true,
Computed: true,
},
"tags": tagsSchema(),
"tags": tagsSchemaComputed(),
},
}
}
func dataSourceAwsEfsFileSystemRead(d *schema.ResourceData, meta interface{}) error {
efsconn := meta.(*AWSClient).efsconn
efsCreationToken := d.Get("creation_token").(string)
efsFileSystemId := d.Get("id").(string)
describeEfsOpts := &efs.DescribeFileSystemsInput{}
switch {
case efsCreationToken != "":
describeEfsOpts.CreationToken = aws.String(efsCreationToken)
case efsFileSystemId != "":
describeEfsOpts.FileSystemId = aws.String(efsFileSystemId)
if v, ok := d.GetOk("creation_token"); ok {
describeEfsOpts.CreationToken = aws.String(v.(string))
}
if v, ok := d.GetOk("file_system_id"); ok {
describeEfsOpts.FileSystemId = aws.String(v.(string))
}
describeResp, err := efsconn.DescribeFileSystems(describeEfsOpts)
@ -106,6 +107,7 @@ func dataSourceAwsEfsFileSystemRead(d *schema.ResourceData, meta interface{}) er
d.Set("creation_token", fs.CreationToken)
d.Set("performance_mode", fs.PerformanceMode)
d.Set("file_system_id", fs.FileSystemId)
return nil
}

View File

@ -13,7 +13,7 @@ func TestAccDataSourceAwsEfsFileSystem(t *testing.T) {
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
Steps: []resource.TestStep{
resource.TestStep{
{
Config: testAccDataSourceAwsEfsFileSystemConfig,
Check: resource.ComposeTestCheckFunc(
testAccDataSourceAwsEfsFileSystemCheck("data.aws_efs_file_system.by_creation_token"),
@ -59,10 +59,6 @@ func testAccDataSourceAwsEfsFileSystemCheck(name string) resource.TestCheckFunc
}
const testAccDataSourceAwsEfsFileSystemConfig = `
provider "aws" {
region = "us-west-2"
}
resource "aws_efs_file_system" "test" {}
data "aws_efs_file_system" "by_creation_token" {
@ -70,6 +66,6 @@ data "aws_efs_file_system" "by_creation_token" {
}
data "aws_efs_file_system" "by_id" {
id = "${aws_efs_file_system.test.id}"
file_system_id = "${aws_efs_file_system.test.id}"
}
`

View File

@ -0,0 +1,39 @@
---
layout: "aws"
page_title: "AWS: efs_file_system"
sidebar_current: "docs-aws-datasource-efs-file-system"
description: |-
Provides an Elastic File System (EFS) data source.
---
# aws_efs_file_system
Provides information about an Elastic File System (EFS).
## Example Usage
```hcl
variable "file_system_id" {
type = "string"
default = ""
}
data "aws_efs_file_system" "by_id" {
file_system_id = "${var.file_system_id}"
}
```
## Argument Reference
The following arguments are supported:
* `file_system_id` - (Optional) The ID that identifies the file system (e.g. fs-ccfc0d65).
* `creation_token` - (Optional) Restricts the list to the file system with this creation token
## Attributes Reference
The following attributes are exported:
* `performance_mode` - The PerformanceMode of the file system.
* `tags` - The list of tags assigned to the file system.

View File

@ -62,6 +62,9 @@
<li<%= sidebar_current("docs-aws-datasource-ecs-task-definition") %>>
<a href="/docs/providers/aws/d/ecs_task_definition.html">aws_ecs_task_definition</a>
</li>
<li<%= sidebar_current("docs-aws-datasource-efs-file-system") %>>
<a href="/docs/providers/aws/d/efs_file_system.html">aws_efs_file_system</a>
</li>
<li<%= sidebar_current("docs-aws-datasource-elb-hosted-zone-id") %>>
<a href="/docs/providers/aws/d/elb_hosted_zone_id.html">aws_elb_hosted_zone_id</a>
</li>