Skip to content

feat: add ability to pass docker build params in template#8913

Open
reedham-aws wants to merge 5 commits intoaws:developfrom
reedham-aws:docker-args
Open

feat: add ability to pass docker build params in template#8913
reedham-aws wants to merge 5 commits intoaws:developfrom
reedham-aws:docker-args

Conversation

@reedham-aws
Copy link
Copy Markdown
Contributor

Which issue(s) does this change fix?

#8656

Why is this change necessary?

It had not been previously possible to pass in standard Docker arguments to the CLI build. While this isn't a big issue, it's a nice quality of life feature to add.

How does it address the issue?

Adds the ability to read extra parameters from the metadata of a SAM template, similar to how we already read build args that go into the Dockerfile. These parameters are then appended to the Docker/Finch CLI subprocess call.

What side effects does this change have?

Should have none because this is opt-in. Integration tests should confirm this.

Mandatory Checklist

PRs will only be reviewed after checklist is complete

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

Copy link
Copy Markdown
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

This review has been superseded by a newer review.

Copy link
Copy Markdown
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

This review has been superseded by a newer review.

@reedham-aws reedham-aws marked this pull request as ready for review April 17, 2026 20:19
@reedham-aws reedham-aws requested a review from a team as a code owner April 17, 2026 20:19
Copy link
Copy Markdown
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

Code Review Results

Reviewed: 09c3cd5..31cf82c
Files: 6
Comments: 2

if not isinstance(docker_build_args, dict):
raise DockerBuildFailed("DockerBuildArgs needs to be a dictionary!")

if docker_build_extra_params is not None and not isinstance(docker_build_extra_params, list):
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

[INPUT_VALIDATION] The validation checks that DockerBuildExtraParams is a list, but does not verify that each element is a string. In CLIBuildClient.build_image, the list is passed directly to cmd.extend(extra_params) which feeds into subprocess.Popen. If a user provides non-string elements (e.g., integers, booleans, nested lists/dicts in their template metadata), this will raise a TypeError at runtime.

Consider adding element-type validation:

if docker_build_extra_params is not None and not isinstance(docker_build_extra_params, list):
   raise DockerBuildFailed("DockerBuildExtraParams needs to be a list!")

if docker_build_extra_params is not None and not all(isinstance(p, str) for p in docker_build_extra_params):
   raise DockerBuildFailed("All items in DockerBuildExtraParams must be strings!")

@aws aws deleted a comment from github-actions bot Apr 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/build sam build command area/local/invoke sam local invoke command area/local/start-api sam local start-api command area/local/start-invoke pr/internal

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants