2016-03-24 09:30
浏览 75


I want to create EMR clusters using AWS SDK for Go, but I can't find a way in the official documentation.

Package: emr — AWS SDK for Go

Cound you please help me with a detailed code?

图片转代码服务由CSDN问答提供 功能建议

我想使用适用于Go的AWS开发工具包创建EMR集群,但是我在官方文档中找不到方法 。

包装 :emr —适用于Go的AWS开发工具包


  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

1条回答 默认 最新

  • doupa8922 2016-05-10 07:08

    Actually, coming up to the same problem, there is a way which is described in the documentation. For me, it was not straightforward as well because the wording is different. It appears that a "running a job flow" is basically what equals creating a cluster and adding steps to it.

    So what you want is the function RunJobFlow found here:


    So, a simple code example which creates a cluster without steps is the following (make sure you have correct credentials configured):

    package main
    import (
    func main() {
        sess := session.New(&aws.Config{Region: aws.String("eu-west-1")})
        svc := emr.New(sess)
        params := &emr.RunJobFlowInput{
            Instances: &emr.JobFlowInstancesConfig{ // Required
                Ec2KeyName:                    aws.String("keyname"),
                HadoopVersion:                 aws.String("2.7.2"),
                InstanceCount:                 aws.Int64(1),
                KeepJobFlowAliveWhenNoSteps: aws.Bool(true),
                MasterInstanceType:          aws.String("m1.medium"),
                Placement: &emr.PlacementType{
                    AvailabilityZone: aws.String("eu-west-1a"), // Required
                TerminationProtected:       aws.Bool(true),
            Name:           aws.String("Go Test Cluster"), // Required
            Applications: []*emr.Application{
                { // Required
                    Name:    aws.String("Ganglia"),
                    Name: aws.String("Spark"),
                // More values...
            JobFlowRole: aws.String("EMR_EC2_DefaultRole"),
            LogUri:      aws.String("s3://aws-logs-0000000000-eu-west-1/elasticmapreduce/"),
            ReleaseLabel: aws.String("emr-4.6.0"),
            ServiceRole:  aws.String("EMR_DefaultRole"),
            VisibleToAllUsers: aws.Bool(true),
        resp, err := svc.RunJobFlow(params)
        if err != nil {
            // Print the error, cast err to awserr.Error to get the Code and
            // Message from an error.
        // Pretty-print the response data.
    点赞 评论

相关推荐 更多相似问题