mirror of
https://github.com/opentofu/opentofu.git
synced 2025-01-08 15:13:56 -06:00
provider/aws: reading multiple pages of aws_efs_file_system tags (#12328)
Fixes: #12232 ``` % make testacc TEST=./builtin/providers/aws TESTARGS='-run=TestAccAWSEFSFileSystem_pagedTags' ==> Checking that code complies with gofmt requirements... go generate $(go list ./... | grep -v /terraform/vendor/) TF_ACC=1 go test ./builtin/providers/aws -v -run=TestAccAWSEFSFileSystem_pagedTags -timeout 120m === RUN TestAccAWSEFSFileSystem_pagedTags --- PASS: TestAccAWSEFSFileSystem_pagedTags (39.51s) PASS ok github.com/hashicorp/terraform/builtin/providers/aws 39.537s ```
This commit is contained in:
parent
e7a88ce089
commit
26926aca77
@ -149,15 +149,34 @@ func resourceAwsEfsFileSystemRead(d *schema.ResourceData, meta interface{}) erro
|
||||
return fmt.Errorf("EFS file system %q could not be found.", d.Id())
|
||||
}
|
||||
|
||||
tagsResp, err := conn.DescribeTags(&efs.DescribeTagsInput{
|
||||
FileSystemId: aws.String(d.Id()),
|
||||
})
|
||||
if err != nil {
|
||||
return fmt.Errorf("Error retrieving EC2 tags for EFS file system (%q): %s",
|
||||
d.Id(), err.Error())
|
||||
tags := make([]*efs.Tag, 0)
|
||||
var marker string
|
||||
for {
|
||||
params := &efs.DescribeTagsInput{
|
||||
FileSystemId: aws.String(d.Id()),
|
||||
}
|
||||
if marker != "" {
|
||||
params.Marker = aws.String(marker)
|
||||
}
|
||||
|
||||
tagsResp, err := conn.DescribeTags(params)
|
||||
if err != nil {
|
||||
return fmt.Errorf("Error retrieving EC2 tags for EFS file system (%q): %s",
|
||||
d.Id(), err.Error())
|
||||
}
|
||||
|
||||
for _, tag := range tagsResp.Tags {
|
||||
tags = append(tags, tag)
|
||||
}
|
||||
|
||||
if tagsResp.NextMarker != nil {
|
||||
marker = *tagsResp.NextMarker
|
||||
} else {
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
err = d.Set("tags", tagsToMapEFS(tagsResp.Tags))
|
||||
err = d.Set("tags", tagsToMapEFS(tags))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -87,7 +87,7 @@ func TestAccAWSEFSFileSystem_basic(t *testing.T) {
|
||||
Providers: testAccProviders,
|
||||
CheckDestroy: testAccCheckEfsFileSystemDestroy,
|
||||
Steps: []resource.TestStep{
|
||||
resource.TestStep{
|
||||
{
|
||||
Config: testAccAWSEFSFileSystemConfig,
|
||||
Check: resource.ComposeTestCheckFunc(
|
||||
resource.TestCheckResourceAttr(
|
||||
@ -103,7 +103,7 @@ func TestAccAWSEFSFileSystem_basic(t *testing.T) {
|
||||
),
|
||||
),
|
||||
},
|
||||
resource.TestStep{
|
||||
{
|
||||
Config: testAccAWSEFSFileSystemConfigWithTags,
|
||||
Check: resource.ComposeTestCheckFunc(
|
||||
testAccCheckEfsFileSystem(
|
||||
@ -122,7 +122,7 @@ func TestAccAWSEFSFileSystem_basic(t *testing.T) {
|
||||
),
|
||||
),
|
||||
},
|
||||
resource.TestStep{
|
||||
{
|
||||
Config: testAccAWSEFSFileSystemConfigWithPerformanceMode,
|
||||
Check: resource.ComposeTestCheckFunc(
|
||||
testAccCheckEfsFileSystem(
|
||||
@ -142,6 +142,32 @@ func TestAccAWSEFSFileSystem_basic(t *testing.T) {
|
||||
})
|
||||
}
|
||||
|
||||
func TestAccAWSEFSFileSystem_pagedTags(t *testing.T) {
|
||||
resource.Test(t, resource.TestCase{
|
||||
PreCheck: func() { testAccPreCheck(t) },
|
||||
Providers: testAccProviders,
|
||||
CheckDestroy: testAccCheckEfsFileSystemDestroy,
|
||||
Steps: []resource.TestStep{
|
||||
{
|
||||
Config: testAccAWSEFSFileSystemConfigPagedTags,
|
||||
Check: resource.ComposeTestCheckFunc(
|
||||
resource.TestCheckResourceAttr(
|
||||
"aws_efs_file_system.foo",
|
||||
"tags.%",
|
||||
"11"),
|
||||
//testAccCheckEfsFileSystem(
|
||||
// "aws_efs_file_system.foo",
|
||||
//),
|
||||
//testAccCheckEfsFileSystemPerformanceMode(
|
||||
// "aws_efs_file_system.foo",
|
||||
// "generalPurpose",
|
||||
//),
|
||||
),
|
||||
},
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
func testAccCheckEfsFileSystemDestroy(s *terraform.State) error {
|
||||
conn := testAccProvider.Meta().(*AWSClient).efsconn
|
||||
for _, rs := range s.RootModule().Resources {
|
||||
@ -286,6 +312,25 @@ resource "aws_efs_file_system" "foo" {
|
||||
}
|
||||
`
|
||||
|
||||
const testAccAWSEFSFileSystemConfigPagedTags = `
|
||||
resource "aws_efs_file_system" "foo" {
|
||||
creation_token = "radeksimko"
|
||||
tags {
|
||||
Name = "foo-efs"
|
||||
Another = "tag"
|
||||
Test = "yes"
|
||||
User = "root"
|
||||
Page = "1"
|
||||
Environment = "prod"
|
||||
CostCenter = "terraform"
|
||||
AcceptanceTest = "PagedTags"
|
||||
CreationToken = "radek"
|
||||
PerfMode = "max"
|
||||
Region = "us-west-2"
|
||||
}
|
||||
}
|
||||
`
|
||||
|
||||
const testAccAWSEFSFileSystemConfigWithTags = `
|
||||
resource "aws_efs_file_system" "foo-with-tags" {
|
||||
creation_token = "yada_yada"
|
||||
|
Loading…
Reference in New Issue
Block a user