Git not pulling changes in AWS ec2 user data

23 Views Asked by At

Hi sorry if this is super obvious but I can't seem to figure it out. I have an auto scaling group setup in AWS for deploying an api server. Instances are launched using a template with an AMI I made from a previously running EC2 instance that has git setup with my credentials to communicate over ssh. On each instance spin up I want the system to pull changes from git and build according to a docker compose yaml file. My user data in the AWS launch template is

#!/bin/bash
cd /home/ubuntu/git-repo-directory
git pull origin main
sudo docker compose up --build -d

What's strange is that the docker command seems to be running but the code is not pulled and updated from remote git repository. Am I doing something wrong?

0

There are 0 best solutions below