亚马逊电子病历使用点实例作为核心,主节点使用Terraform



我想使用terraform为EMR使用spot实例。我可以使用CLI:

aws emr create-cluster --release-label emr-5.3.1 --service-role 
EMR_DefaultRole 
--ec2-attributes InstanceProfile=EMR_EC2_DefaultRole 
--instance-fleets 
InstanceFleetType=MASTER,TargetSpotCapacity=1,InstanceTypeConfigs= . 
['{InstanceType=m4.large,BidPrice=0.5}'] 
InstanceFleetType=CORE,TargetSpotCapacity=1,InstanceTypeConfigs= . 
['{InstanceType=m4.large,BidPrice=0.5}']`

但我在地形中找不到实例舰队的功能。如何使用地形实现同样的效果

您可以为EMR集群在instance_group块下使用的实例指定投标价格,以使Terraform为实例使用现货实例。

aws_emr_cluster资源文档中的示例显示了应该如何指定:

resource "aws_emr_cluster" "emr-test-cluster" {
name          = "emr-test-arn"
release_label = "emr-4.6.0"
applications  = ["Spark"]
additional_info = <<EOF
{
"instanceAwsClientConfiguration": {
"proxyPort": 8099,
"proxyHost": "myproxy.example.com"
}
}
EOF
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}"
emr_managed_slave_security_group  = "${aws_security_group.sg.id}"
instance_profile                  = "${aws_iam_instance_profile.emr_profile.arn}"
}
instance_group {
instance_role = "CORE"
instance_type = "c4.large"
instance_count = "1"
ebs_config {
size = "40"
type = "gp2"
volumes_per_instance = 1
}
bid_price = "0.30"
autoscaling_policy = <<EOF
{
"Constraints": {
"MinCapacity": 1,
"MaxCapacity": 2
},
"Rules": [
{
"Name": "ScaleOutMemoryPercentage",
"Description": "Scale out if YARNMemoryAvailablePercentage is less than 15",
"Action": {
"SimpleScalingPolicyConfiguration": {
"AdjustmentType": "CHANGE_IN_CAPACITY",
"ScalingAdjustment": 1,
"CoolDown": 300
}
},
"Trigger": {
"CloudWatchAlarmDefinition": {
"ComparisonOperator": "LESS_THAN",
"EvaluationPeriods": 1,
"MetricName": "YARNMemoryAvailablePercentage",
"Namespace": "AWS/ElasticMapReduce",
"Period": 300,
"Statistic": "AVERAGE",
"Threshold": 15.0,
"Unit": "PERCENT"
}
}
}
]
}
EOF
}
ebs_root_volume_size     = 100
master_instance_type = "m3.xlarge"
core_instance_type   = "m3.xlarge"
core_instance_count  = 1
tags {
role     = "rolename"
env      = "env"
}
bootstrap_action {
path = "s3://elasticmapreduce/bootstrap-actions/run-if"
name = "runif"
args = ["instance.isMaster=true", "echo running on master node"]
}
configurations_json = <<EOF
[
{
"Classification": "hadoop-env",
"Configurations": [
{
"Classification": "export",
"Properties": {
"JAVA_HOME": "/usr/lib/jvm/java-1.8.0"
}
}
],
"Properties": {}
},
{
"Classification": "spark-env",
"Configurations": [
{
"Classification": "export",
"Properties": {
"JAVA_HOME": "/usr/lib/jvm/java-1.8.0"
}
}
],
"Properties": {}
}
]
EOF  
service_role = "${aws_iam_role.iam_emr_service_role.arn}"
}

最新更新