amazon-web-servicesaws-lambdagithub-actionsamazon-ecr

AWS CLI - Create Lambda With Public ECR Url Keeps Erroring


I am using GitHub Actions to first check if a lambda exists and and if it doesn't create one and just inject a placeholder container from NGINX the next step in the pipeline will build and replace the contaier in the lambda. I log in to ECR so I am creditialed but my pipeline errors every time saying the url is invlaid

Code:

    - name: Add Lambda
      id: lamda-managment
      shell: bash
      env:
        ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }}
        ECR_REPOSITORY: ${{env.ECR_REPOSITORY}}
        IMAGE_TAG: ${{env.ENV}}
      run: |
        aws lambda get-function --function-name ${{env.FUNCTION_NAME}} || \
        aws lambda create-function \
          --function-name ${{env.FUNCTION_NAME}} \
          --role arn:aws:iam::${{env.AWS_ACCOUNT_ID}}:role/lambda-ex \
          --package-type Image \
          --code ImageUri=public.ecr.aws/nginx/nginx:alpine-slim

Error:

when calling the CreateFunction operation: Source image public.ecr.aws/nginx/nginx:alpine-slim is not valid.

Solution

  • I had to push my own nginx image to my private ECR