Search⌘ K
AI Features

Hands-On: Updating the Launch Template

Explore how to enhance your EC2 launch templates by integrating AWS SSM Parameter Store to securely manage configuration parameters. Understand replacing hardcoded database and EFS mount values with parameter lookups, making your user data script reusable and secure. This lesson guides you through updating launch templates via AWS CLI to streamline scalable and secure cloud application deployments.

When all the parameters are stored in the SSM parameter store, we can update the EC2 user data script of our launch template to read the values directly from the SSM parameter store.

There are two parts of the EC2 user data script that we need to replace:

  • Database parameters
Shell
cat > /opt/bitnami/.env <<EOL
DB_HOST=wordpress-db.c42jq3qqvmir.us-east-2.rds.amazonaws.com:3306
DB_PASSWORD=ad65a86fa04f7f1f100b22e93da2dcba6c8a0f9cf6a6d81f99e201f102ad6156
DB_NAME=bitnami_wordpress
DB_USER=bn_wordpress
EOL
  • Mounting of the EFS file system
Shell
# 4. Add the EFS volume to the mount targets
echo "fs-044c22ac078984d92.efs.us-east-2.amazonaws.com:/ /efs efs nfsvers=4.1,rsize=1048576,wsize=1048576,hard,timeo=600,retrans=2,noresvport 0 0" >> /etc/fstab

Now that all our configuration is stored in the ...