Skip to content

Instantly share code, notes, and snippets.

@JWDobken
Last active November 13, 2019 13:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JWDobken/6b29f501ec24a763477edb8128b1c4d0 to your computer and use it in GitHub Desktop.
Save JWDobken/6b29f501ec24a763477edb8128b1c4d0 to your computer and use it in GitHub Desktop.
AWS custom templates
{
"Description": "Custom Ranger template for an EMR cluster",
"Parameters": {
"VPC": {
"Description": "VPC ID for creating the EMR cluster",
"Type": "AWS::EC2::VPC::Id"
},
"Subnet": {
"Description": "Subnet ID for creating the EMR cluster",
"Type": "AWS::EC2::Subnet::Id"
},
"KeyName": {
"Description": "Name of an existing EC2 KeyPair to enable SSH to the instances",
"Type": "AWS::EC2::KeyPair::KeyName"
},
"InstanceType": {
"Description": "Instance type of the Ranger Server",
"Type": "String",
"Default": "m4.xlarge",
"AllowedValues": [
"m5.large",
"m5.xlarge",
"m5.2xlarge",
"m5.4xlarge",
"m5.10xlarge"
],
"ConstraintDescription": "must be a valid EC2 instance type."
},
"myDirectoryIPAddress": {
"Description": "IP Address of the SimpleAD server",
"Type": "String"
},
"myDirectoryBaseDN": {
"Description": "Base DN SimpleAD server",
"Type": "String",
"Default": "dc=corp,dc=emr,dc=local",
"AllowedValues": [
"dc=corp,dc=emr,dc=local"
]
},
"myDirectoryBindUser": {
"Description": "BindUser SimpleAD server",
"Type": "String",
"Default": "binduser@corp.emr.local",
"AllowedValues": [
"binduser@corp.emr.local"
]
},
"myDirectoryBindPassword": {
"Description": "BindPassword SimpleAD server",
"Type": "String",
"Default": "Bind@User123",
"AllowedValues": [
"Bind@User123"
]
},
"rangerVersion": {
"Description": "RangerVersion",
"Type": "String",
"Default": "2.0",
"AllowedValues": [
"0.6",
"0.7",
"1.0",
"1.2",
"2.0"
]
},
"s3artifactsRepoHttp": {
"Default": "https://s3.amazonaws.com/aws-bigdata-blog/artifacts/aws-blog-emr-ranger",
"Description": "Git Repo URL for this blog.",
"Type": "String"
}
},
"Mappings": {
"AWSInstanceType2Arch": {
"m5.large": {
"Arch": "HVM64"
},
"m5.xlarge": {
"Arch": "HVM64"
},
"m5.2xlarge": {
"Arch": "HVM64"
},
"m5.4xlarge": {
"Arch": "HVM64"
},
"m5.10xlarge": {
"Arch": "HVM64"
}
},
"AWSInstanceType2NATArch": {
"m5.large": {
"Arch": "NATHVM64"
},
"m5.xlarge": {
"Arch": "NATHVM64"
},
"m5.2xlarge": {
"Arch": "NATHVM64"
},
"m5.4xlarge": {
"Arch": "NATHVM64"
},
"m5.10xlarge": {
"Arch": "NATHVM64"
}
},
"AWSRegionArch2AMI": {
"us-east-1": {
"PV64": "ami-2a69aa47",
"HVM64": "ami-6869aa05",
"HVMG2": "ami-2e5e9c43"
},
"us-west-2": {
"PV64": "ami-7f77b31f",
"HVM64": "ami-7172b611",
"HVMG2": "ami-83b770e3"
},
"us-west-1": {
"PV64": "ami-a2490dc2",
"HVM64": "ami-31490d51",
"HVMG2": "ami-fd76329d"
},
"eu-west-1": {
"PV64": "ami-4cdd453f",
"HVM64": "ami-f9dd458a",
"HVMG2": "ami-b9bd25ca"
},
"eu-central-1": {
"PV64": "ami-6527cf0a",
"HVM64": "ami-ea26ce85",
"HVMG2": "ami-7f04ec10"
},
"ap-northeast-1": {
"PV64": "ami-3e42b65f",
"HVM64": "ami-374db956",
"HVMG2": "ami-e0ee1981"
},
"ap-northeast-2": {
"PV64": "NOT_SUPPORTED",
"HVM64": "ami-2b408b45",
"HVMG2": "NOT_SUPPORTED"
},
"ap-southeast-1": {
"PV64": "ami-df9e4cbc",
"HVM64": "ami-a59b49c6",
"HVMG2": "ami-0cb5676f"
},
"ap-southeast-2": {
"PV64": "ami-63351d00",
"HVM64": "ami-dc361ebf",
"HVMG2": "ami-a71c34c4"
},
"sa-east-1": {
"PV64": "ami-1ad34676",
"HVM64": "ami-6dd04501",
"HVMG2": "NOT_SUPPORTED"
},
"cn-north-1": {
"PV64": "ami-77559f1a",
"HVM64": "ami-8e6aa0e3",
"HVMG2": "NOT_SUPPORTED"
}
}
},
"Resources": {
"sgRangerAdminServer": {
"Type": "AWS::EC2::SecurityGroup",
"Properties": {
"GroupDescription": "Open Up all Ranger Server ports",
"VpcId": {
"Ref": "VPC"
},
"SecurityGroupIngress": [
{
"IpProtocol": "tcp",
"FromPort": "6080",
"ToPort": "6080",
"CidrIp": "0.0.0.0/0"
},
{
"IpProtocol": "tcp",
"FromPort": "8983",
"ToPort": "8983",
"CidrIp": "0.0.0.0/0"
},
{
"IpProtocol": "tcp",
"FromPort": "22",
"ToPort": "22",
"CidrIp": "0.0.0.0/0"
}
]
}
},
"myEC2": {
"Type": "AWS::EC2::Instance",
"Metadata": {
"AWS::CloudFormation::Init": {
"configSets": {
"InstallRangerServer": [
"RangerServer"
]
},
"RangerServer": {
"commands": {
"installrangerserver": {
"command": {
"Fn::Join": [
"",
[
"bash /tmp/install-ranger-admin-server.sh ",
{
"Ref": "myDirectoryIPAddress"
},
" ",
{
"Ref": "myDirectoryBaseDN"
},
" ",
{
"Ref": "myDirectoryBindUser"
},
" ",
{
"Ref": "myDirectoryBindPassword"
},
" ",
{
"Ref": "rangerVersion"
},
" ",
{
"Ref": "s3artifactsRepoHttp"
},
" > create-ranger-server-output.log \n"
]
]
}
}
}
}
}
},
"Properties": {
"SubnetId": {
"Ref": "Subnet"
},
"SecurityGroupIds": [
{
"Ref": "sgRangerAdminServer"
}
],
"ImageId": {
"Fn::FindInMap": [
"AWSRegionArch2AMI",
{
"Ref": "AWS::Region"
},
{
"Fn::FindInMap": [
"AWSInstanceType2Arch",
{
"Ref": "InstanceType"
},
"Arch"
]
}
]
},
"InstanceType": {
"Ref": "InstanceType"
},
"KeyName": {
"Ref": "KeyName"
},
"UserData": {
"Fn::Base64": {
"Fn::Join": [
"",
[
"#!/bin/bash\n",
"cd /tmp\n",
"wget ",
{
"Ref": "s3artifactsRepoHttp"
},
"/scripts/install-ranger-admin-server.sh\n",
"yum update aws-cfn-bootstrap\n",
"# Install the files and packages from the metadata\n",
"/opt/aws/bin/cfn-init ",
" --stack ",
{
"Ref": "AWS::StackName"
},
" --resource myEC2 ",
" --configsets InstallRangerServer ",
" --region ",
{
"Ref": "AWS::Region"
},
"\n"
]
]
}
},
"Tags": [
{
"Key": "Name",
"Value": "RangerServer"
}
]
}
}
},
"Outputs": {
"IPAddress": {
"Description": "IP address of the Ranger server",
"Value": {
"Fn::GetAtt": [
"myEC2",
"PrivateIp"
]
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment