AWSTemplateFormatVersion: '2010-09-09' Description: This template deploys Autodesk Forge Auto Scaling launch configuration for Node.js runtime. (qs-1s22alebk) Metadata: cfn-lint: { config: { ignore_checks: [W9002, W9003, W9006] } } Parameters: KeyPairName: Description: The name of an existing public/private key pair, which allows you to securely connect to your instance after it launches. Type: AWS::EC2::KeyPair::KeyName ForgeNodeInstanceType: AllowedValues: - t2.nano - t2.micro - t2.small - t2.medium - t2.large - t2.xlarge - t2.2xlarge - t3.nano - t3.micro - t3.small - t3.medium - t3.large - t3.xlarge - t3.2xlarge - m5.large - m5.xlarge - m5.2xlarge - m5.4xlarge ConstraintDescription: Must contain valid instance type Default: t2.large Description: Amazon EC2 instance type for the Autodesk Forge instances. Type: String ForgeAppName: Default: forge-viewmodels-nodejs-aws Description: The name of the zip file that contains the packaged Forge application, without the .zip extension. The two provided options are forge-viewmodels-nodejs-aws and forge-viewmodels-netcore-aws. To deploy a custom application, you would need to deploy this Quick Start from your own private S3 bucket and add your custom package in the packages directory. Type: String ForgeClientIdSSMParameter: Description: Forge Client ID SSM parameter Type: AWS::SSM::Parameter::Name ForgeClientSecretSSMParameter: Description: Forge Client Secret SSM parameter Type: AWS::SSM::Parameter::Name LatestAmazonLinux2Id: Type: AWS::SSM::Parameter::Value Default: /aws/service/ami-amazon-linux-latest/amzn2-ami-hvm-x86_64-gp2 Description: Latest Amazon Linux 2 AMI ID from AWS Systems Manager Parameter Store. WorkloadSecurityGroup: Description: ID of the Forge workload security group (e.g., sg-7f16e910). Type: AWS::EC2::SecurityGroup::Id SetupRoleProfile: Description: Name of the instance profile applied to Forge instances Type: String ParentStack: Description: Name of the parent stack Type: String Toggle: Type: String AllowedValues: - 'true' - 'false' Description: Toggle to force rolling update QSS3BucketName: AllowedPattern: ^[0-9a-zA-Z]+([0-9a-zA-Z-]*[0-9a-zA-Z])*$ ConstraintDescription: Quick Start bucket name can include numbers, lowercase letters, uppercase letters, and hyphens (-). It cannot start or end with a hyphen (-). Default: aws-quickstart Description: S3 bucket name for the Quick Start assets. Quick Start bucket name can include numbers, lowercase letters, uppercase letters, and hyphens (-). It cannot start or end with a hyphen (-). Type: String QSS3KeyPrefix: AllowedPattern: ^[0-9a-zA-Z-/]*$ ConstraintDescription: Quick Start key prefix can include numbers, lowercase letters, uppercase letters, hyphens (-), and forward slash (/). Default: quickstart-autodesk-forge/ Description: S3 key prefix for the Quick Start assets. Quick Start key prefix can include numbers, lowercase letters, uppercase letters, hyphens (-), and forward slash (/). Type: String Conditions: UsingDefaultBucket: !Equals - !Ref 'QSS3BucketName' - aws-quickstart Resources: WorkloadASLaunchConfig: Type: AWS::AutoScaling::LaunchConfiguration Metadata: AWS::CloudFormation::Init: configSets: quickstart: - install - configure - cleanup install: {} configure: {} cleanup: {} Properties: KeyName: !Ref 'KeyPairName' ImageId: !Ref 'LatestAmazonLinux2Id' InstanceMonitoring: true IamInstanceProfile: !Ref 'SetupRoleProfile' InstanceType: !Ref 'ForgeNodeInstanceType' SecurityGroups: - !Ref 'WorkloadSecurityGroup' UserData: !Base64 Fn::Sub: - | #!/bin/bash -ex exec > >(tee /var/log/user-data.log|logger -t user-data -s 2>/dev/console) 2>&1 # update AWS cfn bootsrap # yum update -y aws-cfn-bootstrap curl --silent --location https://rpm.nodesource.com/setup_14.x | bash - yum -y install nodejs # install pm2 to restart node app npm i -g pm2@2.4.3 echo export FORGE_AWS_FLAG=1 >> /etc/profile echo export AWS_REGION=${AWS::Region} >> /etc/profile echo export FORGE_CLIENT_ID=${ForgeClientIdSSMParameter} >> /etc/profile echo export FORGE_CLIENT_SECRET=${ForgeClientSecretSSMParameter} >> /etc/profile echo export FORGE_APP_NAME=${ForgeAppName} >> /etc/profile source /etc/profile ${Param1}$FORGE_APP_NAME.zip . echo toggle: ${Toggle} unzip $FORGE_APP_NAME.zip cd $FORGE_APP_NAME pwd npm install pm2 start /$FORGE_APP_NAME/start.js -i 0 --name forge-node-app # Signal the status from cfn-init /opt/aws/bin/cfn-signal -e $? --stack ${ParentStack} --resource WorkloadAutoScalingGroup --region ${AWS::Region} - Param1: !Sub - aws s3 cp s3://${S3Bucket}/${QSS3KeyPrefix}packages/ - S3Bucket: !If - UsingDefaultBucket - !Sub '${QSS3BucketName}-${AWS::Region}' - !Ref 'QSS3BucketName' Outputs: WorkloadASLaunchConfig: Description: Forge Server Auto Scaling launch configuration Value: !Ref 'WorkloadASLaunchConfig'