terraform - how should I clone my code repo? I have a very simple terraform configuration. I boot up an aws instance of Ubuntu trusty and assign a security group. 

My question is who is responsible of getting the latest code from my code repo? is it a bash script in terraform user_data argument or should I make a modified AMI that has a bash script to pull the code repo.

Basically my repo has docker configuration in it and all i need is to clone and do docker-compose -f env.yml up
You can achieve the clone of the repo and the execution of docker-compose in several ways.

You are right when you think that cloud-init could do that. Check this link for more information