How to achieve CD using Gitlab CI and aws cdk

Viewed 1396

We have our application code (Java) in Gitlab and we are using Gitlab CI to build, test and create docker image (which is then pushed to AWS ECR)

To provision our infra, we are using aws cdk (which is in a separate project in Gitlab)

Whenever we make some changes in our application(java), we have to manually update the docker tag in infra code (aws cdk) and push it so that deployment is updated.

Is there a way to automate this?

PS. We can not have both java and infra code in one repository

4 Answers

I don't have experience with Gitlab, so take following advice more like an idea than an exact guide:

Updating the docker tag in infra code can be replaced by additional step in application build which would set the new tag value in the AWS Parameter Store variable.

Run of infra code build can be automated by creating a trigger causing run of infra code build after application build has successfully finished.

Infra code build will then read the new tag value from the AWS Parameter Store variable.

Depending on the wider architecture conext, my hunch would be you (collective) would want some kind of promotion activity to take place - validate unchanged libraries etc. for security vulnerabilities, make the application available to other integration teams for testing before release - and having that activity centralised would be a natural step. Maybe something the CDK owners value for catching issues if they face integration challenges? The point being, the retagging in the CDK project and eventual release is then handled by the promotion job, which is invoked by multiple projects as and when there are changes.

How I understand your issue:

  • you package app into Docker image and push to registry
  • you want that you infra code in cdk automatically pick next tag

In general, you use tags to prevent this kind of behaviour.

However, why not tag your app image with latest tag and use it in cdk code?

Related