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

[TechDebt]: Fix appstream acceptance tests #32958

Merged
merged 8 commits into from
Aug 11, 2023
3 changes: 3 additions & 0 deletions .changelog/32958.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:enhancement
resource/aws_appstream_fleet: Retry ConcurrentModificationException errors during creation
```
6 changes: 5 additions & 1 deletion internal/service/appstream/fleet.go
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,10 @@ func resourceFleetCreate(ctx context.Context, d *schema.ResourceData, meta inter
return retry.RetryableError(err)
}

if tfawserr.ErrCodeEquals(err, appstream.ErrCodeConcurrentModificationException) {
return retry.RetryableError(err)
}

// Retry for IAM eventual consistency on error:
if tfawserr.ErrMessageContains(err, appstream.ErrCodeInvalidRoleException, "encountered an error because your IAM role") {
return retry.RetryableError(err)
Expand All @@ -288,7 +292,7 @@ func resourceFleetCreate(ctx context.Context, d *schema.ResourceData, meta inter
output, err = conn.CreateFleetWithContext(ctx, input)
}
if err != nil {
return diag.Errorf("creating Appstream Fleet (%s): %s", d.Id(), err)
return diag.Errorf("creating Appstream Fleet (%s): %s", d.Get("name").(string), err)
}

d.SetId(aws.StringValue(output.Fleet.Name))
Expand Down
4 changes: 2 additions & 2 deletions internal/service/appstream/fleet_stack_association_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,11 +131,11 @@ func testAccCheckFleetStackAssociationDestroy(ctx context.Context) resource.Test
}

func testAccFleetStackAssociationConfig_basic(name string) string {
// "Amazon-AppStream2-Sample-Image-02-04-2019" is not available in GovCloud
// "Amazon-AppStream2-Sample-Image-03-11-2023" is not available in GovCloud
return fmt.Sprintf(`
resource "aws_appstream_fleet" "test" {
name = %[1]q
image_name = "Amazon-AppStream2-Sample-Image-02-04-2019"
image_name = "Amazon-AppStream2-Sample-Image-03-11-2023"
instance_type = "stream.standard.small"

compute_capacity {
Expand Down
14 changes: 7 additions & 7 deletions internal/service/appstream/fleet_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -361,11 +361,11 @@ func testAccCheckFleetDestroy(ctx context.Context) resource.TestCheckFunc {
}

func testAccFleetConfig_basic(name, instanceType string) string {
// "Amazon-AppStream2-Sample-Image-02-04-2019" is not available in GovCloud
// "Amazon-AppStream2-Sample-Image-03-11-2023" is not available in GovCloud
return fmt.Sprintf(`
resource "aws_appstream_fleet" "test" {
name = %[1]q
image_name = "Amazon-AppStream2-Sample-Image-02-04-2019"
image_name = "Amazon-AppStream2-Sample-Image-03-11-2023"
instance_type = %[2]q

compute_capacity {
Expand Down Expand Up @@ -395,7 +395,7 @@ resource "aws_subnet" "test" {

resource "aws_appstream_fleet" "test" {
name = %[1]q
image_arn = "arn:${data.aws_partition.current.partition}:appstream:${data.aws_region.current.name}::image/Amazon-AppStream2-Sample-Image-02-04-2019"
image_arn = "arn:${data.aws_partition.current.partition}:appstream:${data.aws_region.current.name}::image/Amazon-AppStream2-Sample-Image-03-11-2023"

compute_capacity {
desired_instances = 1
Expand Down Expand Up @@ -433,7 +433,7 @@ resource "aws_subnet" "test" {

resource "aws_appstream_fleet" "test" {
name = %[1]q
image_name = "Amazon-AppStream2-Sample-Image-02-04-2019"
image_name = "Amazon-AppStream2-Sample-Image-03-11-2023"

compute_capacity {
desired_instances = 1
Expand Down Expand Up @@ -471,7 +471,7 @@ resource "aws_subnet" "test" {

resource "aws_appstream_fleet" "test" {
name = %[1]q
image_name = "Amazon-AppStream2-Sample-Image-02-04-2019"
image_name = "Amazon-AppStream2-Sample-Image-03-11-2023"

compute_capacity {
desired_instances = 1
Expand All @@ -497,11 +497,11 @@ resource "aws_appstream_fleet" "test" {
}

func testAccFleetConfig_emptyDomainJoin(name, instanceType, empty string) string {
// "Amazon-AppStream2-Sample-Image-02-04-2019" is not available in GovCloud
// "Amazon-AppStream2-Sample-Image-03-11-2023" is not available in GovCloud
return fmt.Sprintf(`
resource "aws_appstream_fleet" "test" {
name = %[1]q
image_name = "Amazon-AppStream2-Sample-Image-02-04-2019"
image_name = "Amazon-AppStream2-Sample-Image-03-11-2023"
instance_type = %[2]q

compute_capacity {
Expand Down
12 changes: 6 additions & 6 deletions internal/service/appstream/image_builder_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ func TestAccAppStreamImageBuilder_withIAMRole(t *testing.T) {
ctx := acctest.Context(t)
resourceName := "aws_appstream_image_builder.test"
instanceType := "stream.standard.medium"
imageName := "AppStream-WinServer2019-07-12-2022"
imageName := "AppStream-WinServer2019-06-12-2023"
rName := sdkacctest.RandomWithPrefix(acctest.ResourcePrefix)

resource.ParallelTest(t, resource.TestCase{
Expand Down Expand Up @@ -202,7 +202,7 @@ func TestAccAppStreamImageBuilder_imageARN(t *testing.T) {
resourceName := "aws_appstream_image_builder.test"
// imageName selected from the available AWS Managed AppStream 2.0 Base Images
// Reference: https://docs.aws.amazon.com/appstream2/latest/developerguide/base-image-version-history.html
imageName := "AppStream-WinServer2019-07-12-2022"
imageName := "AppStream-WinServer2019-06-12-2023"
instanceType := "stream.standard.small"
rName := sdkacctest.RandomWithPrefix(acctest.ResourcePrefix)

Expand Down Expand Up @@ -276,7 +276,7 @@ func testAccCheckImageBuilderDestroy(ctx context.Context) resource.TestCheckFunc
func testAccImageBuilderConfig_basic(instanceType, rName string) string {
return fmt.Sprintf(`
resource "aws_appstream_image_builder" "test" {
image_name = "AppStream-WinServer2019-07-12-2022"
image_name = "AppStream-WinServer2019-06-12-2023"
instance_type = %[1]q
name = %[2]q
}
Expand All @@ -286,7 +286,7 @@ resource "aws_appstream_image_builder" "test" {
func testAccImageBuilderConfig_complete(rName, description, instanceType string) string {
return acctest.ConfigCompose(acctest.ConfigVPCWithSubnets(rName, 1), fmt.Sprintf(`
resource "aws_appstream_image_builder" "test" {
image_name = "AppStream-WinServer2019-07-12-2022"
image_name = "AppStream-WinServer2019-06-12-2023"
name = %[1]q
description = %[2]q
enable_default_internet_access = false
Expand All @@ -301,7 +301,7 @@ resource "aws_appstream_image_builder" "test" {
func testAccImageBuilderConfig_tags1(instanceType, rName, key, value string) string {
return fmt.Sprintf(`
resource "aws_appstream_image_builder" "test" {
image_name = "AppStream-WinServer2019-07-12-2022"
image_name = "AppStream-WinServer2019-06-12-2023"
instance_type = %[1]q
name = %[2]q

Expand All @@ -315,7 +315,7 @@ resource "aws_appstream_image_builder" "test" {
func testAccImageBuilderConfig_tags2(instanceType, rName, key1, value1, key2, value2 string) string {
return fmt.Sprintf(`
resource "aws_appstream_image_builder" "test" {
image_name = "AppStream-WinServer2019-07-12-2022"
image_name = "AppStream-WinServer2019-06-12-2023"
instance_type = %[1]q
name = %[2]q

Expand Down
2 changes: 1 addition & 1 deletion website/docs/r/appstream_fleet.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ resource "aws_appstream_fleet" "test_fleet" {
display_name = "test-fleet"
enable_default_internet_access = false
fleet_type = "ON_DEMAND"
image_name = "Amazon-AppStream2-Sample-Image-02-04-2019"
image_name = "Amazon-AppStream2-Sample-Image-03-11-2023"
instance_type = "stream.standard.large"
max_user_duration_in_seconds = 600

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ Manages an AppStream Fleet Stack association.
```terraform
resource "aws_appstream_fleet" "example" {
name = "NAME"
image_name = "Amazon-AppStream2-Sample-Image-02-04-2019"
image_name = "Amazon-AppStream2-Sample-Image-03-11-2023"
instance_type = "stream.standard.small"

compute_capacity {
Expand Down
Loading