02/19/2024
I've been wanting to set up this website through Amazon Web Services Code Pipelines for a while now. Partly for the practise with the AWS features for managing code and deployments, also partly because it can allow me to use a more advanced editor (Visual Studio Code). As well as I know my Linux command line and vi editing, it's just so much more convenient to set up things using more modern features.
I was able to find good documentation from AWS about how to set up permissions for Code Commit, which is their system for working with git: https://docs.aws.amazon.com/codecommit/latest/userguide/setting-up-gc.html?icmpid=docs_acc_console_connect_np. I used git on my WSL command line to get the initial commit pushed up to Code Commit.
AWS has instructions for creating a deployment pipleline after your code is commited that you can find here: https://docs.aws.amazon.com/codepipeline/latest/userguide/tutorials-simple-codecommit.html. I did run into a first error while setting things up and resolved it using: https://stackoverflow.com/a/68380116. The second error I ran into was a bit trickier to resolve, it involved having to read the logs of the CodeDeploy agent on the EC2 instance I had Amazon Linux running on: https://docs.aws.amazon.com/codedeploy/latest/userguide/deployments-view-logs.html#deployments-view-logs-instance.
What I learned from reading the logs and further Googling was that I was missing a key file for instructing Code Deploy which directory on my Amazon Linux EC2 instance to copy the code to, appspec.yml. The following two links were very helpful in creating the file, coding it properly, and resolving the issue: https://docs.aws.amazon.com/codedeploy/latest/userguide/application-revisions-appspec-file.html#add-appspec-file-server and https://docs.aws.amazon.com/codedeploy/latest/userguide/reference-appspec-file.html. It's also worth carefully reading the comment in the appspec.yml template that is provided. The last error I encountered was that files could not be overwritten in my /var/www/html directory. Rather than wrestle with Linux permissions, I removed the current versions. Finally my code pipeline deployment finished without error.
The last step was to connect WS Code through git on Windows, this was an easy process and went without error. Instructions can be found at: https://code.visualstudio.com/docs/sourcecontrol/overview. One final test editing some code in VS Code and pushing it through Windows git worked well, and I had completed the task.