From f040b653ad9753fc91ae8034d3d687d48cd58275 Mon Sep 17 00:00:00 2001 From: Artsiom <82237255+ArtsiomAntropau@users.noreply.github.com> Date: Tue, 8 Feb 2022 18:39:22 +0100 Subject: [PATCH] Fix EMR is not valid for managed_scaling_policy Fix aws_emr_managed_scaling_policy for compatibility with the behavior of emr_cluster that was fixed as a part of the next problem: https://github.com/hashicorp/terraform-provider-aws/pull/16924 https://github.com/hashicorp/terraform-provider-aws/issues/7783 --- internal/service/emr/managed_scaling_policy.go | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/internal/service/emr/managed_scaling_policy.go b/internal/service/emr/managed_scaling_policy.go index 76c61fd6f60..2af73437861 100644 --- a/internal/service/emr/managed_scaling_policy.go +++ b/internal/service/emr/managed_scaling_policy.go @@ -115,6 +115,12 @@ func resourceManagedScalingPolicyRead(d *schema.ResourceData, meta interface{}) d.SetId("") return nil } + + if tfawserr.ErrMessageContains(err, "ValidationException", "is not valid") { + log.Printf("[WARN] EMR Cluster (%s) not found", d.Id()) + d.SetId("") + return nil + } if tfawserr.ErrMessageContains(err, "InvalidRequestException", "does not exist") { log.Printf("[WARN] EMR Managed Scaling Policy (%s) not found, removing from state", d.Id()) @@ -152,7 +158,13 @@ func resourceManagedScalingPolicyDelete(d *schema.ResourceData, meta interface{} if tfawserr.ErrMessageContains(err, "ValidationException", "A job flow that is shutting down, terminated, or finished may not be modified") { return nil } - + + if tfawserr.ErrMessageContains(err, "ValidationException", "is not valid") { + log.Printf("[WARN] EMR Cluster (%s) not found", d.Id()) + d.SetId("") + return nil + } + if tfawserr.ErrMessageContains(err, "InvalidRequestException", "does not exist") { return nil }