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())
|
return fmt.Errorf("EFS file system %q could not be found.", d.Id())
|
||||||
}
|
}
|
||||||
|
|
||||||
tagsResp, err := conn.DescribeTags(&efs.DescribeTagsInput{
|
tags := make([]*efs.Tag, 0)
|
||||||
FileSystemId: aws.String(d.Id()),
|
var marker string
|
||||||
})
|
for {
|
||||||
if err != nil {
|
params := &efs.DescribeTagsInput{
|
||||||
return fmt.Errorf("Error retrieving EC2 tags for EFS file system (%q): %s",
|
FileSystemId: aws.String(d.Id()),
|
||||||
d.Id(), err.Error())
|
}
|
||||||
|
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 {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
|
@ -87,7 +87,7 @@ func TestAccAWSEFSFileSystem_basic(t *testing.T) {
|
||||||
Providers: testAccProviders,
|
Providers: testAccProviders,
|
||||||
CheckDestroy: testAccCheckEfsFileSystemDestroy,
|
CheckDestroy: testAccCheckEfsFileSystemDestroy,
|
||||||
Steps: []resource.TestStep{
|
Steps: []resource.TestStep{
|
||||||
resource.TestStep{
|
{
|
||||||
Config: testAccAWSEFSFileSystemConfig,
|
Config: testAccAWSEFSFileSystemConfig,
|
||||||
Check: resource.ComposeTestCheckFunc(
|
Check: resource.ComposeTestCheckFunc(
|
||||||
resource.TestCheckResourceAttr(
|
resource.TestCheckResourceAttr(
|
||||||
|
@ -103,7 +103,7 @@ func TestAccAWSEFSFileSystem_basic(t *testing.T) {
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
resource.TestStep{
|
{
|
||||||
Config: testAccAWSEFSFileSystemConfigWithTags,
|
Config: testAccAWSEFSFileSystemConfigWithTags,
|
||||||
Check: resource.ComposeTestCheckFunc(
|
Check: resource.ComposeTestCheckFunc(
|
||||||
testAccCheckEfsFileSystem(
|
testAccCheckEfsFileSystem(
|
||||||
|
@ -122,7 +122,7 @@ func TestAccAWSEFSFileSystem_basic(t *testing.T) {
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
resource.TestStep{
|
{
|
||||||
Config: testAccAWSEFSFileSystemConfigWithPerformanceMode,
|
Config: testAccAWSEFSFileSystemConfigWithPerformanceMode,
|
||||||
Check: resource.ComposeTestCheckFunc(
|
Check: resource.ComposeTestCheckFunc(
|
||||||
testAccCheckEfsFileSystem(
|
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 {
|
func testAccCheckEfsFileSystemDestroy(s *terraform.State) error {
|
||||||
conn := testAccProvider.Meta().(*AWSClient).efsconn
|
conn := testAccProvider.Meta().(*AWSClient).efsconn
|
||||||
for _, rs := range s.RootModule().Resources {
|
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 = `
|
const testAccAWSEFSFileSystemConfigWithTags = `
|
||||||
resource "aws_efs_file_system" "foo-with-tags" {
|
resource "aws_efs_file_system" "foo-with-tags" {
|
||||||
creation_token = "yada_yada"
|
creation_token = "yada_yada"
|
||||||
|
|
Loading…
Reference in New Issue