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

resource/aws_emr_cluster: fix error on missing cluster #16924

Merged
merged 2 commits into from
Jan 6, 2021
Merged
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
12 changes: 12 additions & 0 deletions aws/resource_aws_emr_cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -978,6 +978,18 @@ func resourceAwsEMRClusterRead(d *schema.ResourceData, meta interface{}) error {

resp, err := emrconn.DescribeCluster(req)
if err != nil {
// After a Cluster has been terminated for an indeterminate period of time,
// the EMR API will return this type of error:
// InvalidRequestException: Cluster id 'j-XXX' is not valid.
// If this causes issues with masking other legitimate request errors, the
// handling should be updated for deeper inspection of the special error type
// which includes an accurate error code:
// ErrorCode: "NoSuchCluster",
if isAWSErr(err, emr.ErrCodeInvalidRequestException, "is not valid") {
bflad marked this conversation as resolved.
Show resolved Hide resolved
log.Printf("[DEBUG] EMR Cluster (%s) not found", d.Id())
d.SetId("")
return nil
}
return fmt.Errorf("Error reading EMR cluster: %s", err)
}

Expand Down