forked from hashicorp/terraform-provider-aws
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/master' into issue-1146
* origin/master: (59 commits) Update CHANGELOG for hashicorp#13935 resource/aws_batch_compute_environment: Remove resource from Terraform state when not found instead of returning error (hashicorp#13935) resource/aws_dynamodb_table: Return error instead of panic on empty CreateTable response (hashicorp#13925) Update CHANGELOG for hashicorp#13918 New Data Source: aws_efs_access_points (hashicorp#13918) tests/resource/aws_instance: Ensure sweeper has dependencies on resources that manage EC2 Instances (hashicorp#13917) Update CHANGELOG for hashicorp#13937 Update CHANGELOG for hashicorp#5448 resource/aws_cloudtrail: Handle single event selector in cloudtrail with non-default read_write_type (hashicorp#5448) Update CHANGELOG for hashicorp#13892 correct retry message to match in error handling correct import resource name accept empty string in volume_type validation Update CHANGELOG for hashicorp#4855 resource/aws_batch_compute_environment: Support fully optional desired_vcpus and wait for updates add retry error handling for SLR remove unused WebACL resource name in disappears test reference current AWS partition in iam role policy stmt remove duplicated disappears test step Update CHANGELOG for hashicorp#13926 ...
- Loading branch information
Showing
85 changed files
with
2,882 additions
and
555 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
package aws | ||
|
||
import ( | ||
"fmt" | ||
"time" | ||
|
||
"github.com/aws/aws-sdk-go/aws" | ||
"github.com/aws/aws-sdk-go/service/efs" | ||
"github.com/hashicorp/terraform-plugin-sdk/helper/schema" | ||
"github.com/hashicorp/terraform-plugin-sdk/helper/validation" | ||
) | ||
|
||
func dataSourceAwsEfsAccessPoints() *schema.Resource { | ||
return &schema.Resource{ | ||
Read: dataSourceAwsEfsAccessPointsRead, | ||
|
||
Schema: map[string]*schema.Schema{ | ||
"arns": { | ||
Type: schema.TypeSet, | ||
Computed: true, | ||
Elem: &schema.Schema{Type: schema.TypeString}, | ||
}, | ||
"file_system_id": { | ||
Type: schema.TypeString, | ||
Required: true, | ||
ValidateFunc: validation.StringIsNotEmpty, | ||
}, | ||
"ids": { | ||
Type: schema.TypeSet, | ||
Computed: true, | ||
Elem: &schema.Schema{Type: schema.TypeString}, | ||
}, | ||
}, | ||
} | ||
} | ||
|
||
func dataSourceAwsEfsAccessPointsRead(d *schema.ResourceData, meta interface{}) error { | ||
conn := meta.(*AWSClient).efsconn | ||
|
||
fileSystemId := d.Get("file_system_id").(string) | ||
input := &efs.DescribeAccessPointsInput{ | ||
FileSystemId: aws.String(fileSystemId), | ||
} | ||
|
||
var accessPoints []*efs.AccessPointDescription | ||
|
||
err := conn.DescribeAccessPointsPages(input, func(page *efs.DescribeAccessPointsOutput, lastPage bool) bool { | ||
if page == nil { | ||
return !lastPage | ||
} | ||
|
||
accessPoints = append(accessPoints, page.AccessPoints...) | ||
|
||
return !lastPage | ||
}) | ||
|
||
if err != nil { | ||
return fmt.Errorf("error reading EFS Access Points for File System (%s): %w", fileSystemId, err) | ||
} | ||
|
||
if len(accessPoints) == 0 { | ||
return fmt.Errorf("no matching EFS Access Points for File System (%s) found", fileSystemId) | ||
} | ||
|
||
d.SetId(time.Now().UTC().String()) | ||
|
||
var arns, ids []string | ||
|
||
for _, accessPoint := range accessPoints { | ||
arns = append(arns, aws.StringValue(accessPoint.AccessPointArn)) | ||
ids = append(ids, aws.StringValue(accessPoint.AccessPointId)) | ||
} | ||
|
||
if err := d.Set("arns", arns); err != nil { | ||
return fmt.Errorf("error setting arns: %w", err) | ||
} | ||
|
||
if err := d.Set("ids", ids); err != nil { | ||
return fmt.Errorf("error setting ids: %w", err) | ||
} | ||
|
||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package aws | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/hashicorp/terraform-plugin-sdk/helper/resource" | ||
) | ||
|
||
func TestAccDataSourceAWSEFSAccessPoints_basic(t *testing.T) { | ||
dataSourceName := "data.aws_efs_access_points.test" | ||
|
||
resource.ParallelTest(t, resource.TestCase{ | ||
PreCheck: func() { testAccPreCheck(t) }, | ||
Providers: testAccProviders, | ||
CheckDestroy: testAccCheckEfsAccessPointDestroy, | ||
Steps: []resource.TestStep{ | ||
{ | ||
Config: testAccDataSourceAWSEFSAccessPointsConfig(), | ||
Check: resource.ComposeTestCheckFunc( | ||
resource.TestCheckResourceAttr(dataSourceName, "arns.#", "1"), | ||
resource.TestCheckResourceAttr(dataSourceName, "ids.#", "1"), | ||
), | ||
}, | ||
}, | ||
}) | ||
} | ||
|
||
func testAccDataSourceAWSEFSAccessPointsConfig() string { | ||
return ` | ||
resource "aws_efs_file_system" "test" {} | ||
resource "aws_efs_access_point" "test" { | ||
file_system_id = aws_efs_file_system.test.id | ||
} | ||
data "aws_efs_access_points" "test" { | ||
file_system_id = aws_efs_access_point.test.file_system_id | ||
} | ||
` | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.