Created
May 24, 2017 23:27
-
-
Save kangks/bd867e18a9abeb06b8fc3f3e6968e92f to your computer and use it in GitHub Desktop.
AWS CloudFormation template to create EMR-5.1.0 cluster
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"AWSTemplateFormatVersion": "2010-09-09", | |
"Description": "Create AMR Cluster", | |
"Parameters": { | |
"ProductParam": { | |
"Description": "The EMR Product tag", | |
"Type": "String", | |
"Default": "aProductParam", | |
"MinLength": "3", | |
"MaxLength": "50", | |
"AllowedPattern": "^[a-zA-Z0-9][a-zA-Z0-9.-]*" | |
}, | |
"ChargeCodeParam": { | |
"Description": "The EMR ChargeCode tag", | |
"Type": "String", | |
"Default": "aChargeCodeParam", | |
"MinLength": "3", | |
"MaxLength": "50", | |
"AllowedPattern": "^[a-zA-Z0-9][a-zA-Z0-9.-]*" | |
}, | |
"EmrLogsBucketNameParam": { | |
"Description": "The EMR logs S3 bucket name", | |
"Type": "String", | |
"Default": "emr-logs", | |
"MinLength": "3", | |
"MaxLength": "50", | |
"AllowedPattern": "^[a-z0-9][a-z0-9.-]*" | |
}, | |
"Ec2KeyNameParam":{ | |
"Description": "Name of an existing EC2 KeyPair to enable SSH access to the instance", | |
"Type": "AWS::EC2::KeyPair::KeyName", | |
"ConstraintDescription": "must be the name of an existing EC2 KeyPair." | |
} | |
}, | |
"Outputs": { | |
"OutEMRTaskInstanceConfig": { | |
"Value": { | |
"Ref": "EMRTaskInstanceConfig" | |
} | |
}, | |
"OutEmrLogsS3Bucket": { | |
"Value": { | |
"Ref": "EmrLogsS3Bucket" | |
} | |
}, | |
"OutEMRClusterEC2RoleInstance": { | |
"Value": { | |
"Ref": "EMRClusterEC2RoleInstance" | |
} | |
} | |
}, | |
"Resources": { | |
"EmrLogsS3Bucket": { | |
"Type": "AWS::S3::Bucket", | |
"Properties": { | |
"BucketName": { | |
"Fn::Join": [ | |
"-", | |
[ | |
{ | |
"Ref": "AWS::AccountId" | |
}, | |
{ | |
"Ref": "EmrLogsBucketNameParam" | |
} | |
] | |
] | |
}, | |
"AccessControl": "Private" | |
}, | |
"DeletionPolicy" : "Retain" | |
}, | |
"EMRClusterEC2Role": { | |
"Type": "AWS::IAM::Role", | |
"Properties": { | |
"AssumeRolePolicyDocument": { | |
"Version": "2012-10-17", | |
"Statement": [ | |
{ | |
"Effect": "Allow", | |
"Action": "sts:AssumeRole", | |
"Principal": { | |
"Service": "ec2.amazonaws.com" | |
} | |
} | |
] | |
}, | |
"ManagedPolicyArns": [ | |
"arn:aws:iam::aws:policy/service-role/AmazonElasticMapReduceforEC2Role" | |
], | |
"RoleName": "EMRClusterEC2Role" | |
} | |
}, | |
"EMRClusterEC2RoleInstance": { | |
"Type": "AWS::IAM::InstanceProfile", | |
"Properties": { | |
"Path": "/", | |
"Roles": [ | |
{"Ref":"EMRClusterEC2Role"} | |
] | |
}, | |
"DependsOn": [ | |
"EMRClusterEC2Role" | |
] | |
}, | |
"EMRServiceRole": { | |
"Type": "AWS::IAM::Role", | |
"Properties": { | |
"AssumeRolePolicyDocument": { | |
"Version": "2012-10-17", | |
"Statement": [ | |
{ | |
"Effect": "Allow", | |
"Action": "sts:AssumeRole", | |
"Principal": { | |
"Service": "elasticmapreduce.amazonaws.com" | |
} | |
} | |
] | |
}, | |
"ManagedPolicyArns": [ | |
"arn:aws:iam::aws:policy/service-role/AmazonElasticMapReduceRole" | |
], | |
"RoleName": "EMRServiceRole" | |
} | |
}, | |
"EMRCluster": { | |
"Type": "AWS::EMR::Cluster", | |
"Properties": { | |
"Name": "EMRCluster", | |
"Instances": { | |
"MasterInstanceGroup": { | |
"InstanceCount": 1, | |
"InstanceType": "m3.xlarge", | |
"Market": "ON_DEMAND", | |
"Name": "Master" | |
}, | |
"CoreInstanceGroup": { | |
"InstanceCount": 1, | |
"InstanceType": "m3.xlarge", | |
"Market": "ON_DEMAND", | |
"Name": "Core" | |
}, | |
"Ec2KeyName": {"Ref":"Ec2KeyNameParam"}, | |
"TerminationProtected": false | |
}, | |
"ReleaseLabel": "emr-5.1.0", | |
"Applications": [ | |
{ | |
"Name": "Spark" | |
}, | |
{ | |
"Name": "Hadoop" | |
}, | |
{ | |
"Name": "Hive" | |
}, | |
{ | |
"Name": "Sqoop" | |
} | |
], | |
"Tags": [ | |
{ | |
"Key": "Product", | |
"Value": { | |
"Ref": "ProductParam" | |
} | |
}, | |
{ | |
"Key": "ChargeCode", | |
"Value": { | |
"Ref": "ChargeCodeParam" | |
} | |
} | |
], | |
"LogUri": { | |
"Fn::Join": [ | |
"", | |
[ | |
"s3://", | |
{ | |
"Ref": "EmrLogsS3Bucket" | |
} | |
] | |
] | |
}, | |
"JobFlowRole": {"Fn::GetAtt" : ["EMRClusterEC2RoleInstance", "Arn"] }, | |
"ServiceRole": "EMRServiceRole" | |
}, | |
"DependsOn": [ | |
"EMRClusterEC2Role", | |
"EMRServiceRole", | |
"EMRClusterEC2RoleInstance", | |
"EmrLogsS3Bucket" | |
] | |
}, | |
"EMRTaskInstanceConfig": { | |
"Type": "AWS::EMR::InstanceGroupConfig", | |
"Properties": { | |
"InstanceCount": 1, | |
"InstanceType": "m3.xlarge", | |
"InstanceRole": "TASK", | |
"Market": "ON_DEMAND", | |
"Name": "EMRTaskInstanceConfig", | |
"JobFlowId": { | |
"Ref": "EMRCluster" | |
} | |
}, | |
"DependsOn": [ | |
"EMRCluster" | |
] | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment