2017-05-26 23 views
0

我正在嘗試爲AWS EMR羣集創建一個terraform模塊。我需要在EMR中運行多個引導腳本,在這裏我有錯誤。 例如:如何使用Terraform在AWS EMR中傳遞多個引導操作?

main.tf

... 
    variable bootstrap_actions { type = "list"} 
    ...  
    resource "aws_emr_cluster" "emr-cluster" { 
    name   = "${var.emr_name}" 

    release_label = "${var.release_label}" 
    applications = "${var.applications}" 

    termination_protection = true 

    ec2_attributes { 
    subnet_id       = "${data.aws_subnet.subnet.id}" 
    emr_managed_master_security_group = "${data.aws_security_group.emr_managed_master_security_group.id}" 
    emr_managed_slave_security_group = "${data.aws_security_group.emr_managed_slave_security_group.id}" 
    service_access_security_group  = "${data.aws_security_group.service_access_security_group.id}" 
    additional_slave_security_groups = "${var.additional_slave_security_groups_id}" 
    instance_profile     = "${var.instance_profile}" 
    key_name       = "${var.key_name}" 
    } 

    master_instance_type = "${var.master_instance_type}" 
    core_instance_type = "${var.core_instance_type}" 
    core_instance_count = "${var.core_instance_count}" 

    tags { 
     BUSINESS_UNIT = "${var.BUSINESS_UNIT}" 
     BUSINESS_REGION = "${var.BUSINESS_REGION}" 
     CLIENT = "${var.CLIENT}" 
     ENVIRONMENT = "${var.env}" 
     PLATFORM = "${var.PLATFORM}" 
     Name = "${var.emr_name}" 
    } 


    bootstrap_action = "${var.bootstrap_actions}" 

    configurations = "test-fixtures/emr_configurations.json" 

    service_role = "${var.service_role}" 
    autoscaling_role = "${var.autoscaling_role}" 

} 

我通過了所有的變量,包括引導爲:

bootstrap_actions = [ "path=s3://bucket/bootstrap/hive/metastore/JSON41.sh,name=SERDE","path=s3://bucket/bootstrap/hive/hive-nofile-nproc-increase.sh,name=ulimit" ] 

當我申請這個計劃,我得到錯誤:

* aws_emr_cluster.emr-cluster: bootstrap_action.0: expected object, got invalid 
* aws_emr_cluster.emr-cluster: bootstrap_action.1: expected object, got invalid 

有沒有人有任何想法呢?我如何在這裏傳遞多個引導操作。 請指教。

謝謝。

回答

0

Doc:bootstrap_action - (可選)將在羣集節點上啓動Hadoop之前運行的引導操作列表。

您的變量是字符串列表,而不是對象列表。這個變量可能是好的(未經測試):

bootstrap_actions = [ 
    { 
    path = "s3://bucket/bootstrap/hive/metastore/JSON41.sh" 
    name = "SERDE" 
    }, 
    { 
    path = "s3://bucket/bootstrap/hive/hive-nofile-nproc-increase.sh" 
    name = "ulimit" 
    }, 
] 
相關問題