DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Please enter at least three characters to search
Refcards Trend Reports
Events Video Library
Refcards
Trend Reports

Events

View Events Video Library

Zones

Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks

Modernize your data layer. Learn how to design cloud-native database architectures to meet the evolving demands of AI and GenAI workkloads.

Secure your stack and shape the future! Help dev teams across the globe navigate their software supply chain security challenges.

Releasing software shouldn't be stressful or risky. Learn how to leverage progressive delivery techniques to ensure safer deployments.

Avoid machine learning mistakes and boost model performance! Discover key ML patterns, anti-patterns, data strategies, and more.

Related

  • 5 DevOps Tools To Add to Your Stack in 2022
  • Anticipating Your Business Problem With Infrastructure as Code in DevOps
  • Dynatrace Perform: Day Two
  • Learn What Is No-Code as Software Development Trend: A Complete Guide

Trending

  • A Developer's Guide to Mastering Agentic AI: From Theory to Practice
  • Integrating Security as Code: A Necessity for DevSecOps
  • Unlocking AI Coding Assistants Part 2: Generating Code
  • Issue and Present Verifiable Credentials With Spring Boot and Android
  1. DZone
  2. Software Design and Architecture
  3. Cloud Architecture
  4. IaC Hot Reload With Pulumi Watch

IaC Hot Reload With Pulumi Watch

Hot-reloading your cloud infrastructure.

By 
Alexandre Nedelec user avatar
Alexandre Nedelec
·
Feb. 27, 22 · Tutorial
Likes (3)
Comment
Save
Tweet
Share
12.3K Views

Join the DZone community and get the full member experience.

Join For Free

Do you like using hot reload when developing applications? How about using hot reload when developing the cloud infrastructure of an application? Keep reading because that's what we are going to talk about.

Developing and Deploying Cloud Infrastructure

When doing Infrastructure as Code for a cloud application we usually do the following steps:

  1. we write the code describing the desired state of the infrastructure
  2. we build this infrastructure code and compare the resulting desired state against the current state of the infrastructure
  3. we deploy to the provisioned infrastructure the changes needed to achieve the desired state

When using Pulumi, you can run the pulumi preview command for step 2 and the pulumi up command for step 3.

As its name suggests, the pulumi preview command only "previews" the updates that could be made to the infrastructure but does not apply them. To perform an update of the cloud infrastructure you have to use the `pulumi update` command which also does a preview of the changes, prompts the user to approve the changes to be made, and performs these changes. That is why, to be honest, I don't bother with pulumi preview: most of the time I only use the pulumi up command (which means I do steps 2 and 3 in one row).

In case you wonder, if you already have run pulumi preview before running pulumi up you can skip the preview in the up command by using the --skip-preview option.

Of course, you can use these commands to automate the deployment of your cloud infrastructure using your favorite CI/CD system.

The Need for a Hot Reload-Like Experience When Doing IaC

All this is great but there are times when all you want is to quickly write your infrastructure code and check that you can successfully provision and configure the cloud resources you need. This can happen when you want to prototype something, test a new cloud resource, or simply when you are developing your infrastructure and want to verify your infrastructure code works. Usually, you are using a "sandbox" cloud environment for this, the same way you would use your local environment for debugging application code. At these moments, you don't care about CI/CD. You care about quickly experimenting with changes to your infrastructure, being productive, making changes in your code, and checking what it does, so you want to be able to quickly iterate to make your code work. Yet, this is not possible if each time you make a change to the code you have to manually run the pulumi up command, and approve the deployment.

You can use the --yes option to automatically approve the changes and directly perform the update when running the pulumi up command.

But guess what? Fast feedback when doing a code change is exactly what you want when developing an application. Indeed whether you are building an application or building infrastructure you are doing software development so you have the same needs and practices. And what do application developers have in their toolbox to be more productive when developing? They have "hot reload": while debugging locally an application, they can modify the source code, and changes made will be almost instantaneously reflected on the application. Wouldn't it be great if similarly you could make a change in your infrastructure code and have the provisioned infrastructure automatically updated? That is what the pulumi watch command is here for. 

Using Pulumi Watch

pulumi watch is a command currently in preview that watches for changes in the infrastructure code directory and continuously updates the cloud resources. 

But the best is to see by yourself. In the following example, you can see on the left of the screen a terminal opened with the pulumi watch command running, and on the right of the screen vscode opened with the code describing the currently provisioned Azure infrastructure for my project. Some lines to create a "Tweets" table in the storage account are commented. When I uncomment them and save the code file, you can see that pulumi detects it, builds the code, and deploys the changes so creates the table in that case.

I don't know what you think but I find this pretty cool: it's like hot reload for your infrastructure as code. Of course, you will probably not use pulumi watch all the time, but to quickly write and test your infrastructure code, it can be very helpful.

As far as I know (don't hesitate to correct me in the comments if I am wrong), there is no such feature in Terraform and it's too bad because when you start using the watch command you don't want to do without it.

Infrastructure code style application Command (computing) Software development Cloud

Published at DZone with permission of Alexandre Nedelec. See the original article here.

Opinions expressed by DZone contributors are their own.

Related

  • 5 DevOps Tools To Add to Your Stack in 2022
  • Anticipating Your Business Problem With Infrastructure as Code in DevOps
  • Dynatrace Perform: Day Two
  • Learn What Is No-Code as Software Development Trend: A Complete Guide

Partner Resources

×

Comments
Oops! Something Went Wrong

The likes didn't load as expected. Please refresh the page and try again.

ABOUT US

  • About DZone
  • Support and feedback
  • Community research
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Core Program
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 100
  • Nashville, TN 37211
  • support@dzone.com

Let's be friends:

Likes
There are no likes...yet! 👀
Be the first to like this post!
It looks like you're not logged in.
Sign in to see who liked this post!