100% open-source IoT Platform - Integrate your devices, add intelligence, build custom apps
Java asset-managementbuildingdashboarddataplatformdevice-managementedge-computingenergyenergy-managementenergy-monitorfleet-managementfleet-telematicsiotiot-applicationiot-platformmodbusmqttmqtt-brokerota-updaterules-enginesmartcity
CI/CD: Add Disk size, health check and elastic IP options for host provisioning (#826)
Rich Turner51fefc013ae6
diff --git a/.ci_cd/aws/cloudformation-create-ec2.yml b/.ci_cd/aws/cloudformation-create-ec2.ymlindex 994463334..e98ed9ad1 100644--- a/.ci_cd/aws/cloudformation-create-ec2.yml+++ b/.ci_cd/aws/cloudformation-create-ec2.yml@@ -46,7 +46,7 @@ Parameters:ImageId:Description: AMI IDType: String- Default: "ami-0a6b5206d1730bdce"+ Default: "ami-062cd09187a31b743"InstanceType:Description: EC2 instance type (don't change it unless you know what you are doing)Type: String@@ -59,8 +59,9 @@ Parameters:- t4g.small- t4g.medium- t4g.large- - m6g.medium+ - t4g.xlarge- m6g.large+ - m6g.xlargeConstraintDescription: must be a valid EC2 instance type.DNSHostedZoneName:Description: Name of hosted domain zone to insert host A record into@@ -79,6 +80,10 @@ Parameters:- true- falseDefault: false+ DiskSize:+ Description: Root EBS volume size GB+ Type: Number+ Default: 50HealthChecks:Description: Create health checksType: String@@ -575,7 +580,12 @@ Resources:SecurityGroupIds:- Ref: SSHSecurityGroupId- Ref: StandardSecurityGroup-+ BlockDeviceMappings:+ - DeviceName: /dev/xvda+ Ebs:+ VolumeSize: !Ref DiskSize+ VolumeType: gp3+ DeleteOnTermination: trueIpv6AddressCount: 1Tags:- Key: Name@@ -691,6 +701,24 @@ Resources:- Name: InstanceIdValue: !Ref EC2Instance+ DiskUtilizationAlarm:+ Type: AWS::CloudWatch::Alarm+ Properties:+ Namespace: Cloudwatch+ MetricName: disk_used_percent+ Statistic: Average+ Period: 600+ EvaluationPeriods: 3+ ComparisonOperator: GreaterThanThreshold+ Threshold: 90+ AlarmActions:+ - !Ref SnsTopic+ OKActions:+ - !Ref SnsTopic+ Dimensions:+ - Name: InstanceId+ Value: !Ref EC2Instance+HealthCheckAlarm:Type: AWS::CloudWatch::AlarmCondition: CreateHealthChecksdiff --git a/.ci_cd/aws/provision_host.sh b/.ci_cd/aws/provision_host.shindex d36aacd8f..78f4b1d93 100644--- a/.ci_cd/aws/provision_host.sh+++ b/.ci_cd/aws/provision_host.sh@@ -12,8 +12,10 @@# 1 - AWS_ACCOUNT_NAME where resources should be created (defaults to callers account)# 2 - HOST FQDN for e.g. staging.demo.openremote.app# 3 - INSTANCE_TYPE EC2 instance type see cloud formation template parameter-# 4 - PROVISION_S3_BUCKET set to 'false' to not provision an S3 bucket for this host-# 5 - WAIT_FOR_STACK if 'false' script will not wait until the cloud formation stack is running+# 4 - DISK_SIZE to use for created EBS root volume (GB)+# 5 - ELASTIC_IP if 'true' then create an elastic public IP for this host+# 6 - PROVISION_S3_BUCKET set to 'false' to not provision an S3 bucket for this host+# 7 - WAIT_FOR_STACK if 'false' script will not wait until the cloud formation stack is runningif [[ $BASH_SOURCE = */* ]]; thenawsDir=${BASH_SOURCE%/*}/@@ -24,8 +26,10 @@ fiAWS_ACCOUNT_NAME=${1,,}HOST=${2,,}INSTANCE_TYPE=${3,,}-PROVISION_S3_BUCKET=${4,,}-WAIT_FOR_STACK=${5,,}+DISK_SIZE=${4,,}+ELASTIC_IP=${5,,}+PROVISION_S3_BUCKET=${6,,}+WAIT_FOR_STACK=${7,,}if [ -z "$HOST" ]; thenecho "Host must be set"@@ -121,6 +125,14 @@ elsePARAMS="$PARAMS ParameterKey=InstanceType,ParameterValue=$INSTANCE_TYPE"fi+ if [ -n "$DISK_SIZE" ]; then+ PARAMS="$PARAMS ParameterKey=DiskSize,ParameterValue=$DISK_SIZE"+ fi++ if [ -n "$ELASTIC_IP" ]; then+ PARAMS="$PARAMS ParameterKey=ElasticIP,ParameterValue=$ELASTIC_IP"+ fi+# Get SMTP credentialsSMTP_HOST="email-smtp.$AWS_REGION.amazonaws.com"SMTP_USER=$(aws cloudformation describe-stacks --stack-name $SMTP_STACK_NAME --query "Stacks[0].Outputs[?OutputKey=='SMTPUserKey'].OutputValue" --output text 2>/dev/null)@@ -193,7 +205,7 @@ EOFif [ -n "$DNSHostedZoneRoleArn" ]; thenPARAMS="$PARAMS ParameterKey=DNSHostedZoneRoleArn,ParameterValue=$DNSHostedZoneRoleArn"fi-+# Get OR VPC ID, Subnet ID, SSH Security Group ID and EFS MOUNT TARGET IPVPCID=$(aws ec2 describe-vpcs --filters Name=tag:Name,Values=or-vpc --query "Vpcs[0].VpcId" --output text $ACCOUNT_PROFILE 2>/dev/null)SUBNET_NUMBER=$(( $RANDOM % 3 + 1 ))diff --git a/.github/workflows/provision-host.yml b/.github/workflows/provision-host.ymlindex 705a0d1ab..499f1547d 100644--- a/.github/workflows/provision-host.yml+++ b/.github/workflows/provision-host.yml@@ -17,15 +17,25 @@ on:required: trueINSTANCE_TYPE:description: 'EC2 instance type (only change if you know what you are doing)'- default: t4g.small+ default: t4g.mediumtype: choiceoptions:- t4g.small- t4g.medium- t4g.large- - m6g.medium+ - t4g.xlarge- m6g.large+ - m6g.xlargerequired: true+ DISK_SIZE:+ description: 'Override EC2 root EBS volume size to provision (GB)'+ type: string+ required: false+ ELASTIC_IP:+ description: 'Create elastic public IP'+ type: boolean+ default: false+ required: falsePROVISION_S3_BUCKET:description: 'Create S3 bucket for backups'type: boolean@@ -56,11 +66,13 @@ jobs:if: ${{ steps.checkUserMember.outputs.isTeamMember == 'true' }}run: |chmod +x .ci_cd/aws/*- .ci_cd/aws/provision_host.sh "$ACCOUNT_NAME" "$HOST" "$INSTANCE_TYPE" "$PROVISION_S3_BUCKET"+ .ci_cd/aws/provision_host.sh "$ACCOUNT_NAME" "$HOST" "$INSTANCE_TYPE" "$DISK_SIZE" "$ELASTIC_IP" "$PROVISION_S3_BUCKET"env:ACCOUNT_NAME: ${{ github.event.inputs.ACCOUNT_NAME }}HOST: ${{ github.event.inputs.HOST }}INSTANCE_TYPE: ${{ github.event.inputs.INSTANCE_TYPE }}+ DISK_SIZE: ${{ github.event.inputs.DISK_SIZE }}+ ELASTIC_IP: ${{ github.event.inputs.ELASTIC_IP }}PROVISION_S3_BUCKET: ${{ github.event.inputs.PROVISION_S3_BUCKET }}AWS_ACCESS_KEY_ID: ${{ secrets._TEMP_AWS_ACCESS_KEY_ID }}AWS_SECRET_ACCESS_KEY: ${{ secrets._TEMP_AWS_SECRET_ACCESS_KEY }}