Skip to content

sam build broken after upgrading SAM CLI when using ECR (backward compatibility issue) #3239

@romanek-adam

Description

@romanek-adam

Description:

I have a SAM application with an AWS ECR repository configured as the storage for the app snapshots/releases.

So far I was using just sam build and sam deploy to deploy my SAM application. It used to work with SAM CLI 1.24.1.

Unfortunately after I upgraded to SAM CLI 1.27.2 it stopped working. Now sam build says:

The resource AWS::Serverless::Function 'HelloFunction' has specified ECR registry image for ImageUri. It will not be built and SAM CLI does not support invoking it locally.

Upgrading SAM CLI to the current latest version 1.30.0 doesn't help either.

This is a breaking change. Not sure if it was announced anywhere. Also it seems the problem was introduced as part of #2934.

Honestly I don't know what I should do now and how I should fix it. For now I can stick to the SAM CLI version that works for me but this is only a temporary solution.

Steps to reproduce:

Create a SAM app with a template including:

Resources:
  HelloFunction:
    Type: AWS::Serverless::Function
    Properties:
      PackageType: Image
      ImageUri: <account-number>.dkr.ecr.<region>.amazonaws.com/hello-app
    Metadata:
      Dockerfile: Dockerfile
      DockerContext: ./app
      DockerTag: python3.8-v1

Use sam build and then guided deploy with SAM CLI 1.24.1. Then upgrade to SAM CLI 1.27.2 - sam build will stop working.

Observed result:

sam build doesn't build the image anymore and sam deploy doesn't push the image to ECR. As a result sam deploy fails.

Expected result:

sam build should build the image, as it used to. sam deploy should push the image to ECR and update the app without issues.

Additional environment details (Ex: Windows, Mac, Amazon Linux etc)

  1. OS: Ubuntu 20.04
  2. sam --version: 1.24.1, 1.27.2, 1.30.0
  3. AWS region: Ireland (eu-west-1)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions