2
votes

I am trying to deploy my GITLabs repository code to my AWS instance on every commit i do on repo.

I have created webhook using ZipDownloadWebHookApi URL form Output tab of my stack. I have followed this link for doing all the stuff.

I am using the stack cloud template specified here

The zip which is being created by cloudFormation inside specified S3 Bucket is having a subfolder, which is containing whole git repository code.

So the issue I am facing is, when I use this zip as an object in AWS CodeDeploy it does not find the appspecs.yml file and deployment stops before beforeInstall event with following error-

No such file or directory - /opt/codedeploy-agent/deployment-root/1d0d3a00-435a-4td1-87d8-4ad40222e6f9/d-LJS5Q7WGN/deployment-archive/appspec.yml

Can you please suggest me what should I follow after this to achieve my goal?

1

1 Answers

0
votes

You could, wuth GitLab 13.5 (October 2020), follow a template example which would illustrate the all delivery process:

Template for Deploying to AWS EC2

To help you deploy to AWS Elastic Cloud Compute (EC2) more efficiently, we created a template that shows you how to get started.
This template allows you to:

  • provision your own infrastructure by first leveraging the AWS CloudFormation API.
  • push your previously built artifact to an AWS S3 bucket and deploy the content to an AWS EC2 instance.

Users can include the template in their configuration, specify a few variables, and their application will be deployed and ready to go in no time.

See Documentation and Issue.


And with GitLab 13.6 (November 2020):

Auto Deploy to EC2

Auto DevOps has been expanded to support deployments to Amazon Web Services. You can now deploy to AWS Cloud Compute (EC2) and take advantage of Auto DevOps, even without Kubernetes.

To enable this workflow, you must enable Auto DevOps and define the AWS-typed environment variables AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, and AWS_DEFAULT_REGION. This allows you to provision your own infrastructure by leveraging the AWS CloudFormation API.

Then, you can push your previously built artifact to an AWS S3 bucket, and deploy the content to an AWS EC2 instance.
Your EC2 deployment then automatically builds you a complete, automatic delivery pipeline without extra manual steps.

See Documentation and Issue.