Pulumi integration with Bazel
Requirements:
pulumi
installed
Usage:
- Load the pulumi dependency and this workspace as an external workspace:
load("@bazel_tools//tools/build_defs/repo:git.bzl", "git_repository")
git_repository(
name = "pulumi_bazel",
remote = "https://github.com/ryanrasti/pulumi-bazel.git"
)
http_archive(
name = "pulumi",
sha256 = "2d7e0ce78520799b130e3525378f353a339981d53064883f794a670c9cc5d4e8",
url = "https://github.com/pulumi/pulumi/releases/download/v3.35.3/pulumi-v3.35.3-linux-x64.tar.gz",
build_file = "@pulumi_bazel//:pulumi.BUILD",
)
- Use the rule
pulumi_python
in the directory with your pulumi project. Seetest/project/BUILD
for an example. - Run using
bazel run //directory/to/pulumi/project:pulumi
. Thepulumi
target is created for you and should be used in place of the regular invocation topulumi
Note: you will likely need pip
dependencies via Bazel:
- You should remove the
venv
configuration in yourPulumi.yaml
file - You will need to declare
pip
dependencies in yourWORKSPACE
file. See./WORKSPACE
for an example.
Note: since the likely use-case is that you will run pulumi commands via bazel
and
want to keep the outputs (e.g., stack yaml files) in source control, the generated
//...:pulumi
target is run in the actual source directory (rather than a generated one).
TODO: user should have an option to use a local pulumi install rather than use the hermetic one. TODO: user shouldn't need to copy two dependencies -- pulumi dependency should be automatic.