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

Add support for updating release label on EMR Serverless applications #32278

Merged
merged 3 commits into from
Jun 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .changelog/32278.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:enhancement
resource/aws_emrserverless_application: Do not recreate the resource if `release_label` changes
```
5 changes: 4 additions & 1 deletion internal/service/emrserverless/application.go
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down Expand Up @@ -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))
}
Expand Down
45 changes: 45 additions & 0 deletions internal/service/emrserverless/application_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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" {
Expand Down