Last active
July 5, 2024 09:13
-
-
Save b0tting/f1a83a8ecca42ae37cc2c40d6174cead to your computer and use it in GitHub Desktop.
Installing the AWS CFN helper scripts on Ubuntu 24.04. At the moment of writing, the aws-cfn-bootstrap-py3-latest.tar.gz helpers such as cfn-init and cfn-signal are not updated for python 3.12. A solution would be to use a virtual environment during bootstrapping or cloudinit.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This should be able to run in cfn-init / EC2 userdata | |
export DEBIAN_FRONTEND=noninteractive | |
export VENV_DIR=/opt/aws/cfn-bootstrap-venv | |
export HELPER_SCRIPTS_BIN_DIR=/opt/aws/bin | |
# Install python 3.11 from deadsnakes, this will not be the default python, that will stay on 3.12 | |
apt update | |
apt-get install -y tzdata software-properties-common # Maybe only required in docker? | |
add-apt-repository -y ppa:deadsnakes/ppa | |
apt update | |
apt install -y python3.11 python3.11-venv | |
# Set up a virtual env | |
mkdir -p ${VENV_DIR} | |
python3.11 -m venv ${VENV_DIR} | |
source ${VENV_DIR}/bin/activate | |
# Install the CFN helper scripts. These will link to the virtual environment & 3.11, not touching the | |
# system standard python 3.12 | |
pip3 install https://s3.amazonaws.com/cloudformation-examples/aws-cfn-bootstrap-py3-latest.tar.gz | |
mkdir -p ${HELPER_SCRIPTS_BIN_DIR} | |
ln -s ${VENV_DIR}/bin/cfn-* ${HELPER_SCRIPTS_BIN_DIR} | |
deactivate |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment