Skip to content

Conversation

pedropinho7
Copy link

@pedropinho7 pedropinho7 commented Oct 9, 2025

Description

This PR adds support for executing shell commands inside Docker containers when build_in_docker = true.
Previously, shell commands specified in the commands parameter were always executed on the host machine, even when Docker builds were enabled.

Motivation and Context

When using build_in_docker = true, users often need to run commands (like package managers or build tools) that
are only available in the Lambda runtime environment. For example, installing Python packages with native
extensions that need to be compiled for the specific Lambda runtime.
#307

Breaking Changes

No breaking changes. This is fully backward compatible:

  • If Docker is not configured, shell commands execute on the host as before
  • Existing functionality and behavior are preserved
  • All existing tests continue to pass

How Has This Been Tested?

  • I have updated at least one of the examples/* to demonstrate and validate my change(s)
    • Added package_with_docker_shell_commands example in examples/build-package/main.tf
  • I have tested and validated these changes using one or more of the provided examples/* projects
    • Tested Docker execution with shell commands
    • Verified working directory tracking with cd commands
    • Tested error handling for failed commands
  • I have executed pre-commit run -a on my pull request
    • All hooks passing (terraform_fmt, terraform_docs, terraform_validate, tflint, etc.)

- Execute shell commands inside Docker container when build_in_docker=true
- Add automatic Docker image pull if not found locally
- Fix critical bug: handle query=None in BuildPlanManager.execute()
- Add 4 unit tests for Docker and host execution paths
- Update README with shell commands documentation and example
- Add example module demonstrating Docker shell commands

This allows users to run package managers and build tools that are only
available in the container environment.

All 11 tests passing (7 existing + 4 new).
  - Apply ruff formatting fixes
  - Update example documentation with terraform-docs
@pedropinho7 pedropinho7 changed the title Feat/docker shell commands feat: docker shell commands Oct 9, 2025
@pedropinho7 pedropinho7 changed the title feat: docker shell commands feat: Docker shell commands Oct 9, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant