AWSTemplateFormatVersion: "2010-09-09" Description: Provides configuration for a Deadline license server instance. Parameters: PrivateSubnet1: Type: AWS::EC2::Subnet::Id LicenseServerSecurityGroup: Type: AWS::EC2::SecurityGroup::Id InstanceType: Type: String InstanceAMI: Type: AWS::EC2::Image::Id Environment: Type: String EC2InstanceProfile: Type: String LicenseServerVersion: Type: String DeadlineLicense: Type: String NoEcho: true ArtefactBucketName: Type: String Resources: LicenseServerInstance: CreationPolicy: ResourceSignal: Count: 1 Timeout: PT10M Type: AWS::EC2::Instance Metadata: AWS::CloudFormation::Init: configSets: dcc_install: - instance_prep - artefacts_download - app_install instance_prep: files: /opt/scripts/ec2-mount-ebs-volume.sh: content: | #!/usr/bin/env bash mkdir -p /data while [ ! -b $(readlink -f /dev/xvdh) ]; do echo "waiting for device /dev/xvdh"; sleep 5 ; done blkid $(readlink -f /dev/xvdh) || mkfs -t ext4 $(readlink -f /dev/xvdh) e2label $(readlink -f /dev/xvdh) dcc-data grep -q ^LABEL=dcc-data /etc/fstab || echo 'LABEL=dcc-data /data ext4 defaults' >> /etc/fstab grep -q "^$(readlink -f /dev/xvdh) /data " /proc/mounts || mount /data mode: "000755" owner: root group: root /etc/cfn/cfn-hup.conf: content: !Sub | [main] stack=${AWS::StackId} region=${AWS::Region} interval=1 mode: "000400" owner: root group: root /etc/cfn/hooks.d/cfn-auto-reloader.conf: content: !Sub | [cfn-auto-reloader-hook] triggers=post.update path=Resources.LicenseServerInstance.Metadata.AWS::CloudFormation::Init action=/opt/aws/bin/cfn-init -v --stack ${AWS::StackName} --resource LicenseServerInstance --configsets dcc_install --region ${AWS::Region} runas=root mode: "000400" owner: root group: root commands: 01-mount-ebs-volume: command: sh /opt/scripts/ec2-mount-ebs-volume.sh > /opt/scripts/ec2-mount-ebs-volume.log 2>&1 test: test -x /opt/scripts/ec2-mount-ebs-volume.sh # check if filename exists and is executable ignoreErrors: false services: sysvinit: cfn-hup: enabled: true ensureRunning: true files: - /etc/cfn/cfn-hup.conf - /etc/cfn/hooks.d/cfn-auto-reloader.conf amazon-ssm-agent: enabled: true ensureRunning: true artefacts_download: sources: /data/thinkbox: !Sub https://${ArtefactBucketName}.s3.amazonaws.com/ThinkboxLicenseServer-${LicenseServerVersion}-linux-x64-installer.zip app_install: files: /data/thinkbox/license.lic: content: !Sub | ${DeadlineLicense} commands: 01-set_permissions: command: chmod 500 /data/thinkbox/ThinkboxLicenseServer* 02-install_license_server: command: | ls /data/thinkbox | grep ThinkboxLicenseServer | \ (read data; /data/thinkbox/$data \ --mode text \ --licenseFile /data/thinkbox/license.lic) ignoreErrors: true Properties: BlockDeviceMappings: - DeviceName: /dev/xvdh Ebs: VolumeSize: 100 VolumeType: gp2 Encrypted: true DeleteOnTermination: true IamInstanceProfile: !Ref EC2InstanceProfile ImageId: !Ref InstanceAMI InstanceType: !Ref InstanceType SecurityGroupIds: - !Ref LicenseServerSecurityGroup SubnetId: !Ref PrivateSubnet1 Tags: - Key: Name Value: deadline-license-server - Key: Environment Value: !Ref Environment UserData: !Base64 Fn::Sub: | #!/bin/bash -xe # Update aws-cfn-bootstrap to the latest yum install -y aws-cfn-bootstrap # Call cfn-init script to install files and packages /opt/aws/bin/cfn-init -v --stack ${AWS::StackName} --resource LicenseServerInstance --configsets dcc_install --region ${AWS::Region} # Call cfn-signal script to send a signal with exit code /opt/aws/bin/cfn-signal --exit-code $? --stack ${AWS::StackName} --resource LicenseServerInstance --region ${AWS::Region} Outputs: LicenseServerInstancePrivateIp: Value: !GetAtt LicenseServerInstance.PrivateIp DeadlineLicense: Value: !Ref DeadlineLicense