Merge branch 'xt84-emr_autotermination'
This commit is contained in:
commit
3259aa0d56
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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"
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue