thankful-elephant-10650
02/07/2023, 8:21 PMbroad-processor-92400
02/07/2023, 9:00 PM./pants package --filter-tag-regex=stack1 ::
and then separately cdk deploy ...
, with the CDK code referring to the appropriate dist/path.to.target/whatever.zip
path for lambdas.
We have multiple stacks deployed in separate CI jobs, so we set tags=["stack1"]
(etc.) on the targets required for each stack, and use the --filter-tag-regex
to only build what's required for each deploy.thankful-elephant-10650
02/07/2023, 9:13 PMthankful-elephant-10650
02/07/2023, 9:17 PMbroad-processor-92400
02/07/2023, 9:30 PMchilly-holiday-77415
02/08/2023, 8:47 AMcomplete_platforms
to build lambdex.
In CodePipeline (using CDK pipelines), my synth step now looks like (again, could probably be refined):
"npm install -g cdk",
"./pants version",
"./pants package ::",
"cd infrastructure/main_service",
"cdk synth --app ../../dist/infrastructure.main_service/cdk_infra.pex -o $CODEBUILD_SRC_DIR/cdk.out",
chilly-holiday-77415
02/08/2023, 8:49 AMpython_sources(
name="cdklib",
dependencies=[
"//:reqs#aws-cdk-asset-awscli-v1",
"//:reqs#jsii",
],
)
pex_binary(
name="cdk_infra",
entry_point="app.py",
execution_mode="venv",
venv_site_packages_copies=True,
)
famous-river-94971
02/08/2023, 8:37 PMexperimental_run_shell
stuff.famous-river-94971
02/08/2023, 8:38 PMlerna
in TypeScript, but pants
for Python was the next best thing I could find.chilly-holiday-77415
02/09/2023, 9:21 AMpants package
to synth?famous-river-94971
02/09/2023, 3:15 PMfamous-river-94971
02/09/2023, 3:16 PMpython_sources(name="cdk_source", sources=["**/*.py"])
files(name="cdk_files", sources=["cdk.json", "cdk.context.json"])
experimental_run_shell_command(
name="cdk_diff",
tags=["cdk_diff"],
command="../_scripts/cdk.sh diff --no-color",
dependencies=[
":cdk_files",
":cdk_source",
],
workdir="aws/projects/core_infrastructure",
)
experimental_run_shell_command(
name="cdk_deploy",
tags=["cdk_deploy"],
command="../_scripts/cdk.sh deploy --progress events --require-approval never '**'",
dependencies=[
":cdk_files",
":cdk_source",
],
workdir="aws/projects/core_infrastructure",
)
famous-river-94971
02/09/2023, 3:16 PM_cdk.sh
#! /bin/bash
set -e
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
source "$SCRIPT_DIR/utils.sh"
source_virtualenv
set_aws_profile
cdk_version=$(find_aws_cdk_version)
npx -y aws-cdk@"$cdk_version" "$@"
famous-river-94971
02/09/2023, 3:18 PM./pants \
--changed-since=origin/main \
--changed-dependees=transitive \
--filter-tag-regex='^cdk_diff$' \
list | parallel \
-L1 \
--rpl '{project_name} $_ = s/(.*\/)(.*):.*/$2/r' \
--tagstring '{project_name} |' \
-P "$CONCURRENCY" \
./pants run
famous-river-94971
02/09/2023, 3:19 PMpants
just had a --parallel <n>
flag. Piping to gnu parallel
adds a lot of visual complexity to the command.famous-river-94971
02/09/2023, 3:19 PMthankful-elephant-10650
02/09/2023, 3:20 PMfamous-river-94971
02/09/2023, 3:22 PMlerna
, they automatically add git
tags to specify when things were deployed. So I could just say --changed
and lerna
would do all the heavy lifting. This doesn't exist in pants
. So I basically recreated what lerna does manually in CI:famous-river-94971
02/09/2023, 3:23 PM--changed-since
when deploying on main
looks for the most recent git tag
(sorting by timestamp) and uses that.famous-river-94971
02/09/2023, 3:24 PMfamous-river-94971
02/09/2023, 3:25 PMfamous-river-94971
02/09/2023, 3:26 PMpants
intends to do.famous-river-94971
02/09/2023, 3:26 PMpants
has been _rough_: https://github.com/pantsbuild/pants/issues/14111famous-river-94971
02/09/2023, 3:27 PMenough-analyst-54434
02/19/2023, 6:55 PMscie-pants
for your pants
binary (these install instructions: https://www.pantsbuild.org/v2.15/docs/installation), it works for any version of Pants all the way back to late 1.x and, although Pants still needs 3.8 or 3.9 you now don't have to care about that since scie-pants
provides its own hermetic Python to run Pants with.famous-river-94971
02/22/2023, 3:12 PMenough-analyst-54434
02/22/2023, 3:59 PMscie-pants
instead of the ./pants
script are only present in 2.15.x; however, scie-pants
can in fact be used to run all versions of Pants. You can use it now for 2.14, 2.0, 1.26, etc. IOW, scie-pants
is a drop in replacement for ./pants
- retroactively.famous-river-94971
02/22/2023, 4:16 PMfamous-river-94971
05/24/2023, 7:11 PMscie-pants
today. It's great to decouple the interpreter required for pants
from my application! I suggested a few edits to the documentation and also left some additional information in this GitHub issue: https://github.com/pantsbuild/pants/issues/14111#issuecomment-1561759153. I'm impressed by how fast the interpreter download is š šØ