Set Subnet ID and EC2 Key Name in EMR Cluster Config via Step Functions.

huangapple go评论71阅读模式
英文:

Set Subnet ID and EC2 Key Name in EMR Cluster Config via Step Functions

问题

截止到2019年11月,AWS Step Functions原生支持编排EMR集群。因此,我们正在尝试配置一个集群并在其上运行一些作业。

我们找不到关于如何设置子网ID以及集群中EC2实例使用的密钥名称的任何文档。是否有这样的可能性?

截止目前,我们的创建集群步骤如下所示:

"States": {
  "Create an EMR cluster": {
    "Type": "Task",
    "Resource": "arn:aws:states:::elasticmapreduce:createCluster.sync",
    "Parameters": {
      "Name": "TestCluster",
      "VisibleToAllUsers": true,
      "ReleaseLabel": "emr-5.26.0",
      "Applications": [
        { "Name": "spark" }
      ],
      "ServiceRole": "SomeRole",
      "JobFlowRole": "SomeInstanceProfile",
      "LogUri": "s3://some-logs-bucket/logs",
      "Instances": {
        "KeepJobFlowAliveWhenNoSteps": true,
        "InstanceFleets": [
          {
            "Name": "MasterFleet",
            "InstanceFleetType": "MASTER",
            "TargetOnDemandCapacity": 1,
            "InstanceTypeConfigs": [
              {
                "InstanceType": "m3.2xlarge"
              }
            ]
          },
          {
            "Name": "CoreFleet",
            "InstanceFleetType": "CORE",
            "TargetSpotCapacity": 2,
            "InstanceTypeConfigs": [
              {
                "InstanceType": "m3.2xlarge",
                "BidPriceAsPercentageOfOnDemandPrice": 100
              }
            ]
          }
        ]
      }
    },
    "ResultPath": "$.cluster",
    "End": "true"
  }
}

一旦我们尝试在Parameters的任何子对象中或Parameter本身中添加"SubnetId"键,我们会收到错误消息:

