--- AWSTemplateFormatVersion: '2010-09-09' Description: This template deploys Autodesk Forge Auto Scaling launch configuration for .NetCore runtime. (qs-1s23636dd) 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 ForgeClientIdSSMParameter: Description: Forge Client ID SSM parameter Type: AWS::SSM::Parameter::Name ForgeClientSecretSSMParameter: Description: Forge Client Secret SSM parameter Type: AWS::SSM::Parameter::Name ForgeCallbackUrlSSMParameter: Description: Forge Callback Url 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 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-bim360-integration/ 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 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: Fn::Base64: Fn::Join: - '' - - "#!/bin/bash -ex\n" - 'exec > >(tee /var/log/user-data.log|logger -t user-data -s 2>/dev/console) 2>&1 ' - "# update AWS cfn bootsrap\n" - "# yum update -y aws-cfn-bootstrap\n" - 'yum -y update ' - 'rpm -Uvh https://packages.microsoft.com/config/rhel/7/packages-microsoft-prod.rpm ' - "# install netcore sdk 2.2\n" - 'yum install -y dotnet-sdk-2.2 ' - echo export AWS_REGION= - Ref: AWS::Region - " >> /etc/profile\n" - echo export FORGE_CLIENT_ID= - Ref: ForgeClientIdSSMParameter - " >> /etc/profile\n" - echo export FORGE_CLIENT_SECRET= - Ref: ForgeClientSecretSSMParameter - " >> /etc/profile\n" - echo export FORGE_CALLBACK_URL= - Ref: ForgeCallbackUrlSSMParameter - " >> /etc/profile\n" - 'source /etc/profile ' - Fn::Sub: 'aws s3 cp s3://${QSS3BucketName}/${QSS3KeyPrefix}packages/forge-viewhubs-netcore-aws.zip . ' - 'unzip forge-viewhubs-netcore-aws.zip ' - 'cd forge-viewhubs-netcore-aws/Properties ' - 'sed -i "s/CALLBACK_TOKEN/$FORGE_CALLBACK_URL/g" launchSettings.json ' - 'sed -i "s/SECRET_TOKEN/$FORGE_CLIENT_SECRET/g" launchSettings.json ' - 'sed -i "s/ID_TOKEN/$FORGE_CLIENT_ID/g" launchSettings.json ' - 'sed -i "s/REGION_TOKEN/$AWS_REGION/g" launchSettings.json ' - 'cd .. ' - 'export DOTNET_CLI_HOME=`pwd` ' - 'dotnet build ' - 'nohup dotnet run > application.log 2>&1 & ' - "# Signal the status from cfn-init\n" - "/opt/aws/bin/cfn-signal -e $? --stack " - Ref: ParentStack - " --resource WorkloadAutoScalingGroup --region " - Ref: AWS::Region - "\n" Outputs: WorkloadASLaunchConfig: Description: Forge Server Auto Scaling launch configuration Value: Ref: WorkloadASLaunchConfig