Organizing Pulumi project

Within your Pulumi project, there are good practices to consider to help keep your code organized, maintainable, and understandable.

Organize your code in a way that makes it easy to understand and maintain. One way to do this in Typescript is to break out your code into separate files, and then import them into your main file.

This project looks a bit like this:

β”œβ”€ pulumi-ask-workshop
  β”œβ”€β”€ resources
    β”œβ”€β”€ akscluster.ts
    β”œβ”€β”€ certmanager.ts
    β”œβ”€β”€ containerregistry.ts
    β”œβ”€β”€ namespaces.ts
    β”œβ”€β”€ nginxingresscontroller.ts
    β”œβ”€β”€ virtualnetwork.ts
  β”œβ”€β”€ config.ts
  β”œβ”€β”€ index.ts
  β”œβ”€β”€ package-lock.json
  β”œβ”€β”€ package.json
  β”œβ”€β”€ Pulumi.yaml
  β”œβ”€β”€ Pulumi.dev.yaml
  β”œβ”€β”€ tsconfig.json

Let’s discuss them briefly:

  • resources β€” all the azure resources for provisioning your system on azure

  • config.ts β€” get all configurations from Pulumi

  • index.tsβ€” is the Pulumi program that defines your stack resources.

  • package.json and package-lock.jsonβ€”definitions of required npm dependencies

  • Pulumi.yaml and Pulumi.dev.yamlβ€”contains configurationarrow-up-right values for the stackarrow-up-right you initialized.

  • tsconfig.jsonβ€”settings for the TypeScript compiler

  • .gitignoreβ€”Git exclusion list, is not important for us

  • node_modulesβ€”installed npm packages

Now that we have our folder structure, we can create all the resources that the service needs.

Last updated