Invalid State Machine Definition: 'SCHEMA_VALIDATION_FAILED: The field "SubnetId" is not supported by Step Functions at /States/Create an EMR cluster/Parameters' (Service: AWSStepFunctions; Status Code: 400; Error Code: InvalidDefinition;
英文:

As of November 2019 AWS Step Function has native support for orchestrating EMR Clusters. Hence we are trying to configure a Cluster and run some jobs on it.

We could not find any documentation on how to set the SubnetId as well as the Key Name used for the EC2 instances in the cluster. Is there any such possibility?

As of now our create cluster step looks as following:

"States": {
          "Create an EMR cluster": {
            "Type": "Task",
            "Resource": "arn:aws:states:::elasticmapreduce:createCluster.sync",
            "Parameters": {
              "Name": "TestCluster",
              "VisibleToAllUsers": true,
              "ReleaseLabel": "emr-5.26.0",
              "Applications": [
                { "Name": "spark" }
              ],
              "ServiceRole": "SomeRole",
              "JobFlowRole": "SomeInstanceProfile",
              "LogUri": "s3://some-logs-bucket/logs",
              "Instances": {
                "KeepJobFlowAliveWhenNoSteps": true,
                "InstanceFleets": [
                  {
                    "Name": "MasterFleet",
                    "InstanceFleetType": "MASTER",
                    "TargetOnDemandCapacity": 1,
                    "InstanceTypeConfigs": [
                      {
                        "InstanceType": "m3.2xlarge"
                      }
                    ]
                  },
                  {
                    "Name": "CoreFleet",
                    "InstanceFleetType": "CORE",
                    "TargetSpotCapacity": 2,
                    "InstanceTypeConfigs": [
                      {
                        "InstanceType": "m3.2xlarge",
                        "BidPriceAsPercentageOfOnDemandPrice": 100                         }
                    ]
                  }
                ]
              }
            },
            "ResultPath": "$.cluster",
            "End": "true"
          }
}

As soon as we try to add "SubnetId" key in any of the subobjects in Parameters, or in Parameter itself we get the error:

Invalid State Machine Definition: 'SCHEMA_VALIDATION_FAILED: The field "SubnetId" is not supported by Step Functions at /States/Create an EMR cluster/Parameters' (Service: AWSStepFunctions; Status Code: 400; Error Code: InvalidDefinition;

答案1

得分: 3

以下是您要翻译的内容:

根据emr integration中的SF文档,我们可以看到createCluster.sync使用emr API RunJobFlow。在RunJobFlow中,我们可以指定位于$.Instances.Ec2KeyName和$.Instances.Ec2SubnetId路径下的Ec2KeyName和Ec2SubnetId。

话虽如此,我成功创建了一个具有以下定义的状态机(顺便说一句,您的定义中有一个语法错误,"End": "true"应为"End": true)

{
  "Comment": "使用Pass状态的Amazon States语言的Hello World示例",
  "StartAt": "创建EMR集群",
  "States": {
    "创建EMR集群": {
      "Type": "Task",
      "Resource": "arn:aws:states:::elasticmapreduce:createCluster.sync",
      "Parameters": {
        "Name": "TestCluster",
        "VisibleToAllUsers": true,
        "ReleaseLabel": "emr-5.26.0",
        "Applications": [
          {
            "Name": "spark"
          }
        ],
        "ServiceRole": "SomeRole",
        "JobFlowRole": "SomeInstanceProfile",
        "LogUri": "s3://some-logs-bucket/logs",
        "Instances": {
          "Ec2KeyName": "ENTER_EC2KEYNAME_HERE",
          "Ec2SubnetId": "ENTER_EC2SUBNETID_HERE",
          "KeepJobFlowAliveWhenNoSteps": true,
          "InstanceFleets": [
            {
              "Name": "MasterFleet",
              "InstanceFleetType": "MASTER",
              "TargetOnDemandCapacity": 1,
              "InstanceTypeConfigs": [
                {
                  "InstanceType": "m3.2xlarge"
                }
              ]
            },
            {
              "Name": "CoreFleet",
              "InstanceFleetType": "CORE",
              "TargetSpotCapacity": 2,
              "InstanceTypeConfigs": [
                {
                  "InstanceType": "m3.2xlarge",
                  "BidPriceAsPercentageOfOnDemandPrice": 100
                }
              ]
            }
          ]
        }
      },
      "ResultPath": "$.cluster",
      "End": true
    }
  }
}

英文:

Referring to the SF docs on the emr integration we can see that createCluster.sync uses the emr API RunJobFlow. In RunJobFlow we can specify the Ec2KeyName and Ec2SubnetId located at the paths $.Instances.Ec2KeyName and $.Instances.Ec2SubnetId.

With that said I managed to create a State Machine with the following definition (on a side note, your definition had a syntax error with "End": "true", which should be "End": true)

{
"Comment": "A Hello World example of the Amazon States Language using Pass states",
"StartAt": "Create an EMR cluster",
"States": {
    "Create an EMR cluster": {
        "Type": "Task",
        "Resource": "arn:aws:states:::elasticmapreduce:createCluster.sync",
        "Parameters": {
            "Name": "TestCluster",
            "VisibleToAllUsers": true,
            "ReleaseLabel": "emr-5.26.0",
            "Applications": [
                {
                    "Name": "spark"
                }
            ],
            "ServiceRole": "SomeRole",
            "JobFlowRole": "SomeInstanceProfile",
            "LogUri": "s3://some-logs-bucket/logs",
            "Instances": {
                "Ec2KeyName": "ENTER_EC2KEYNAME_HERE",
                "Ec2SubnetId": "ENTER_EC2SUBNETID_HERE",
                "KeepJobFlowAliveWhenNoSteps": true,
                "InstanceFleets": [
                    {
                        "Name": "MasterFleet",
                        "InstanceFleetType": "MASTER",
                        "TargetOnDemandCapacity": 1,
                        "InstanceTypeConfigs": [
                            {
                                "InstanceType": "m3.2xlarge"
                            }
                        ]
                    },
                    {
                        "Name": "CoreFleet",
                        "InstanceFleetType": "CORE",
                        "TargetSpotCapacity": 2,
                        "InstanceTypeConfigs": [
                            {
                                "InstanceType": "m3.2xlarge",
                                "BidPriceAsPercentageOfOnDemandPrice": 100
                            }
                        ]
                    }
                ]
            }
        },
        "ResultPath": "$.cluster",
        "End": true
    }
}
}

huangapple
  • 本文由 发表于 2020年1月6日 22:23:23
  • 转载请务必保留本文链接:https://go.coder-hub.com/59613750.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定