diff --git a/.changelog/32278.txt b/.changelog/32278.txt new file mode 100644 index 00000000000..7ebd393ad8a --- /dev/null +++ b/.changelog/32278.txt @@ -0,0 +1,3 @@ +```release-note:enhancement +resource/aws_emrserverless_application: Do not recreate the resource if `release_label` changes +``` \ No newline at end of file diff --git a/internal/service/emrserverless/application.go b/internal/service/emrserverless/application.go index eb44a2e3f75..2c0931abbef 100644 --- a/internal/service/emrserverless/application.go +++ b/internal/service/emrserverless/application.go @@ -201,7 +201,6 @@ func ResourceApplication() *schema.Resource { "release_label": { Type: schema.TypeString, Required: true, - ForceNew: true, }, names.AttrTags: tftags.TagsSchema(), names.AttrTagsAll: tftags.TagsSchemaComputed(), @@ -334,6 +333,10 @@ func resourceApplicationUpdate(ctx context.Context, d *schema.ResourceData, meta ClientToken: aws.String(id.UniqueId()), } + if v, ok := d.GetOk("release_label"); ok { + input.ReleaseLabel = aws.String(v.(string)) + } + if v, ok := d.GetOk("architecture"); ok { input.Architecture = aws.String(v.(string)) } diff --git a/internal/service/emrserverless/application_test.go b/internal/service/emrserverless/application_test.go index 5b483dc6604..07f39f3ff5c 100644 --- a/internal/service/emrserverless/application_test.go +++ b/internal/service/emrserverless/application_test.go @@ -91,6 +91,41 @@ func TestAccEMRServerlessApplication_arch(t *testing.T) { }) } +func TestAccEMRServerlessApplication_releaseLabel(t *testing.T) { + ctx := acctest.Context(t) + var application emrserverless.Application + resourceName := "aws_emrserverless_application.test" + rName := sdkacctest.RandomWithPrefix(acctest.ResourcePrefix) + + resource.ParallelTest(t, resource.TestCase{ + PreCheck: func() { acctest.PreCheck(ctx, t) }, + ErrorCheck: acctest.ErrorCheck(t, emrserverless.EndpointsID), + ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories, + CheckDestroy: testAccCheckApplicationDestroy(ctx), + Steps: []resource.TestStep{ + { + Config: testAccApplicationConfig_releaseLabel(rName, "emr-6.10.0"), + Check: resource.ComposeTestCheckFunc( + testAccCheckApplicationExists(ctx, resourceName, &application), + resource.TestCheckResourceAttr(resourceName, "release_label", "emr-6.10.0"), + ), + }, + { + ResourceName: resourceName, + ImportState: true, + ImportStateVerify: true, + }, + { + Config: testAccApplicationConfig_releaseLabel(rName, "emr-6.11.0"), + Check: resource.ComposeTestCheckFunc( + testAccCheckApplicationExists(ctx, resourceName, &application), + resource.TestCheckResourceAttr(resourceName, "release_label", "emr-6.11.0"), + ), + }, + }, + }) +} + func TestAccEMRServerlessApplication_initialCapacity(t *testing.T) { ctx := acctest.Context(t) var application emrserverless.Application @@ -388,6 +423,16 @@ resource "aws_emrserverless_application" "test" { `, rName) } +func testAccApplicationConfig_releaseLabel(rName string, rl string) string { + return fmt.Sprintf(` +resource "aws_emrserverless_application" "test" { + name = %[1]q + release_label = %[2]q + type = "spark" +} +`, rName, rl) +} + func testAccApplicationConfig_initialCapacity(rName, cpu string) string { return fmt.Sprintf(` resource "aws_emrserverless_application" "test" {