3

I have set up two EC2 instances in a private subnet behind a NAT. The instances are both in a AutoScalling group. I want to integrate CodeDeploy with my repository from GitLab.

All I can think of now is running a script on the BeforeInstall hook of the appspec.yml file.

Is there another way to do this?

1 Answer 1

5

GitLab doesn't implements a direct integration with AWS services, but you can work around that. You can do something like what you described, and implement all the installation/distribution/auth logic, but then you aren't really getting much from CodeDeploy. What you should do depends on what you are trying to achieve.

Automatic deployment on push: You can get automatic deployments on commit to GitLab if you bridge their WebHooks with something that can authenticate to AWS. That might look like:

  1. Web Hook in GitLab that sends a push request to a Jenkins server you control.
  2. The Jenkins server uses the Git plugin to pull the source.
  3. The Jenkins server runs your build and test steps.
  4. The Jenkins server uses the CodeDeploy plugin to upload the build artifacts to S3 and create a deployment.

If you want to have manual deployments, you could do the same as above but manually trigger the Jenkins build.

Deploy manually only: Do the following when you want to deploy:

  1. Use git to checkout the commit you want to deploy.
  2. Run your build and test locally.
  3. Execute the AWS CLI deploy push command to upload your build artifacts to S3.
  4. Create a deployment in CodeDeploy using the bundle uploaded.
Sign up to request clarification or add additional context in comments.

1 Comment

An alternative is to setup a CodeCommitt repo mirror from gitlab as per this answer and doc

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.