Skip to content

armgit / core

Public Imported from GitHub
0

100% open-source IoT Platform - Integrate your devices, add intelligence, build custom apps

CI/CD: Minor (#775)

Rich Turnerb52045a2bef6
diff --git a/.ci_cd/aws/cloudformation-create-ec2.yml b/.ci_cd/aws/cloudformation-create-ec2.yml
index e0d4215ef..994463334 100644
--- a/.ci_cd/aws/cloudformation-create-ec2.yml
+++ b/.ci_cd/aws/cloudformation-create-ec2.yml
@@ -2,10 +2,8 @@
# Standard OpenRemote CloudFormation template for provisioning an EC2 instance with docker support for running the
# OpenRemote stack. SMTP credentials are optionally read from the parameter store and added to the /etc/environment
# file to essentially preconfigure standard OpenRemote SMTP environment variables.
-# DNS parameters allow for DNS A record for the created EC2 instance to be dynamically updated between restarts.
-#
-# A standard access security group is also created for the standard OpenRemote stack services; the ssh-access security
-# group is also linked to the EC2 instance and this security group must already exist within the account.
+# DNS parameters allow for DNS A record for the created EC2 instance to be dynamically updated between restarts and a
+# standard access security group is also created for the standard OpenRemote stack services.
#
# Optionally assign an Elastic IP address by setting the ElasticIP parameter to true.
#
@@ -34,16 +32,16 @@ Parameters:
#AllowedPattern: "^((?!-))(xn--)?[a-z0-9][a-z0-9-_]{0,61}[a-z0-9]{0,1}\.(xn--)?([a-z0-9\-]{1,61}|[a-z0-9-]{1,30}\.[a-z]{2,})$"
Default: ""
VpcId:
- Description: VPC ID
+ Description: VPC ID in which to create instance
Type: String
SubnetId:
- Description: Subnet ID
+ Description: Subnet ID in which to create instance
Type: String
SSHSecurityGroupId:
Description: SSH Security Group ID
Type: String
EFSDNS:
- Description: EFS DNS entry (for maps)
+ Description: EFS DNS entry (for maps - IP address of EFS mount target in the same AZ ID)
Type: String
ImageId:
Description: AMI ID
diff --git a/.ci_cd/aws/cloudformation-create-efs.yml b/.ci_cd/aws/cloudformation-create-efs.yml
index 4153e31cd..9044154be 100644
--- a/.ci_cd/aws/cloudformation-create-efs.yml
+++ b/.ci_cd/aws/cloudformation-create-efs.yml
@@ -1,6 +1,6 @@
# ---------------------------------------------------------------------------------------------
# Provisions an EFS using the specified VPC and subnets; creates a security group called
-# `or-map`.
+# `or-map`; but doesn't pre-configure ingress rules on this security group.
# ---------------------------------------------------------------------------------------------
AWSTemplateFormatVersion: 2010-09-09
Description: Hosts EFS
diff --git a/.ci_cd/aws/provision_account.sh b/.ci_cd/aws/provision_account.sh
index 29891b53c..b8e2e724d 100644
--- a/.ci_cd/aws/provision_account.sh
+++ b/.ci_cd/aws/provision_account.sh
@@ -14,10 +14,13 @@
#
# Arguments:
# 1 - OU - Name of organizational unit where account should be provisioned (defaults to account root if not set)
-# 1 - AWS_ACCOUNT_NAME - Name of the new account (required)
-# 2 - PARENT_DNS_ZONE - name of parent hosted domain zone in management account
-# 3 - HOSTED_DNS - If set to 'true' a sub domain hosted zone will be provisioned in the new account and delegated from the
+# 2 - AWS_ACCOUNT_NAME - Name of the new account (required)
+# 3 - PARENT_DNS_ZONE - name of parent hosted domain zone in management account
+# 4 - HOSTED_DNS - If set to 'true' a sub domain hosted zone will be provisioned in the new account and delegated from the
# PARENT_DNS_ZONE in the callee account (e.g. x.y -> AWS_ACCOUNT_NAME.x.y)
+# 5 - CREATE_VPC_PEER - Whether or not a VPC peering connection should be created with the caller account; will look for
+# a VPC called or-vpc in the caller account and will try and use the IAM role arn:aws:iam::$CALLER_AWS_ACCOUNT_ID:role/or-vpc-peer-$AWS_REGION
+# to automatically accept the VPC peering connection
if [[ $BASH_SOURCE = */* ]]; then
awsDir=${BASH_SOURCE%/*}/
diff --git a/.ci_cd/aws/provision_host.sh b/.ci_cd/aws/provision_host.sh
index 46d3a0ece..d36aacd8f 100644
--- a/.ci_cd/aws/provision_host.sh
+++ b/.ci_cd/aws/provision_host.sh
@@ -199,12 +199,12 @@ EOF
SUBNET_NUMBER=$(( $RANDOM % 3 + 1 ))
SUBNETNAME="or-subnet-public-$SUBNET_NUMBER"
SUBNETID=$(aws ec2 describe-subnets --filters Name=tag:Name,Values=$SUBNETNAME --query "Subnets[0].SubnetId" --output text $ACCOUNT_PROFILE 2>/dev/null)
- SUBNET_AZ=$(aws ec2 describe-subnets --filters Name=tag:Name,Values=$SUBNETNAME --query "Subnets[0].AvailabilityZone" --output text $ACCOUNT_PROFILE 2>/dev/null)
+ SUBNET_AZ=$(aws ec2 describe-subnets --filters Name=tag:Name,Values=$SUBNETNAME --query "Subnets[0].AvailabilityZoneId" --output text $ACCOUNT_PROFILE 2>/dev/null)
SGID=$(aws ec2 describe-security-groups --filters Name=tag:Name,Values=ssh-access --query "SecurityGroups[0].GroupId" --output text $ACCOUNT_PROFILE 2>/dev/null)
- # Look for EFS mount target in caller account for the same availability zone (no costs if within same AZ)
+ # Look for EFS mount target in caller account for the same availability zone ID (no costs if within same AZ) - Don't use name as name to IDs vary between accounts
EFS_ID=$(aws efs describe-file-systems --query "FileSystems[?Name=='or-map-efs'].FileSystemId" --output text)
- EFS_DNS=$(aws efs describe-mount-targets --file-system-id $EFS_ID --query "MountTargets[?AvailabilityZoneName=='$SUBNET_AZ'].IpAddress" --output text)
+ EFS_DNS=$(aws efs describe-mount-targets --file-system-id $EFS_ID --query "MountTargets[?AvailabilityZoneId=='$SUBNET_AZ'].IpAddress" --output text)
PARAMS="$PARAMS ParameterKey=VpcId,ParameterValue=$VPCID"
PARAMS="$PARAMS ParameterKey=SSHSecurityGroupId,ParameterValue=$SGID"
diff --git a/.ci_cd/deploy.sh b/.ci_cd/deploy.sh
index f2fcdf038..9377ac52a 100644
--- a/.ci_cd/deploy.sh
+++ b/.ci_cd/deploy.sh
@@ -265,6 +265,8 @@ fi
# Delete any deployment volume so we get the latest
echo "Deleting existing deployment data volume"
docker volume rm or_deployment-data 1>/dev/null
+echo "Deleting existing EFS mount volume"
+docker volume rm or_efs-data 1>/dev/null
# Start the stack
echo "Starting the stack"
@@ -400,6 +402,8 @@ fi
# Delete any deployment volume so we get the latest
echo "Deleting existing deployment data volume"
docker volume rm or_deployment-data 1>/dev/null
+echo "Deleting existing EFS mount volume"
+docker volume rm or_efs-data 1>/dev/null
# Start the stack
echo "Starting the stack"
diff --git a/.github/workflows/provision-account.yml b/.github/workflows/provision-account.yml
index b022a592d..fc9064a02 100644
--- a/.github/workflows/provision-account.yml
+++ b/.github/workflows/provision-account.yml
@@ -17,8 +17,8 @@ on:
type: string
default: openremote.app
required: true
- PROVISION_EFS:
- description: 'Create EFS volume called hosts-filesystem in new account'
+ VPC_PEER:
+ description: 'Create VPC peering connection with management account'
type: boolean
default: true
required: false
@@ -55,13 +55,13 @@ jobs:
if: ${{ steps.checkUserMember.outputs.isTeamMember == 'true' }}
run: |
chmod +x .ci_cd/aws/*
- .ci_cd/aws/provision_account.sh "$OU" "$ACCOUNT_NAME" "$PARENT_DNS_ZONE" "$HOSTED_DNS" "$PROVISION_EFS"
+ .ci_cd/aws/provision_account.sh "$OU" "$ACCOUNT_NAME" "$PARENT_DNS_ZONE" "$HOSTED_DNS" "$VPC_PEER"
env:
OU: ${{ github.event.inputs.OU }}
ACCOUNT_NAME: ${{ github.event.inputs.ACCOUNT_NAME }}
PARENT_DNS_ZONE: ${{ github.event.inputs.PARENT_DNS_ZONE }}
HOSTED_DNS: ${{ github.event.inputs.HOSTED_DNS }}
- PROVISION_EFS: ${{ github.event.inputs.PROVISION_EFS }}
+ VPC_PEER: ${{ github.event.inputs.VPC_PEER }}
AWS_ACCESS_KEY_ID: ${{ secrets._TEMP_AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets._TEMP_AWS_SECRET_ACCESS_KEY }}
AWS_ROLE_NAME: ${{ secrets._TEMP_AWS_ROLE_NAME }}