feat!: replace docker artifact packager with cruxstack/buildkit provider - #9
Merged
Conversation
sgtoj
force-pushed
the
feat/buildkit-artifact-provider
branch
2 times, most recently
from
May 29, 2026 11:39
2f2ac2c to
eba8024
Compare
Swap the bot_artifact module (github.com/cruxstack/terraform-docker-artifact-packager) for the cruxstack/buildkit Terraform provider, which builds the Lambda deployment package from the Dockerfile via BuildKit's gRPC API rather than driving the Docker CLI/daemon through a module. Changes: - Add the cruxstack/buildkit provider to required_providers (>= 0.0.1). - Replace module.bot_artifact with a buildkit_artifact resource plus a buildkit_context data source. The context digest is wired into the resource triggers so rebuilds happen on content change; bot_force_rebuild_id remains supported as an additional trigger. - Point the Lambda at buildkit_artifact.bot.artifact_path and restore source_code_hash via buildkit_artifact.bot.artifact_sha256. - Build args (BOT_VERSION, BOT_REPO), build target (package), and the source path (/tmp/package.zip) are preserved, so the produced package is equivalent. - gitignore .terraform.lock.hcl (root and nested) since this is a reusable module and consumers generate their own lock files. - Update README prerequisites/build description to reference BuildKit and the provider's endpoint discovery; correct bot_force_rebuild_id type to string. State migration (no manual `terraform state rm` required): - Add a `removed` block for module.bot_artifact with lifecycle.destroy = false so existing deployments forget the old module from state on the next plan/apply instead of erroring. The old module's resources were backed by providers no longer used here (docker, archive, null, random); without this, terraform/opentofu tries to destroy orphaned resources and fails because those providers are no longer configured. - Bump required_version to >= 1.7 (minimum for `removed` blocks; satisfied by both Terraform and OpenTofu 1.7+). - Temporarily re-declare the docker/archive/null/random providers so `init` succeeds for upgrading users whose state still references them. The `removed` block and these legacy provider declarations are transitional and should be dropped in a follow-up release once consumers have upgraded. The buildkit provider auto-discovers the BuildKit endpoint embedded in Docker Desktop / OrbStack / Colima, honors BUILDKIT_HOST, and can supervise an embedded rootless buildkitd on Linux. BREAKING CHANGE: The module now requires the cruxstack/buildkit provider, a reachable BuildKit endpoint, and Terraform/OpenTofu >= 1.7 (previously >= 1.3). Run `terraform init` (or `tofu init`) to install the new provider; existing deployments are migrated automatically via a `removed` block, so no manual `terraform state rm module.bot_artifact` is needed. A BuildKit endpoint must be available (Docker Desktop/OrbStack/Colima, BUILDKIT_HOST, or an embedded buildkitd). The artifact is now written to a fixed path (dist/package.zip) rather than a hashed filename.
sgtoj
force-pushed
the
feat/buildkit-artifact-provider
branch
from
May 29, 2026 11:40
eba8024 to
90d97d7
Compare
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.
Summary
Replaces the
bot_artifactmodule (github.com/cruxstack/terraform-docker-artifact-packager) with thecruxstack/buildkitTerraform provider. The Lambda deployment package is now built from the Dockerfile via BuildKit's gRPC API instead of driving the Docker CLI/daemon through a module.Warning
This is a major version bump when merged to
main. Do not merge until the release is planned.Changes
cruxstack/buildkitprovider torequired_providers(>= 0.0.1).module.bot_artifactwith abuildkit_artifactresource plus abuildkit_contextdata source. The context digest is wired into the resourcetriggersso rebuilds happen on content change;bot_force_rebuild_idremains supported as an additional trigger.buildkit_artifact.bot.artifact_pathand restoresource_code_hashviabuildkit_artifact.bot.artifact_sha256.BOT_VERSION,BOT_REPO), build target (package), and the source path (/tmp/package.zip) so the produced package is equivalent..terraform.lock.hcl(root and nested) since this is a reusable module and consumers generate their own lock files.bot_force_rebuild_idtype tostring.State migration (no manual
state rm)Existing deployments had
module.bot_artifactin state, backed by providers this module no longer uses (kreuzwerker/docker,hashicorp/archive,hashicorp/null,hashicorp/random). Without handling, removing the module from config makes Terraform/OpenTofu try to destroy those orphaned resources and fail because their providers are no longer configured — requiring a manualterraform state rm module.bot_artifact.This PR migrates automatically:
removedblock formodule.bot_artifactwithlifecycle { destroy = false }, so the next plan/apply forgets the old module from state without destroying anything.required_versionto>= 1.7(minimum forremovedblocks; works on both Terraform and OpenTofu 1.7+).docker/archive/null/randomproviders soinitsucceeds for upgrading users whose state still references them.The
removedblock and the legacy provider declarations are transitional and should be dropped in a follow-up release once consumers have upgraded.Breaking changes
cruxstack/buildkitprovider and a reachable BuildKit endpoint instead of theterraform-docker-artifact-packagermodule.>= 1.3).terraform init/tofu initto install the new provider.BUILDKIT_HOST, or an embedded rootlessbuildkitdon Linux.dist/package.zip) rather than a hashed filename.Validation
terraform fmt -checkon.tffiles — cleanterraform init -backend=false+terraform validate— success (providercruxstack/buildkit v0.0.1installs and config validates)Notes
~> 1.0, but onlyv0.0.1is currently published to the registry; the constraint is pinned to>= 0.0.1accordingly. Bump to~> 1.0once a 1.x release is available.