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},
|
Elem: &schema.Schema{Type: schema.TypeString},
|
||||||
Set: schema.HashString,
|
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{
|
"ec2_attributes": &schema.Schema{
|
||||||
Type: schema.TypeList,
|
Type: schema.TypeList,
|
||||||
MaxItems: 1,
|
MaxItems: 1,
|
||||||
|
@ -169,13 +181,22 @@ func resourceAwsEMRClusterCreate(d *schema.ResourceData, meta interface{}) error
|
||||||
|
|
||||||
applications := d.Get("applications").(*schema.Set).List()
|
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{
|
instanceConfig := &emr.JobFlowInstancesConfig{
|
||||||
MasterInstanceType: aws.String(masterInstanceType),
|
MasterInstanceType: aws.String(masterInstanceType),
|
||||||
SlaveInstanceType: aws.String(coreInstanceType),
|
SlaveInstanceType: aws.String(coreInstanceType),
|
||||||
InstanceCount: aws.Int64(int64(coreInstanceCount)),
|
InstanceCount: aws.Int64(int64(coreInstanceCount)),
|
||||||
// Default values that we can open up in the future
|
|
||||||
KeepJobFlowAliveWhenNoSteps: aws.Bool(true),
|
KeepJobFlowAliveWhenNoSteps: aws.Bool(keepJobFlowAliveWhenNoSteps),
|
||||||
TerminationProtected: aws.Bool(false),
|
TerminationProtected: aws.Bool(terminationProtection),
|
||||||
}
|
}
|
||||||
|
|
||||||
var instanceProfile string
|
var instanceProfile string
|
||||||
|
@ -275,7 +296,7 @@ func resourceAwsEMRClusterCreate(d *schema.ResourceData, meta interface{}) error
|
||||||
Pending: []string{"STARTING", "BOOTSTRAPPING"},
|
Pending: []string{"STARTING", "BOOTSTRAPPING"},
|
||||||
Target: []string{"WAITING", "RUNNING"},
|
Target: []string{"WAITING", "RUNNING"},
|
||||||
Refresh: resourceAwsEMRClusterStateRefreshFunc(d, meta),
|
Refresh: resourceAwsEMRClusterStateRefreshFunc(d, meta),
|
||||||
Timeout: 75 * time.Minute,
|
Timeout: 40 * time.Minute,
|
||||||
MinTimeout: 10 * time.Second,
|
MinTimeout: 10 * time.Second,
|
||||||
Delay: 30 * time.Second, // Wait 30 secs before starting
|
Delay: 30 * time.Second, // Wait 30 secs before starting
|
||||||
}
|
}
|
||||||
|
|
|
@ -121,6 +121,9 @@ resource "aws_emr_cluster" "tf-test-cluster" {
|
||||||
name = "name-env"
|
name = "name-env"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
keep_job_flow_alive_when_no_steps = true
|
||||||
|
termination_protection = false
|
||||||
|
|
||||||
bootstrap_action {
|
bootstrap_action {
|
||||||
path = "s3://elasticmapreduce/bootstrap-actions/run-if"
|
path = "s3://elasticmapreduce/bootstrap-actions/run-if"
|
||||||
name = "runif"
|
name = "runif"
|
||||||
|
|
|
@ -20,6 +20,9 @@ resource "aws_emr_cluster" "emr-test-cluster" {
|
||||||
release_label = "emr-4.6.0"
|
release_label = "emr-4.6.0"
|
||||||
applications = ["Spark"]
|
applications = ["Spark"]
|
||||||
|
|
||||||
|
termination_protection = false
|
||||||
|
keep_job_flow_alive_when_no_steps = true
|
||||||
|
|
||||||
ec2_attributes {
|
ec2_attributes {
|
||||||
subnet_id = "${aws_subnet.main.id}"
|
subnet_id = "${aws_subnet.main.id}"
|
||||||
emr_managed_master_security_group = "${aws_security_group.sg.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
|
* `log_uri` - (Optional) S3 bucket to write the log files of the job flow. If a value
|
||||||
is not provided, logs are not created
|
is not provided, logs are not created
|
||||||
* `applications` - (Optional) A list of applications for the cluster. Valid values are: `Hadoop`, `Hive`,
|
* `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
|
`Mahout`, `Pig`, and `Spark.` Case insensitive
|
||||||
* `ec2_attributes` - (Optional) Attributes for the EC2 instances running the job
|
* `ec2_attributes` - (Optional) Attributes for the EC2 instances running the job
|
||||||
flow. Defined below
|
flow. Defined below
|
||||||
|
|
Loading…
Reference in New Issue