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: Define Snapshot Schedule / Retention Strategy (#1928)
Dennis Kuijs6f04a0871998
diff --git a/.ci_cd/aws/cloudformation-create-ec2.yml b/.ci_cd/aws/cloudformation-create-ec2.ymlindex 07909c6c7..b10d34ddd 100644--- a/.ci_cd/aws/cloudformation-create-ec2.yml+++ b/.ci_cd/aws/cloudformation-create-ec2.yml@@ -29,7 +29,7 @@ Parameters:Host:Description: FQDN for hostType: String- #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,})$"+ # 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 in which to create instance@@ -70,7 +70,7 @@ Parameters:DNSHostedZoneName:Description: Name of hosted domain zone to insert host A record intoType: String- #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,})$"+ # 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,})$"ConstraintDescription: Must be a valid FQDNDefault: ""DNSHostedZoneRoleArn:@@ -78,10 +78,10 @@ Parameters:Type: StringDefault: ""DLMExecutionRoleArn:- Description: Role ARN for executing the DLM operations+ Description: Role ARN that can be assumed for executing DLM operationsType: StringSnapshotId:- Description: Snapshot ID to create the EBS data volume based of an existing snapshot+ Description: Snapshot ID to create EBS data volume based on an existing snapshotType: StringDefault: ""ElasticIP:@@ -99,11 +99,11 @@ Parameters:- falseDefault: falseRootDiskSize:- Description: Root EBS volume size GB+ Description: Size of the EBS root volume (in GB)Type: NumberDefault: 16DataDiskSize:- Description: Amount of storage you want to provision for this EBS data volume+ Description: Size of the EBS data volume (in GB)Type: NumberDefault: 16HealthChecks:@@ -836,8 +836,8 @@ Resources:ImageId: !If [UseAMIID, !Ref ImageAMI, !Ref ImageId]SubnetId: !Ref SubnetIdSecurityGroupIds:- - Ref: SSHSecurityGroupId- - Ref: StandardSecurityGroup+ - !Ref SSHSecurityGroupId+ - !Ref StandardSecurityGroupBlockDeviceMappings:- DeviceName: /dev/xvdaEbs:@@ -881,6 +881,7 @@ Resources:EBSDataVolume:Type: AWS::EC2::Volume+ DeletionPolicy: SnapshotProperties:AvailabilityZone: !GetAtt EC2Instance.AvailabilityZoneSize: !Ref DataDiskSize@@ -891,7 +892,6 @@ Resources:Value: !Sub ${Host}-data- Key: TypeValue: !Sub ${Host}-or-data-not-in-use- DeletionPolicy: Snapshot# DLM Policy for automatic snapshot creation@@ -900,7 +900,10 @@ Resources:DependsOn: EBSDataVolumeProperties:ExecutionRoleArn: !Ref DLMExecutionRoleArn- Description: 'or-data'+ Description: !Join+ - ''+ - - 'Docker Volumes from instance '+ - !Ref EC2InstanceState: ENABLEDPolicyDetails:PolicyLanguage: STANDARD@@ -912,18 +915,22 @@ Resources:- VOLUMESchedules:- Name: Daily Backup+ CopyTags: true+ CreateRule:+ CronExpression: 'cron(0 3 * * ? * )'+ RetainRule:+ Count: 7+ - Name: Weekly Backup+ CopyTags: trueCreateRule:- Interval: 24- IntervalUnit: HOURS- Times:- - '05:00'+ CronExpression: 'cron(0 3 ? * MON * )'RetainRule:- Count: 5+ Count: 4Tags:- Key: NameValue: !Ref Host- # Telemetry and Alarms.+ # Telemetry and AlarmsEmailSubscription:Condition: CreateHealthChecksdiff --git a/.ci_cd/aws/cloudformation-create-smtp-user.yml b/.ci_cd/aws/cloudformation-create-smtp-user.ymlindex 601aa5733..cec5e9f6e 100644--- a/.ci_cd/aws/cloudformation-create-smtp-user.yml+++ b/.ci_cd/aws/cloudformation-create-smtp-user.yml@@ -9,7 +9,7 @@ Parameters:UserName:Description: User name for smtp userType: String- #AllowedPattern: "^\S{4,}$"+ # AllowedPattern: "^\S{4,}$"Resources:SMTPUser:diff --git a/.ci_cd/aws/cloudformation-create-vpc.yml b/.ci_cd/aws/cloudformation-create-vpc.ymlindex e6615cce3..664d318a5 100644--- a/.ci_cd/aws/cloudformation-create-vpc.yml+++ b/.ci_cd/aws/cloudformation-create-vpc.yml@@ -42,7 +42,7 @@ Conditions:CreateSSHSecurityGroup: !Equals [!Ref SSHSecurityGroup, "true"]Resources:- ## VPC+ # VPCVpc:Type: AWS::EC2::VPCProperties:@@ -60,7 +60,7 @@ Resources:VpcId: !Ref VpcAmazonProvidedIpv6CidrBlock: true- ## VPC Peering accept role+ # VPC Peering accept roleVPCPeerRole:Type: AWS::IAM::RoleCondition: CreateVPCAcceptRole@@ -97,7 +97,7 @@ Resources:'Fn::Sub': >-arn:aws:ec2:${AWS::Region}:${AWS::AccountId}:vpc-peering-connection/*- ## VPC Peering Request+ # VPC Peering RequestVpcPeeringConnection:Type: 'AWS::EC2::VPCPeeringConnection'Condition: CreateVPCPeerRequest@@ -107,7 +107,7 @@ Resources:PeerOwnerId: !Ref PeerVPCAccountIdPeerRoleArn: !Ref PeerRoleArn- ## SUBNETS+ # SubnetsPublicSubnet1:Type: AWS::EC2::SubnetDependsOn: VpcCidrBlockIpv6@@ -192,7 +192,7 @@ Resources:- Key: NameValue: or-subnet-private-3- ## INTERNET GATEWAY+ # Internet GatewayInternetGateway:Type: AWS::EC2::InternetGateway@@ -202,7 +202,7 @@ Resources:VpcId: !Ref VpcInternetGatewayId: !Ref InternetGateway- ## PUBLIC ROUTING+ # Public RoutingPublicRouteTable:Type: AWS::EC2::RouteTableProperties:@@ -254,7 +254,7 @@ Resources:SubnetId: !Ref PublicSubnet3RouteTableId: !Ref PublicRouteTable- ## SSH Security Group+ # SSH Security GroupSecurityGroup:Type: AWS::EC2::SecurityGroupCondition: CreateSSHSecurityGroupdiff --git a/.ci_cd/aws/cloudformation-healthcheck-alarm.yml b/.ci_cd/aws/cloudformation-healthcheck-alarm.ymlindex c2e91ede4..c1b72e232 100644--- a/.ci_cd/aws/cloudformation-healthcheck-alarm.yml+++ b/.ci_cd/aws/cloudformation-healthcheck-alarm.yml@@ -1,8 +1,8 @@# ----------------------------------------------------------------------------------------------------------------------# Creates an alarm for Route53 health check - must be run in the us-east-1 region+# Creates an alarm for Route53 Health Check - must be run in the us-east-1 region# ---------------------------------------------------------------------------------------------------------------------AWSTemplateFormatVersion: '2010-09-09'-Description: 'Route 53 Healthcheck alarm'+Description: 'Route53 Health Check alarm'Parameters:Host:Description: FQDN for hostdiff --git a/.ci_cd/aws/provision_host.sh b/.ci_cd/aws/provision_host.shindex a8fd02af4..716dcce4f 100644--- a/.ci_cd/aws/provision_host.sh+++ b/.ci_cd/aws/provision_host.sh@@ -20,7 +20,7 @@# 3 - INSTANCE_TYPE EC2 instance type see cloud formation template parameter# 4 - ROOT_DISK_SIZE to use for created EBS root volume (GB)# 5 - DATA_DISK_SIZE to use for created EBS data volume (GB)-# 6 - SNAPSHOT_ID to use for creating the EBS data volume based off an existing snapshot+# 6 - SNAPSHOT_ID to use for creating the EBS data volume based on an existing snapshot# 7 - ELASTIC_IP if 'true' then create an elastic public IP for this host# 8 - PROVISION_S3_BUCKET set to 'false' to not provision an S3 bucket for this host# 9 - ENABLE_METRICS set to 'false' to not enable cloudwatch metrics for this instance@@ -72,7 +72,6 @@ fiSTACK_NAME=$(tr '.' '-' <<< "$HOST")SMTP_STACK_NAME="$STACK_NAME-smtp"HEALTH_STACK_NAME="$STACK_NAME-healthcheck"-SSM_STACK_NAME="$STACK_NAME-ssm-attach-detach-documents"# Provision SMTP user using CloudFormation (if stack doesn't already exist)echo "Provisioning SMTP user"@@ -286,7 +285,7 @@ if [ -n "$STATUS" ] && [ "$STATUS" != 'available' ]; thenecho "EBS data volume is already attached or not available for this host '$HOST' current status is '$STATUS'"else- EBS_DEVICE_NAME="/dev/sdf" # Only change if you know what you are doing+ EBS_DEVICE_NAME="/dev/sdf" # Don't change it unless you know what you are doingINSTANCE_ID=$(aws ec2 describe-instances --filters "Name=tag:Name,Values='$HOST'" --query "Reservations[].Instances[?Tags[?Value=='$STACK_ID']].InstanceId" --output text $ACCOUNT_PROFILE 2>/dev/null)VOLUME_ID=$(aws ec2 describe-volumes --filters "Name=tag:Name,Values='$HOST-data'" --query "Volumes[?Tags[?Value=='$STACK_ID']].VolumeId" --output text $ACCOUNT_PROFILE 2>/dev/null)@@ -335,7 +334,7 @@ if [ "$PROVISION_S3_BUCKET" != 'false' ]; thenfifi-# Provision Route 53 healthcheck alarm CloudFormation (if stack doesn't already exist) - must be in the us-east-1 region+# Provision Route53 Health Check Alarm CloudFormation (if stack doesn't already exist) - must be in the us-east-1 regionecho "Provisioning Healthcheck Alarm"STATUS=$(aws cloudformation describe-stacks --stack-name $HEALTH_STACK_NAME --query "Stacks[0].StackStatus" --output text $ACCOUNT_PROFILE --region us-east-1 2>/dev/null)