Skip to content

armgit / core

Public Imported from GitHub
0

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

Fix: AWS Marketplace CloudFormation Init script cannot start OpenRemote (#2380)

Dennis Kuijs19802328b924
diff --git a/.ci_cd/aws/cloudformation-aws-marketplace.yml b/.ci_cd/aws/cloudformation-aws-marketplace.yml
index c0b7eb7c0..fd1915701 100644
--- a/.ci_cd/aws/cloudformation-aws-marketplace.yml
+++ b/.ci_cd/aws/cloudformation-aws-marketplace.yml
@@ -37,7 +37,7 @@ Metadata:
InstanceType:
default: Which instance would you like to use?
ImageId:
- default: Which AMI (Amazon Machine Image) do you want to use for this instance?
+ default: Which AMI (Amazon Machine Image) do you want to use for this instance?
DiskSize:
default: How much storage would you like to allocate to the virtual machine?
Keypair:
@@ -77,10 +77,8 @@ Parameters:
DiskSize:
Description: Choose the amount of storage (in GB)
Type: String
- Default: 8GB
+ Default: 32GB
AllowedValues:
- - 8GB
- - 16GB
- 32GB
- 48GB
- 64GB
@@ -301,7 +299,7 @@ Resources:
command: |
usermod -a -G docker ec2-user
chkconfig docker on
- curl -L https://github.com/docker/compose/releases/latest/download/docker-compose-$(uname -s)-$(uname -m) -o /usr/local/bin/docker-compose && chmod +x /usr/local/bin/docker-compose
+ curl -sL https://github.com/docker/compose/releases/latest/download/docker-compose-$(uname -s)-$(uname -m) -o /usr/bin/docker-compose && chmod +x /usr/bin/docker-compose
test: docker-compose --version >/dev/null 2>&1; (( $? != 0 ))
services:
systemd:
@@ -313,8 +311,8 @@ Resources:
commands:
01_openremote_installation:
command: |
- wget https://raw.githubusercontent.com/openremote/openremote/refs/heads/master/docker-compose.yml -P /openremote
- test: ls /openremote/docker-compose.yml >/dev/null 2>&1; (( $? != 0 ))
+ curl -sL https://raw.githubusercontent.com/openremote/openremote/refs/heads/master/docker-compose.yml -o /home/ec2-user/docker-compose.yml
+ test: ls /home/ec2-user/docker-compose.yml >/dev/null 2>&1; (( $? != 0 ))
start_openremote:
commands:
@@ -322,27 +320,37 @@ Resources:
command: !Sub |
# If hostname is not provided, use the IPv4 address of the EC2 instance, otherwise use the hostname.
- [ -z "${Host}" ] && HOST=$(curl v4.ident.me 2>/dev/null) || HOST="${Host}"
-
+ export OR_HOSTNAME=$( [ -z "${Host}" ] && curl -s v4.ident.me || echo "${Host}" )
+
# Avoid parameter expansion if the password contains `$`
- PASSWORD=$(cat << 'EOF'
+ if [ -n "${Password}" ]; then
+ export OR_ADMIN_PASSWORD=$(cat << 'EOF'
${Password}
EOF
)
- SMTP_PASSWORD=$(cat << 'EOF'
+ fi
+
+ if [ -n "${SMTPPassword}" ]; then
+ export OR_EMAIL_PASSWORD=$(cat << 'EOF'
${SMTPPassword}
EOF
)
+ fi
+
+ # Configure SMTP credentials if provided.
+ if [ -n "${SMTPHost}" ]; then
+ export OR_EMAIL_HOST="${SMTPHost}"
+ fi
+ if [ -n "${SMTPUser}" ]; then
+ export OR_EMAIL_USER="${SMTPUser}"
+ fi
+ if [ -n "${SMTPFrom}" ]; then
+ export OR_EMAIL_FROM="${SMTPFrom}"
+ fi
+
+ # Start OpenRemote using the Docker Compose file.
+ docker-compose -f /home/ec2-user/docker-compose.yml -p or up -d
- # Set environment variables and start OpenRemote with the Docker Compose file.
- OR_HOSTNAME="$HOST" \
- OR_ADMIN_PASSWORD="$PASSWORD" \
- OR_EMAIL_HOST="${SMTPHost}" \
- OR_EMAIL_USER="${SMTPUser}" \
- OR_EMAIL_PASSWORD="$SMTP_PASSWORD" \
- OR_EMAIL_FROM="${SMTPFrom}" \
- docker-compose -f /openremote/docker-compose.yml -p openremote up -d
-
Properties:
ImageId: !Ref ImageId
InstanceType: !Ref InstanceType
@@ -354,7 +362,7 @@ Resources:
Ipv6AddressCount: 1
Tags:
- Key: Name
- Value: !Sub ${AWS::StackName}-AWS Marketplace
+ Value: OpenRemote
BlockDeviceMappings:
- DeviceName: /dev/xvda
Ebs:
@@ -371,7 +379,7 @@ Resources:
# Execute OpenRemote configset.
/opt/aws/bin/cfn-init -v --stack ${AWS::StackName} --configsets openremote --region ${AWS::Region} --resource EC2Instance
- # Wait for signal that OpenRemote is succesfully installed.
+ # Wait for signal that OpenRemote is successfully installed.
/opt/aws/bin/cfn-signal -e $? --stack ${AWS::StackName} --region ${AWS::Region} --resource EC2Instance
IPAddress:
@@ -392,4 +400,4 @@ Resources:
Outputs:
PublicIP:
Description: The Public IP of the OpenRemote instance
- Value: !GetAtt EC2Instance.PublicIp
\ No newline at end of file
+ Value: !GetAtt EC2Instance.PublicIp