Skip to content

Conversation

@abhishektang
Copy link

Summary

Implements --resolve-image-repos support for sam package command to automatically create ECR repositories, matching the behavior of sam deploy.

Resolves

Closes #3888

Changes

  • Added --resolve-image-repos CLI option to sam package
  • Calls sync_ecr_stack() to auto-create managed ECR repositories
  • Added validation requiring --s3-bucket when flag is used
  • Added conflict detection with --image-repositories
  • Added unit tests for validation logic

Testing

  • All existing tests pass
  • Added new unit test for validation
  • Tested with real AWS resources (ECR repos created successfully)

Use Case

Enables CI/CD workflows to package once and deploy to multiple environments in parallel using AWS-managed ECR repositories, avoiding manual repo creation and permission complexity.

Implements issue aws#3888 to auto-create ECR repositories during
packaging, matching sam deploy behavior. Enables package-once,
deploy-many CI/CD workflows with managed ECR repos.

- Add --resolve-image-repos CLI option to sam package
- Call sync_ecr_stack() to auto-create managed ECR repositories
- Add validation requiring --s3-bucket when flag is used
- Add conflict detection with --image-repositories
- Add unit tests for validation logic

Closes aws#3888
@abhishektang abhishektang requested a review from a team as a code owner December 2, 2025 16:53
@github-actions github-actions bot added area/package sam package command pr/external stage/needs-triage Automatically applied to new issues and PRs, indicating they haven't been looked at. labels Dec 2, 2025
Copy link
Contributor

@vicheey vicheey left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for your contribution. Since this is a remote operation, do you mind add integration test as well.

super().__init__(message=message_fmt)


class PackageResolveImageReposAndImageReposSetError(UserException):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I do not see this class being used anywhere.

Copy link
Author

@abhishektang abhishektang Dec 8, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah!, my apologies I implemented this class to check exceptions in my testing, but I haven't included my testing files in here so the reason why this class is unused in the PR.

Execute packaging based on the argument provided by customers and samconfig.toml.
"""
if self.resolve_image_repos:
from samcli.lib.bootstrap.companion_stack.companion_stack_manager import sync_ecr_stack
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Following the existing pattern, the import should be at the top of the file.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have updated this PR now, and made this above change. I have also added the integration tests with this update.

@abhishektang abhishektang requested a review from vicheey December 8, 2025 09:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/package sam package command pr/external stage/needs-triage Automatically applied to new issues and PRs, indicating they haven't been looked at.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Feature request: Add --resolve-image-repos support for package command

2 participants