diff --git a/template.yaml b/template.yaml index f7001ee..61b9845 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 @@ -169,7 +173,7 @@ Resources: InstanceRole: Type: AWS::IAM::Role Properties: - RoleName: MailInABoxInstanceRole + RoleName: !Sub MailInABoxInstanceRole-${AWS::StackName} AssumeRolePolicyDocument: Version: 2012-10-17 Statement: @@ -249,7 +253,7 @@ Resources: InstanceProfile: Type: AWS::IAM::InstanceProfile Properties: - InstanceProfileName: MailInABoxInstanceProfile + InstanceProfileName: !Sub MailInABoxInstanceProfile-${AWS::StackName} Roles: - !Ref InstanceRole @@ -279,8 +283,8 @@ Resources: BlockDeviceMappings: - DeviceName: /dev/sda1 Ebs: - VolumeType: gp2 - VolumeSize: 8 + VolumeType: gp3 + VolumeSize: !Ref InstanceVolumeSize DeleteOnTermination: true Encrypted: true Tags: @@ -302,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 @@ -331,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 @@ -391,6 +397,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