https://pulumi.com logo
c

chilly-laptop-44574

03/26/2020, 9:55 AM
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

limited-rainbow-51650

03/26/2020, 10:03 AM
You have an existing
index.ts
but you still need to bootstrap the project? Why is that?
c

chilly-laptop-44574

03/26/2020, 10:09 AM
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

limited-rainbow-51650

03/26/2020, 10:10 AM
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

better-actor-92669

03/26/2020, 10:39 AM
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

chilly-laptop-44574

03/26/2020, 11:26 AM
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

billowy-army-68599

03/26/2020, 4:15 PM
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

chilly-laptop-44574

03/26/2020, 10:09 PM
Nice - Thanks👍
2 Views