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:
<span>INFO: Using default authentication with AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY.</span>
<span>INFO: Start package...</span>
<span>SAM CLI now collects telemetry to better understand customer needs.</span>
<span>You can OPT OUT and disable telemetry collection by setting the</span><span> environment variable SAM_CLI_TELEMETRY=0 in your shell.</span><span> Thanks for your help!</span><span> Learn More: <a href="https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/serverless-sam-telemetry.html" target="_blank" rel="noopener nofollow noreferrer">https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/serverless-sam-telemetry.html</a></span>
<span>Usage: sam package [OPTIONS]</span>
<span>Try 'sam package -h' for help.</span>
<span>Error: Missing option '--image-repository' or '--image-repositories'</span>
<span>✖ Failed SAM package.</span>
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
- pipe: atlassian/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_INTERVAL: 60
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