Skip to content

Instantly share code, notes, and snippets.

@robnolen
Created May 31, 2018 00:14
Show Gist options
  • Save robnolen/fe82d472466c006e1cf68c9a612a1f70 to your computer and use it in GitHub Desktop.
Save robnolen/fe82d472466c006e1cf68c9a612a1f70 to your computer and use it in GitHub Desktop.
Parameters:
SubnetId:
Type: AWS::EC2::Subnet::Id
Description: "The list of SubnetIds, for at least two Availability Zones in the region in your Virtual Private Cloud (VPC)"
Default: "subnet-xxxxx"
AvailabilityZone:
Type: AWS::EC2::AvailabilityZone::Name
Description: "The availability zone to use. You may want to change this to find an AZ with the appropriate capacity."
Default: "us-gov-west-1a"
ImageId:
Type: AWS::EC2::Image::Id
Default: "ami-1234566"
Description: "Image ID for AMI"
InstanceType:
Type: String
Default: c4.8xlarge
AllowedValues:
- c4.xlarge
- c4.2xlarge
- c4.4xlarge
- c4.8xlarge
Description: "The EC2 instance type to use for all instances in the cluster."
KeyPair:
Type: AWS::EC2::KeyPair::KeyName
Description: "The EC2 KeyPair to launch the instances with."
Default: "mykey"
InstanceCount:
Type: Number
Description: "Number of EC2 instances to request in the Autoscaling group. This is in addition to the first instance."
MinValue: 0
MaxValue: 100
Default: 3
InstanceSecurityGroup:
Type: AWS::EC2::SecurityGroup::Id
Default: "sg-xxxxx"
Resources:
FirstInstance:
Type: AWS::EC2::Instance
Properties:
ImageId: !Ref ImageId
InstanceType: !Ref InstanceType
KeyName: !Ref KeyPair
PlacementGroupName: !Ref PlacementGroup
SecurityGroupIds:
- !Ref InstanceSecurityGroup
SubnetId: !Ref SubnetId
Tags:
- Key: Name
Value: "MyClusterTag"
UserData:
Fn::Base64: !Sub |
#!/bin/bash
# Set up the filesystem
mount -t nfs -o rsize=1048576,wsize=1048576,hard,timeo=600,retrans=2,_netdev 10.10.10.1:/media/datasets /efs
sleep 10
# selinux is enforcing and requires this change to allow NFS home directories.
setsebool -P use_nfs_home_dirs 1
#LSH START
# First instance only
# Populate the home folder
LaunchConfig:
Type: AWS::AutoScaling::LaunchConfiguration
Properties:
ImageId: !Ref ImageId
InstanceType: !Ref InstanceType
KeyName: !Ref KeyPair
SecurityGroups:
- !Ref InstanceSecurityGroup
UserData:
Fn::Base64: !Sub |
#!/bin/bash
# Set up the filesystem
mount -t nfs -o rsize=1048576,wsize=1048576,hard,timeo=600,retrans=2,_netdev 10.10.10.1:/media/datasets /efs
sleep 10
# selinux is enforcing and requires this change to allow NFS home directories.
setsebool -P use_nfs_home_dirs 1
#LSH START
# First instance only
# Populate the home folder
AutoScalingGroup:
Type: AWS::AutoScaling::AutoScalingGroup
Properties:
LaunchConfigurationName: !Ref LaunchConfig
PlacementGroup: !Ref PlacementGroup
MinSize: !Ref InstanceCount
MaxSize: !Ref InstanceCount
VPCZoneIdentifier:
- !Ref SubnetId
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment