Skip to content

Instantly share code, notes, and snippets.

Created October 1, 2021 09:41
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
Unifi controller on Ubuntu 20.04 arm64 - AWS userdata
echo -e "Running custom Unifi userdata"
# Assoicate an elastic IP
# Set timezone
ln -fs /usr/share/zoneinfo/Pacific/Auckland /etc/localtime
apt-key adv --keyserver --recv 06E85760C0A52C50
echo 'deb [arch=armhf] stable ubiquiti' > /etc/apt/sources.list.d/99-unifi.list
apt update && apt -y upgrade
apt-mark hold openjdk-8-*
apt -y install openjdk-8-jre
echo JAVA_HOME=/usr/lib/jvm/java-8-openjdk-arm64/ >> /etc/environment
source /etc/environment
apt -y install unifi
# Make sure ssm is running
sudo systemctl start
sudo systemctl enable
sudo systemctl start unifi
sudo systemctl enable unifi
# Associate a given elastic IP with an instance on boot.
# Get instance creds.
# @see
# @see
# @see
apt install awscli jq -y
ROLE=$(curl -s
CR=$(curl -s$ROLE/)
INSTANCE_ID=$(curl -s
export AWS_ACCESS_KEY_ID=$(echo $CR | jq -r '.AccessKeyId')
export AWS_SECRET_ACCESS_KEY=$(echo $CR | jq -r '.SecretAccessKey')
export AWS_SESSION_TOKEN=$(echo $CR | jq -r '.Token')
# Now we can associate the address.
echo -e "Running: aws --region=$AWS_DEFAULT_REGION ec2 associate-address --instance-id $INSTANCE_ID --allocation-id $ALLOC_ID --allow-reassociation"
aws --region=$AWS_DEFAULT_REGION ec2 associate-address --instance-id $INSTANCE_ID --allocation-id $ALLOC_ID --allow-reassociation
IPv4=$(curl -s
echo -e "This instance now has public IPv4 $IPv4"
echo -e "Start setting up your controller at https://$IPv4:8080"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment