如何使用Terraform在AWS EMR中传递多个引导操作?

时间:2017-05-26 18:17:57

标签: emr terraform

我正在尝试为AWS EMR集群创建一个terraform模块。我需要在EMR中运行多个引导脚本,我遇到了错误。 例如:

main.tf

Access-Control

我传递了包括bootstrap在内的所有变量:

  ...
  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" ]

有人对此有任何想法吗?如何在此处传递多个引导操作。 请指教。

感谢。

2 个答案:

答案 0 :(得分:1)

有效:

bootstrap_action = [
        {
          name = "custombootrstrap_test1"
          path = "s3://${aws_s3_bucket.bucketlogs.bucket}/bootstrap-actions/master/configure-test1.sh"
        },
        {
          name = "custombootrstrap_test2"
          path = "s3://${aws_s3_bucket.bucketlogs.bucket}/bootstrap-actions/master/configure-test2.sh"
        },
      ]

答案 1 :(得分: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"
  },
]