@lpezet/hpcc-cluster
Version:
HPCC Cluster management in JS
158 lines (151 loc) • 4.56 kB
YAML
AWSTemplateFormatVersion: '2010-09-09'
Description: HPCC Cluster node (Master, Support or Slave).
Parameters:
ParamNodeName:
Description: Node name
Type: String
ParamPrivateIpAddress:
Description: Private IP Address
Type: String
Resources:
HPCCCluster:
Type: AWS::EC2::Instance
Metadata:
Comment1: HPCC Systems Node
Comment2: Install and Configure HPCC Node
AWS::CloudFormation::Init:
configSets:
default:
- ConfigSet: Basic
#if( $Node.ConfigSets && ! $Node.ConfigSets.isEmpty() )
- ConfigSet: AddOns
#end
Basic:
- AWSBaseConfig
- BasePackages
- ClusterProperties
#if( $Node.ConfigSets && ! $Node.ConfigSets.isEmpty() )
AddOns:
#foreach( $ConfigSet in $Node.ConfigSets.entrySet() )
- ${ConfigSet.key}
#end
#end
BasePackages:
packages:
yum:
xfsprogs: []
ClusterProperties:
files:
/opt/hpcc-cluster/cluster.config:
mode: '000440'
owner: root
content: !Join
- ''
- - cluster_name=${Cluster.Name}
- |+
- aws_username=${AWS.Username}
- |+
- cluster_region=
- !Ref 'AWS::Region'
- |+
group: root
AWSBaseConfig:
files:
/etc/aws/.aws-stack.properties:
mode: '000440'
owner: root
content: !Join
- ''
- - stack_name=
- !Ref 'AWS::StackId'
- |+
- resource=HPCCCluster
- |+
- region=
- !Ref 'AWS::Region'
- |+
group: root
# ----------------------------------------------------------------------------------
# AddOns
# ----------------------------------------------------------------------------------
#foreach( $ConfigSet in $Node.ConfigSets.entrySet() )
${ConfigSet.key}:
#end
Properties:
ImageId: ${Instance.ImageId}
InstanceType: ${Instance.Type}
KeyName: ${Instance.KeyName}
NetworkInterfaces:
- AssociatePublicIpAddress: true
DeviceIndex: 0
SubnetId: ${Vpc.SubnetId}
GroupSet:
- ${Vpc.SecurityGroupId}
PrivateIpAddress:
Ref: ParamPrivateIpAddress
IamInstanceProfile: #lastpart($Instance.IamRole, '/')
EbsOptimized: true
BlockDeviceMappings:
- DeviceName: /dev/xvda
Ebs:
DeleteOnTermination: true
VolumeSize: '8'
VolumeType: gp2
#foreach( $vol in $Node.Volumes )
#if( $vol.Type != 'ephemeral' )
- DeviceName: ${vol.DeviceName}
Ebs:
DeleteOnTermination: true
#if( $vol.SnapshotId )
SnapshotId: ${vol.SnapshotId}
#else
VolumeSize: '${vol.Size}'
Encrypted: #default($vol.Encrypted,"false")
#if($vol.Encrypted)
KmsKeyId: '#default($vol.EncryptionKey,"aws/ebs")'
#end
#end
VolumeType: #default($vol.Type,"gp2")
#if( $vol.Type == 'io1' )
Iops: ${vol.Iops}
#end
#end
#end
UserData:
Fn::Base64:
!Sub |
#!/bin/bash -xe
yum update -y
yum install -y aws-cfn-bootstrap
# Install the files and packages from the metadata
/opt/aws/bin/cfn-init -v --stack \${AWS::StackName} --resource HPCCCluster --region \${AWS::Region}
# Signal the status from cfn-init
/opt/aws/bin/cfn-signal -e $? --stack \${AWS::StackName} --resource HPCCCluster --region \${AWS::Region}
Tags:
- Value:
Fn::Join:
- '-'
- - ${Cluster.Name}
- Ref: ParamNodeName
Key: Name
CreationPolicy:
ResourceSignal:
Timeout: PT15M
Outputs:
InstanceId:
Description: Instance Id
Value:
Ref: HPCCCluster
PrivateIP:
Description: Private IP
Value:
Fn::GetAtt:
- HPCCCluster
- PrivateIp
PublicIP:
Description: Public IP
Value:
Fn::GetAtt:
- HPCCCluster
- PublicIp