Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

AWS SAM Deploy Missing option '--image-repository' or '--image-repositories'

Hi all,

I am trying to deploy to Lambda using `aws-sam-deploy` pipe and got an "Missing option '--image-repository' or '--image-repositories'" error when packaging. However, I have included "image_repositories" inside my `samconfig.toml` file and set SAM_CONFIG to `samconfig.toml` file.

I can build and deploy to AWS Lambda using Docker images from local without any problems with the command `sam build` and then `sam deploy`. So I do not think there's anything wrong with my `template.yaml` or `samconfig.toml`

What steps am I missing? Any help would be greatly appreciated.

Thank you!!

HCL

 

bitbucket-pipeline error message:

INFO: Using default authentication with AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY.

INFO: Start package...

SAM CLI now collects telemetry to better understand customer needs.

You can OPT OUT and disable telemetry collection by setting the environment variable SAM_CLI_TELEMETRY=0 in your shell. Thanks for your help! Learn More: https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/serverless-sam-telemetry.html

Usage: sam package [OPTIONS]

Try 'sam package -h' for help.

Error: Missing option '--image-repository' or '--image-repositories'

✖ Failed SAM package.

 

Relevant part of my pipeline (monorepo, so I have to cd into the specific directory where `samconfg.toml` and `template.yaml` resides:

          script:
            - apt-get update
            - cd project/function
-
 pipeatlassian/aws-sam-deploy:1.2.0
              variables:
                AWS_ACCESS_KEY_ID$AWS_ACCESS_KEY_ID
                AWS_SECRET_ACCESS_KEY$AWS_SECRET_ACCESS_KEY
                AWS_DEFAULT_REGION: $AWS_DEFAULT_REGION
                S3_BUCKET'lambda-function-bucket'
                STACK_NAME'MyLambdaFunction'
                CAPABILITIES: ['CAPABILITY_IAM']
                SAM_TEMPLATE'template.yaml'
                SAM_CONFIG"samconfig.toml"
                WAIT'true'
                WAIT_INTERVAL60

And here's my samconfig.toml:

```

version = 0.1
[default]
[default.deploy]
[default.deploy.parameters]
stack_name = "MyLambdaFunction"
s3_bucket = "lambda-function-bucket"
s3_prefix = "s3-prefix/"
region = "us-east-1"
capabilities = "CAPABILITY_IAM"
image_repositories = ["MyLambdaFunction=12345678910.dkr.ecr.us-east-1.amazonaws.com/my-lambda-function"]
confirm_changeset = false

 

1 answer

0 votes

@Han  In our pipe we are using sam package firstly.

image_repositories

parameter is in deploy section, not in package. I guess, it should be in both ones, since the command failed is `sam package`, not sam deploy .

However, if you don't want to use sam package, you can always use deploy command only. Be aware that for deploy that we don't support toml sam config yet.

Regarding aws lambda container image support, we are working on this right now (in aws-lambda-deploy pipe)

Regards, Galyna

Hi @Halyna Berezovska ,

If I understand you correctly, `image_repositories` has to be specified in both `aws-lambda-deploy` pipe and `samconfig.toml`?

I am deploying to Lambda using Docker images manually at the moment. When do you expect `aws-lambda-deploy` to support AWS Lambda container image deployment to be done?

Also, how do I use the deploy command only and what do I need to do to successfully deploy to Lambda from Docker Images?

@Han Unfortunately, right now in aws-sam-deploy we don't support images yet.

As a temporary workaround I suggest using sam package with proper config and sam deploy in bitbucket-pipelines without using aws-sam-deploy pipe.

This is to create function.

For update function, basically we use aws-lambda-deploy pipe, but it also does not support images yet.

I suspect you would prefer aws-sam-deploy pipe, where you have samconfig and you would like this samconfig to be support for packaging and deploying.

This is nice improvement and I'll discuss it within the team and notify you with update.

For now I suggest using aws sam cli (we recommend to follow their installation - downloading binary https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/serverless-sam-cli-install-linux.html#serverless-sam-cli-install-linux-sam-cli)

Regards, Galyna

@Halyna Berezovska

 

Correct. I would like to have alignment between both manual `sam deploy` and CD via aws-sam-deploy pipe.

AWS just released and AWS SAM Pipelines that generates support for serveless applications, image or otherwise. https://aws.amazon.com/blogs/compute/introducing-aws-sam-pipelines-automatically-generate-deployment-pipelines-for-serverless-applications/. Unfortunately, it only supports Jenkins, GitHub, and GitLab.

When can I expect Bitbucket to reach feature parity with this?

HCL

"I suspect you would prefer aws-sam-deploy pipe, where you have samconfig and you would like this samconfig to be support for packaging and deploying."

This would be an excellent feature. I haven't been able to use the aws-sam-deploy pipe thus far because it's useless to me without accepting a samconfig toml file for the deploy command. Currently I have to use custom images with the AWS SAM CLI installed which are rather large and increase my build time.

If there's an issue link or a roadmap available with this feature on it I'd love a link so I can come back and check periodically to see if this feature has been added.

I wonder how anyone using this pipe is avoiding getting errors without the 

--no-fail-on-empty-changeset option available? CI/CD pipelines surely hit the "Error: No changes to deploy. Stack stack-name is up to date'." error all the time?

Solved using AWS SAM CLI directly. @Daniel Coppell 

FYI, deployment time is highly dependent the size of the docker image, but I find it faster than my local machine probably from higher bandwidth connection to AWS

 

- step:
name: CD
caches:
- pip
script
:
apt-get update
    - pip install awscli
- pip install aws-sam-cli
- aws configure --profile cicd set AWS_ACCESS_KEY_ID ${AWS_ACCESS_KEY_ID}
- aws configure --profile cicd set AWS_SECRET_ACCESS_KEY ${AWS_SECRET_ACCESS_KEY}
- sam build --profile cicd
- sam deploy --profile cicd
services:
- docker
Like Steffen Opel _Utoolity_ likes this

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Published in Bitbucket

⭐ Calling all Bitbucket and DevOps experts: Special showcase opportunity ⭐

Hi, Bitbucket community! Are you a DevOps practitioner (or know one in your network)? Do you have DevOps tips, tricks, or learnings you'd like to share with the community? If so, we'd love to hea...

1,436 views 4 7
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you