What is the best way to bootstrap Pulumi project v...
# general
c
What is the best way to bootstrap Pulumi project via CLI in automated fashion (non-interactive)? I am running following script:
Copy code
export PULUMI_CONFIG_PASSPHRASE=testtest

pulumi new gcp-typescript \
  --name 02-host-vpc \
  --description "GCP host VPC" \
  --stack stage \
  --secrets-provider passphrase \
  --yes \
  --non-interactive \
  --force

pulumi config set gcp:project "test"
This creates new project
Pulumi.yaml
and
Pulumi.stage.yaml
as required but it overwrites my
index.ts
file. Is there any way to stop that? Thanks 😉
l
You have an existing
index.ts
but you still need to bootstrap the project? Why is that?
c
Well I have a “template” project that it is being bootstrapped for each GCP project/customer so common items like admin gcp project, host VPC, etc are automatically created at the beginning. Hope it makes sense?
l
Yes, but you should keep the Pulumi project file (
Pulumi.yaml
) also under source control and only create a new stack non-interactively when you want to roll this out.
That is one way to do it. Another is to have the reusable code in a language specific package (npm for javascript, egg for python, …) and re-use this in a project which is specifically set up per customer
b
what you can do it to have generic__main__.py for python or index ts in your case and cp it to index.ts, that's what I do in pulumi_init script
c
Yes I was thinking about
cp
after bootstrapping is done. Is there a way to create a custom template? Perhaps this will be more elegant solution?
b
You can pass a url to
pulumi new
. The examples are here: https://github.com/pulumi/templates eg:
pulumi new <https://github.com/pulumi/templates/tree/master/kubernetes-python>
just replace the built in template with your own
c
Nice - Thanks👍