Add --package option to cfn submit for pre-built zip submission#1121
Open
cv-dote wants to merge 5 commits intoaws-cloudformation:masterfrom
Open
Add --package option to cfn submit for pre-built zip submission#1121cv-dote wants to merge 5 commits intoaws-cloudformation:masterfrom
cv-dote wants to merge 5 commits intoaws-cloudformation:masterfrom
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Issue #, if available: #291
Description of changes:
Summary
Add a
--package/-poption tocfn submitthat uploads a pre-built schema handler package zip instead of building one from the current project. This enables common workflows such as building once (for example, inside a Docker container) and registering the same artifact across multiple regions, or registering a third-party zip without rebuilding.Motivation
Today
cfn submittightly couples the packaging step with the upload step: the CLI always builds a zip from the current working directory and then uploads it. There is no way to feed in an already-built zip, so users can't:cfn submit --dry-run.Changes
Behavior
--package <path>and-p <path>options tocfn submit.--packageis used, the CLI validates the zip, readstypeNameandartifact_typefrom its.rpdk-configentry, and uploads the zip's bytes as-is.--packagecannot be combined with--dry-run,--use-docker, or--no-docker(those flags configure the packaging step that--packageskips). The CLI exits with a clear error if the user tries to combine them.--packagepath does not read.rpdk-configfrom the current working directory, so the option works outside a CloudFormation CLI project.--role-arnor--no-rolemust be specified together with--package.When
--packageis not used, behavior is unchanged: the original packaging workflow runs with the same inputs, outputs, and log messages as before.Code
src/rpdk/core/package_validator.pymodule that opens the zip, reads.rpdk-config, resolvesartifact_type(with a RESOURCE fallback for legacy packages), asserts required entries, and logscli-versionfrom.cfn_metadata.jsonif present. All failures surface asInvalidProjectError.Projectthat builds a minimal instance from the validator's output. Setsschema = {}so_upload's automatic-role branch stays inactive; the caller must provide--role-arnor--no-role. No existing methods are modified._submit_existing_packagehelper and a single-branch dispatch insubmit(). The flag-combination check runs before any I/O.tests/test_submit.pycovering parser, dispatch, flag conflicts, and end-to-end upload byte identity via a mocked_upload.doc_source/resource-type-cli-submit.md(Synopsis, Options, Examples) and a one-line example inREADME.md.Testing
tests/test_submit.py.tests/test_project.pyforProject.from_package.tests/test_package_validator.pycovering happy paths (RESOURCE / MODULE / HOOK), all validation error paths (missing path, non-zip, missing.rpdk-config, invalid JSON, unknown artifact_type, missingtypeName, missingschema.json), the legacy RESOURCE fallback, and the best-effort metadata log.tests/test_cli.py,tests/test_project.py,tests/test_package_validator.py,tests/test_submit.py, andtests/test_upload.pypass (206 tests).pre-commit(black, isort, flake8, pylint) passes. No new pylint warnings introduced; pylint rating unchanged at 9.98/10.Example
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.