https://pulumi.com logo
#getting-started
Title
# getting-started
n

narrow-needle-95047

01/03/2024, 6:45 AM
Hi team! I'm aiming to have the following setup: 1. Three stacks (dev, stg, prod). 2. Automated deployment to respective stack by GitHub actions. a. On push to respective branch the code will be deployed. 3. Keep pulumi infrastructure code in the same repository as the software in a different folder for simplicity. 4. Templates for specific resources, e.g. AWS Lambda, DynamoDB, etc. shared across my microservices for uniformity (let’s say in an importable python module). a. I plan to parametrise those to my needs, e.g. certain AWS Lambda function would have a timeout of 5 seconds and another one would have 30 seconds. While I have understanding for 1, 2 and 3, I would like to ask for help with 4: • As I understand, for every project I need to run
pulumi init
and it then creates the structure which I can change. ◦ How could I automate this process? ◦ As I understand, I need a script that will: ▪︎ create the stacks (
pulumi stack init ...
) ▪︎ remove the files created by automation ▪︎ then, during deployment, get the module to the infrastructure folder ▪︎ then the module will figure out what infra it is deploying with dynamic naming by looking into cloud-specific code folder Is it the right thought process? If you have any example to point me to, I would really appreciate it! Any other feedback is also very welcome!
Sorry if I'm tagging a wrong person @steep-sunset-89396, maybe you could advise on the above?
g

great-sunset-355

01/03/2024, 11:40 AM
I am not sure what is your goal. If you are trying to create stacks dynamically or only resources/components? For resources, you'd create Component Resources and then share them as a library/package. Should you need to create pulumi stacks dynamically, you can use
pulumi cli
or automation API for more control.
s

salmon-account-74572

01/03/2024, 8:58 PM
If you’re truly looking for templates, you can totally create your own templates that will be consumed by
pulumi new
. A little-known fact is that
pulumi new
supports passing a path or URL to a template in order to use that template when creating the new project. This blog post talks a bit more about the process: https://www.pulumi.com/blog/how-to-create-and-share-a-pulumi-template/ Does that help?
You could take a look at any of the existing templates in https://github.com/pulumi/templates (the default location where
pulumi new
looks) to get an idea of how to parameterize your templates.
n

narrow-needle-95047

01/03/2024, 11:13 PM
Good morning! @great-sunset-355 thank you for suggestions! My goal is to: • dynamically create stacks and components • keep as less reusable code and settings in services repositories (keep the reusable code and settings separately) Thank you @salmon-account-74572 for the articles on templates, this is very close to what I need! Let me experiment with this.
s

salmon-account-74572

01/03/2024, 11:14 PM
@narrow-needle-95047 If you have additional questions about templates, feel free to hit me up.