Skip to content

Conversation

@abhishektang
Copy link
Contributor

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.

@abhishektang abhishektang requested a review from vicheey December 8, 2025 09:01
@seshubaws
Copy link
Contributor

Hi @abhishektang thanks for all your work on this! There seems to be a small linting error making some tests fail, could you check this?

@abhishektang
Copy link
Contributor Author

Hey, @seshubaws I have fixed the linting error, please try to run the PR workflow now.

@reedham-aws
Copy link
Contributor

Seems like the linting error was fixed but there are test failures as well.

@seshubaws
Copy link
Contributor

seshubaws commented Jan 16, 2026

@abhishektang This test seems to be the only one failing

FAILED tests/unit/commands/samconfig/test_samconfig.py::TestSamConfigForAllCommands::test_package - AssertionError: expected call not found.
Expected: do_cli('/private/var/folders/kg/7q73ww8s3llgyl61c9z_j5g40000gn/T/tmpsj7xpbql/mytemplate.yaml', 'mybucket', '123456789012.dkr.ecr.us-east-1.amazonaws.com/test1', None, 'myprefix', 'mykms', 'output.yaml', True, True, False, {'m1': 'value1', 'm2': 'value2'}, {'function': {'profile_name': 'profile', 'profile_owner': 'owner'}}, 'myregion', None, False)
  Actual: do_cli('/private/var/folders/kg/7q73ww8s3llgyl61c9z_j5g40000gn/T/tmpsj7xpbql/mytemplate.yaml', 'mybucket', '123456789012.dkr.ecr.us-east-1.amazonaws.com/test1', None, 'myprefix', 'mykms', 'output.yaml', True, True, False, {'m1': 'value1', 'm2': 'value2'}, {'function': {'profile_name': 'profile', 'profile_owner': 'owner'}}, 'myregion', None, False, False)

- Add race condition tests for _create_layer_directory
- Fix test_samconfig.py parameter count (16 params for resolve_image_repos)
- Add resolve_image_repos verification tests in test_command.py
- Add sync_ecr_stack execution test in test_package_context.py
- Regenerate schema/samcli.json

Fixes: Lines 288-308 (race condition handling) and lines 107-112 (resolve_image_repos path)
@abhishektang
Copy link
Contributor Author

Hey @seshubaws @reedham-aws, I've fixed the unit test failures and added test coverage for the _create_layer_directory method that was missing from test runs.

@abhishektang
Copy link
Contributor Author

Hey @vicheey, kindly can you review my pr. Thankyou!

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.

@seshubaws seshubaws added this pull request to the merge queue Jan 22, 2026
Merged via the queue into aws:develop with commit 4f63f21 Jan 22, 2026
42 checks passed
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

4 participants