I've just started learning Terraform (utilizing the AWS provider) and I have managed to replicate our infrastructure which includes quite a few amazon web services.
I can successfully deploy it and get a basic Apache website up and running on an EC2 instance with the following bash script (run from Terraform):
#!/bin/bash
sudo apt update -y
sudo apt install apache2 -y
sudo systemctl start apache2
sudo bash -c 'echo frontend-website > /var/www/html/index.html'
Very basic, but I'm having issues in finding some documentation on the best practices for getting our project code onto the AWS EC2 instance once provisioned, and how everything should be setup for Gitlab CI/CD to keep it all automated.
Especially for a bigger project (e.g., separate frontend and backend instances) where you may have a dev, test, and prod environment for the frontend and backend.