![back arrow icon](https://cdn.prod.website-files.com/626810605ff95a8e4fb471fa/653238e268af70aaae08aac7_size%3Ds%2C%20direction%3Dleft.png)
Streamlining deployments with Pulumi
For years now at Panenco we’ve been implementing Infrastructure as Code (IaC) workflows when building cloud applications. Starting with simple YAML configurations within our CI tools, we quickly matured to using Terraform and Pulumi with great success in terms of deployment speed and reliability.. This blog highlights the reasons why and how we approached it.
Why IaC?
The concept of Infrastructure as Code (IaC) involves defining your entire cloud infrastructure through code, minimising the need for manual interventions during application deployment. Here are some of the key advantages:
- Facilitates application deployment to other environments or organisations without the need to manually repeat the same actions.
- It is code, and thus described as part of the code repository, making it easy to review and verify changes.
- Increased deployment velocity, by leveraging infrastructure state to identify the least amount of resources needed to be deployed.
If you want to know more we wrote a blog specifically about IaC and Terraform as well.
Why Pulumi?
Terraform is by far the most popular IaC tool on the market. We also used it for a great while and were happy with all the advantages it brought compared to our YAML workflows. We were able to work in a declarative way, keep track of state when deploying and reduce most of the manual actions from our deployment procedure.
However, a limitation that we kept stumbling upon when using Terraform was using HCL, its proprietary programming language which has quite a learning curve thus making it difficult for new developers to work with.
As such, we started looking for alternatives in which we were able to write our IaC code in the same language as the repository we were working in while maintaining the flexibility and vastness of the components available to Terraform.
We came across Pulumi, as it was gaining a lot of popularity, and immediately fell in love with it.
Pulumi allows us to write the code in a number of familiar languages that we regularly use, like Typescript, Python and .NET. It also includes support for all the resources that we need from known cloud providers, including GCP, AWS and Azure.
Furthermore, Pulumi also has great documentation, including an AI assistant to help with specific tasks based on GPT technology. In terms of pricing, Pulumi is completely free in the way we are using it as we are storing our deployment state in the Cloud provider where the application is deployed. We were used to this way of working in Terraform so we were glad to apply it here as well.
![](https://cdn.prod.website-files.com/627a7356ad04a22fd1133827/6694f2529f7d1761b834af61_AD_4nXfm775o1TGdifUk-F2P3ETYTD2ZXMAj1TFbbZAEB_OBxseHeZ-dTCbHQ1IaWciN5IlmBSoSbJnOzYWesbH5rplu8ZwPMzRjVkHrF9br1nrcX3En8D1DXcS7Z7OnpxpV_oSIVcvcEMRaz8HepJ70rOBEhApU.png)
![](https://cdn.prod.website-files.com/627a7356ad04a22fd1133827/6694f25206f861444dcdd64e_AD_4nXdTBHahFukxxKsl7HGfva5wfuCCAGwRvDrtSJMitxidgVCSCynw_QoojRtUkXRkErwrMY_UV7ECmix0mgsgvPj3wLELRPRmjLPBf24ibJdmCbJ9UsRnPDKsNHjDtWnTkvaCnXZjPNRB36VYMRJyRO8E9iLL.png)
Approach
This section highlights the key choices we made when implementing our infrastructure code using Pulumi and Typescript.
Code structure
A very simple application would just have a single index.ts file in which every part of the application is declared, but this quickly becomes very messy. Instead, we went for a component based approach. We still have some index files which import the components in the correct order but it doesn’t have any other logic defined.
![](https://cdn.prod.website-files.com/627a7356ad04a22fd1133827/6694f2522570dceb09dcf0f3_AD_4nXezO74XXXEVop1LiOSpehLVG6WTFkHZt43MT5Sa7GrmPmmMBy9JCGEjJax8D_5S9InhuJAsPZ-xnb2JRQrEGlBc2NQEzYdOKBmkxxriAubAPntSRpeZMkd1KdVRKL8T7yYrZd4yQpA41TzWYdx-T2wASNE.png)
![](https://cdn.prod.website-files.com/627a7356ad04a22fd1133827/6694f253dbc652a8254a5f17_AD_4nXc7lIVaROLZ2zgfgmPfWnlXZ0pgLd7vf-F6zI0DHksBPID39s-qgK1WKy0WritWMet6PutK0drg0gZBQn3v3JHItIxGEYQvkgmWEOcRbsZw0R-aYOcxAcL25j3F4ZiMH0OWSbOC03h7_zqNVZgDHZ_Dp3Z0.png)
Then in every component file we can easily separate the code needed for that part of the application. We can also easily import components in others to create dependencies.
![](https://cdn.prod.website-files.com/627a7356ad04a22fd1133827/6694f253b5c04d98f7eec39c_AD_4nXclghwHsDuLGFQXxzzgwVEc83KpFystxAk0NFD73vob9slH2wdnasNGyEwCtTNxuYu4dpzBa_m8wgqNak1cQpgMACSFv9eRYPjUFueJloBYKtP39lClVbVbJ0p0FJbVKNWVcjerZDCcJi4ahODos1Hs6FpW.png)
![](https://cdn.prod.website-files.com/627a7356ad04a22fd1133827/6694f252c4426ea34c94972e_AD_4nXd1ZVVUCxyOE_wJ-tu7Fn_XiERuzKTO_24R_Osy_jIWABEPbIIT7imNNgRFsK1Dc_74kRHgJjGnVlhKVtnirmBu8QsO66vnWrT1xLoq40TOTb2pny8wdse03GJDynBey6QZIZOWi4IS3usx5GFLwl248krZ.png)
Secrets
Pulumi has a way to define secrets in configuration files and password encrypt them. However, we were already using our secret managers from our Cloud providers so we simply chose to keep them stored there. Below is an example for Google cloud (GCP).
![](https://cdn.prod.website-files.com/627a7356ad04a22fd1133827/6694f253d857ec504a8633dc_AD_4nXfFyiuO9PnaKU_bIC7ondJUzu13hqBKKHjlcNRk1ibmcB2y0zDeR25rRYA75msddfVwoTRLmJItA6vLLZu6IjMp-7s-nf5NBWASAzWLJNoyCnh9ZspTazUTTu6Rx26HlHjHc6HJvd_M1Ey9_HVHBvoT859Z.png)
Imperative actions
By default, Pulumi is a declarative programming language. A component is declared and is taken into account when deploying the infrastructure. Sometimes, you need to perform actions such as executing a command or running a job to continue the deployment process.
For handling these imperative tasks, Pulumi created the Command component in which you can freely run custom scripts but still define dependencies and triggers to have full flexibility.
![](https://cdn.prod.website-files.com/627a7356ad04a22fd1133827/6694f2522570dceb09dcf122_AD_4nXc0iJzQb95e9KkpNF9_ied0FUt7eZHP-H1PamIVZRaHfdt4KLnbsRYjsmbMR4hTthVCx59mxZrqsiJzpmHK1yASgy9rLrW8dzIG11sLHdoXyAeM2zcmtsRn5EM7k75fsNjW82pzluDQBmxS645dD4QDsP-t.png)
Closing statement
We really enjoyed using Pulumi for our deployments. It enables us to create structured and efficient deployment pipelines while leveraging the latest technologies and our preferred programming languages. Pulumi's flexibility and ease of integration make it an excellent choice for our ongoing and future projects, ensuring a streamlined and modern approach to managing our infrastructure.
See also
Let's build!
Are you looking for an entrepreneurial digital partner?
Reach out to hello@panenco.com or schedule a call
![](https://cdn.prod.website-files.com/626810605ff95a8e4fb471fa/64e5eb179bc189979c75438e_contact-person-avatar-1.png)
![](https://cdn.prod.website-files.com/626810605ff95a8e4fb471fa/64f98579fc0ed35759d24732_Koen%20Verschooten.webp)