-
Notifications
You must be signed in to change notification settings - Fork 11
Error while provisioning EC2 instance #1
Copy link
Copy link
Open
Description
Issue
CloudFormation always fail when provisioning EC2 instance.
Expected
CloudFormation should be able to provision all the resources.
Details
I've tried the steps found at https://aws.amazon.com/blogs/opensource/fully-automated-deployment-of-an-open-source-mail-server-on-aws/.
It turn out caused by the installation script issuing sudo command which took long and caused CloudFormation to timed-out. The sudo trying to resolve the hostname but it does not written on /etc/hosts. So to execute a singgle command it took ages to complete and gives warning:
sudo: unable to resolve host (MY_HOST_NAME)
Several script such as setup/nextcloud.sh uses sudo to run several commands.
Fixes
My fix is simple, I modify EC2 userdata on CloudFormation template and write the hostname to /etc/hosts file.
# ...cut...
export PRIMARY_HOSTNAME="${InstanceDns}.${MailInABoxDomain}"
if [[ -z "${InstanceEIP}" ]]; then
export PUBLIC_IP=$(ec2metadata --public-ipv4)
else
export PUBLIC_IP="${InstanceEIP}"
fi
echo "$PUBLIC_IP $PRIMARY_HOSTNAME" >> /etc/hosts
# ...cut...Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels