From 3f3664a4e4437863fd2b3dde94fa5fa1b0dbcf54 Mon Sep 17 00:00:00 2001 From: Radek Simko Date: Tue, 6 Jun 2017 13:55:13 +0100 Subject: [PATCH] provider/aws: Expose reason of EMR cluster termination (#15117) --- builtin/providers/aws/resource_aws_emr_cluster.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/builtin/providers/aws/resource_aws_emr_cluster.go b/builtin/providers/aws/resource_aws_emr_cluster.go index ee8868aae..f1a0d5512 100644 --- a/builtin/providers/aws/resource_aws_emr_cluster.go +++ b/builtin/providers/aws/resource_aws_emr_cluster.go @@ -831,6 +831,13 @@ func resourceAwsEMRClusterStateRefreshFunc(d *schema.ResourceData, meta interfac log.Printf("[DEBUG] EMR Cluster status (%s): %s", d.Id(), *resp.Cluster.Status) } - return emrc, *emrc.Status.State, nil + status := emrc.Status + if *status.State == "TERMINATING" { + reason := *status.StateChangeReason + return emrc, *status.State, fmt.Errorf("EMR Cluster is terminating. %s: %s", + *reason.Code, *reason.Message) + } + + return emrc, *status.State, nil } }