0
votes

I'm using CodePipeline and CodeDeploy to automate the deployment process. The code sourcing and docker image build happen outside of AWS. I have a git pipeline outside of AWS that builds/packages a docker image on code push and pushes the docker image to ECR.

As soon as the docker image is pushed to AWS ECR is kicks the AWS pipeline and starts the ECR source stage. The output artifact from this stage can't be passed directly into the deploy stage. It requires an AppSpec file.

{
  "version": "0.0",
  "Resources": [
    {
      "awscodestar-gateway-api-lambda-HelloWorld": {
        "Type": "AWS::Lambda::Function",
        "Properties": {
          "Name": "awscodestar-gateway-api-lambda-HelloWorld",
          "Alias": "live",
          "CurrentVersion": "3",
          "TargetVersion": "4"
        }
      }
    }
  ]
}

I'm not able to figure out how to pass the Docker image URL and AppSpec file to the deploy stage so that it deploys the image to lambda.

The reason for using the CodeDeploy stage for the lambda is it supports blue/green deployment and versioning.

I can't find any docs related to lambda deployment where ECR acts as a source.

Please, let me know if anyone has any workarounds.

1

1 Answers

0
votes

Using ECR as the source you specify the repo and the tag:

Name: Source
Actions:
  - InputArtifacts: []
    ActionTypeId:
      Version: '1'
      Owner: AWS
      Category: Source
      Provider: ECR
    OutputArtifacts:
      - Name: SourceArtifact
    RunOrder: 1
    Configuration:
      ImageTag: latest
      RepositoryName: my-image-repo

    Name: ImageSource

So you already know the docker image URL.

A pipeline can have multiple source stages (https://docs.aws.amazon.com/codebuild/latest/userguide/sample-pipeline-multi-input-output.html) so presumably one could be ECR and another a repo or bucket with the appspec.