Add KeyName to EMR cluster in Cloud Formation template

1.1k views Asked by At

I am creating an AWS EMR cluster running Spark using a Cloud Formation template. I am using Cloud Formation because that's how we create reproducible environments for our applications.

When I create the cluster from the web dashboard one of the options is to add a Key Pair. This is necessary in order to access via ssh the nodes of the cluster. http://docs.aws.amazon.com/ElasticMapReduce/latest/DeveloperGuide/EMR_CreateJobFlow.html

I can't see how to do the same when using Cloud Formation templates. The template structure (see below) doesn't have the same attribute.

Type: "AWS::EMR::Cluster"
Properties: 
  AdditionalInfo: JSON object
  Applications:
    - Applications
  BootstrapActions:
    - Bootstrap Actions
  Configurations:
    - Configurations
  Instances:
    JobFlowInstancesConfig
  JobFlowRole: String
  LogUri: String
  Name: String
  ReleaseLabel: String
  ServiceRole: String
  Tags:
    - Resource Tag
  VisibleToAllUsers: Boolean

http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-emr-cluster.html#d0e76479

I had a loook to the attribute JobFlowRole that is a reference to an instance profile (http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-iam-instanceprofile.html). Again, no sign of the KeyName.

Did anyone solved this problem before?

Thanks, Marco

1

There are 1 answers

0
Marco Bonvini On

I solved this problem. I was just confused by the lack of naming consistency in Cloud Formation templates. What is generally referred as KeyName becomes Ec2KeyName under the JobFlowInstancesConfig.

http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-emr-cluster-jobflowinstancesconfig.html#cfn-emr-cluster-jobflowinstancesconfig-ec2keyname