diff --git a/builtin/providers/aws/resource_aws_emr_cluster.go b/builtin/providers/aws/resource_aws_emr_cluster.go index 53d8f06bb..661972c4e 100644 --- a/builtin/providers/aws/resource_aws_emr_cluster.go +++ b/builtin/providers/aws/resource_aws_emr_cluster.go @@ -70,6 +70,18 @@ func resourceAwsEMRCluster() *schema.Resource { Elem: &schema.Schema{Type: schema.TypeString}, Set: schema.HashString, }, + "termination_protection": &schema.Schema{ + Type: schema.TypeBool, + ForceNew: true, + Optional: true, + Computed: true, + }, + "keep_job_flow_alive_when_no_steps": &schema.Schema{ + Type: schema.TypeBool, + ForceNew: true, + Optional: true, + Computed: true, + }, "ec2_attributes": &schema.Schema{ Type: schema.TypeList, MaxItems: 1, @@ -169,13 +181,22 @@ func resourceAwsEMRClusterCreate(d *schema.ResourceData, meta interface{}) error applications := d.Get("applications").(*schema.Set).List() + keepJobFlowAliveWhenNoSteps := true + if v, ok := d.GetOk("keep_job_flow_alive_when_no_steps"); ok { + keepJobFlowAliveWhenNoSteps = v.(bool) + } + + terminationProtection := false + if v, ok := d.GetOk("termination_protection"); ok { + terminationProtection = v.(bool) + } instanceConfig := &emr.JobFlowInstancesConfig{ MasterInstanceType: aws.String(masterInstanceType), SlaveInstanceType: aws.String(coreInstanceType), InstanceCount: aws.Int64(int64(coreInstanceCount)), - // Default values that we can open up in the future - KeepJobFlowAliveWhenNoSteps: aws.Bool(true), - TerminationProtected: aws.Bool(false), + + KeepJobFlowAliveWhenNoSteps: aws.Bool(keepJobFlowAliveWhenNoSteps), + TerminationProtected: aws.Bool(terminationProtection), } var instanceProfile string @@ -275,7 +296,7 @@ func resourceAwsEMRClusterCreate(d *schema.ResourceData, meta interface{}) error Pending: []string{"STARTING", "BOOTSTRAPPING"}, Target: []string{"WAITING", "RUNNING"}, Refresh: resourceAwsEMRClusterStateRefreshFunc(d, meta), - Timeout: 75 * time.Minute, + Timeout: 40 * time.Minute, MinTimeout: 10 * time.Second, Delay: 30 * time.Second, // Wait 30 secs before starting } diff --git a/builtin/providers/aws/resource_aws_emr_cluster_test.go b/builtin/providers/aws/resource_aws_emr_cluster_test.go index a871d53e8..b125afc7e 100644 --- a/builtin/providers/aws/resource_aws_emr_cluster_test.go +++ b/builtin/providers/aws/resource_aws_emr_cluster_test.go @@ -121,6 +121,9 @@ resource "aws_emr_cluster" "tf-test-cluster" { name = "name-env" } + keep_job_flow_alive_when_no_steps = true + termination_protection = false + bootstrap_action { path = "s3://elasticmapreduce/bootstrap-actions/run-if" name = "runif" diff --git a/website/source/docs/providers/aws/r/emr_cluster.html.md b/website/source/docs/providers/aws/r/emr_cluster.html.md index 872b728a3..8e955f5fb 100644 --- a/website/source/docs/providers/aws/r/emr_cluster.html.md +++ b/website/source/docs/providers/aws/r/emr_cluster.html.md @@ -20,6 +20,9 @@ resource "aws_emr_cluster" "emr-test-cluster" { release_label = "emr-4.6.0" applications = ["Spark"] + termination_protection = false + keep_job_flow_alive_when_no_steps = true + ec2_attributes { subnet_id = "${aws_subnet.main.id}" emr_managed_master_security_group = "${aws_security_group.sg.id}" @@ -68,6 +71,8 @@ The following arguments are supported: * `log_uri` - (Optional) S3 bucket to write the log files of the job flow. If a value is not provided, logs are not created * `applications` - (Optional) A list of applications for the cluster. Valid values are: `Hadoop`, `Hive`, +* `termination_protection` - (Optional) Switch on/off termination protection (default is off) +* `keep_job_flow_alive_when_no_steps` - (Optional) Switch on/off run cluster with no steps or when all steps are complete (default is on) `Mahout`, `Pig`, and `Spark.` Case insensitive * `ec2_attributes` - (Optional) Attributes for the EC2 instances running the job flow. Defined below