From e496b1cadae723eb6813fee5b0122f0ef1122cd7 Mon Sep 17 00:00:00 2001 From: Michael Meidlinger Date: Mon, 6 May 2024 17:41:37 +0100 Subject: [PATCH 1/4] :sparkles: Moving to gp3 and making the root volume size a parameter --- template.yaml | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/template.yaml b/template.yaml index f7001ee..f7f3fea 100644 --- a/template.yaml +++ b/template.yaml @@ -30,6 +30,10 @@ Parameters: Description: Managed AMI ID for EC2 Instance Type : AWS::SSM::Parameter::Value Default: '/aws/service/canonical/ubuntu/server/jammy/stable/current/amd64/hvm/ebs-gp2/ami-id' + InstanceVolumeSize: + Description: Size of Instance root volume in GB + Type : String + Default: 10 InstanceDns: Description: DNS name of Instance (within the 'MailInABoxDomain') Type: String @@ -279,8 +283,8 @@ Resources: BlockDeviceMappings: - DeviceName: /dev/sda1 Ebs: - VolumeType: gp2 - VolumeSize: 8 + VolumeType: gp3 + VolumeSize: !Ref InstanceVolumeSize DeleteOnTermination: true Encrypted: true Tags: From aade325b43dc371cd2bbe26f1972577fc46c3b44 Mon Sep 17 00:00:00 2001 From: Michael Meidlinger Date: Mon, 6 May 2024 17:42:57 +0100 Subject: [PATCH 2/4] :art: Unique resource names to allow co-existance of cloudformation stacks --- template.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/template.yaml b/template.yaml index f7f3fea..d00bf1d 100644 --- a/template.yaml +++ b/template.yaml @@ -173,7 +173,7 @@ Resources: InstanceRole: Type: AWS::IAM::Role Properties: - RoleName: MailInABoxInstanceRole + RoleName: !Sub MailInABoxInstanceRole-${AWS::StackName} AssumeRolePolicyDocument: Version: 2012-10-17 Statement: @@ -253,7 +253,7 @@ Resources: InstanceProfile: Type: AWS::IAM::InstanceProfile Properties: - InstanceProfileName: MailInABoxInstanceProfile + InstanceProfileName: !Sub MailInABoxInstanceProfile-${AWS::StackName} Roles: - !Ref InstanceRole From b564fce13a58bc2fe415fcc39d9c05680a4fa3c4 Mon Sep 17 00:00:00 2001 From: Michael Meidlinger Date: Mon, 6 May 2024 17:44:13 +0100 Subject: [PATCH 3/4] :art: Install duplicity via snap rather than pip --- template.yaml | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/template.yaml b/template.yaml index d00bf1d..dbdcb83 100644 --- a/template.yaml +++ b/template.yaml @@ -306,9 +306,9 @@ Resources: unzip \ intltool \ python-is-python3 - pip3 install duplicity==1.0.1 - # snap install duplicity --classic - # ln -s /snap/bin/duplicity /usr/bin/duplicity + + # Install duplicity via snap + snap install duplicity --classic && ln -s /snap/bin/duplicity /usr/local/sbin/ # Install awscli and CloudFormation helper scripts cd /tmp @@ -395,6 +395,8 @@ Resources: cd /opt/mailinabox/ && setup/start.sh # ---------------- POST INSTALL + # Get rid of duplicity installed by MIAB + apt-get remove -o DPkg::Lock::Timeout=120 -y duplicity && ln -s /snap/bin/duplicity /usr/bin/ # Configure networking according to https://aws.amazon.com/premiumsupport/knowledge-center/ec2-static-dns-ubuntu-debian/ INTERFACE=$(ip route list | grep default | grep -E 'dev (\w+)' -o | awk '{print $2}') cat < /etc/netplan/99-custom-dns.yaml From bdefaf72e50da67b4bab3e702fa9382b0423510f Mon Sep 17 00:00:00 2001 From: Michael Meidlinger Date: Mon, 6 May 2024 17:44:58 +0100 Subject: [PATCH 4/4] :zap: Add loopback address for server FQDN to /etc/hosts --- template.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/template.yaml b/template.yaml index dbdcb83..61b9845 100644 --- a/template.yaml +++ b/template.yaml @@ -335,6 +335,8 @@ Resources: else export PUBLIC_IP="${InstanceEIP}" fi + echo "127.0.0.1 $PRIMARY_HOSTNAME" >> /etc/hosts + # Setup Admin Account. export EMAIL_ADDR="admin@${MailInABoxDomain}" # If no admin password is specified generate a random one. In that case, we upload this randomly genereated PW to SSM if it's a fresh install