<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>2. Pulumi Basics :: Cloud Native Engineering</title><link>https://cloud-native.labs.netrics.dev/2-pulumi-basics/index.html</link><description>Pulumi is an open-source Infrastructure as Code platform that lets you define, deploy, and manage cloud resources using general-purpose programming languages instead of proprietary configuration formats.
Language Support Pulumi supports a wide range of languages out of the box:
Language Runtime Python 3.8+ TypeScript / JavaScript Node.js Go 1.21+ C# / F# / VB .NET 6+ Java JDK 11+ YAML (declarative, no runtime required) In this workshop we use Python — it is widely known, has excellent Pulumi SDK coverage, and pairs naturally with the Azure Native provider.</description><generator>Hugo</generator><language>en-us</language><atom:link href="https://cloud-native.labs.netrics.dev/2-pulumi-basics/index.xml" rel="self" type="application/rss+xml"/><item><title>2.1. Project Structure</title><link>https://cloud-native.labs.netrics.dev/2-pulumi-basics/1-project-structure/index.html</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://cloud-native.labs.netrics.dev/2-pulumi-basics/1-project-structure/index.html</guid><description>In this lab you will initialise a local Pulumi state backend and scaffold a new Python project.
Step 1 — Login with a Local Backend Execute the following command to store your Pulumi state locally:
pulumi login --local Verify the login:
pulumi whoami -v You should see User: &lt;local&gt; and the backend URL pointing to your home directory.</description></item><item><title>2.2. Core Workflow</title><link>https://cloud-native.labs.netrics.dev/2-pulumi-basics/2-core-workflow/index.html</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://cloud-native.labs.netrics.dev/2-pulumi-basics/2-core-workflow/index.html</guid><description>In this lab you will declare your first resource, then drive it through the preview → up → destroy cycle.
Step 1 — Add the pulumi_random provider Open requirements.txt and add the random provider:
pulumi==3.243.0 pulumi_random==4.21.0 Install the updated dependencies:
source venv/bin/activate pip install -r requirements.txt Explanation pulumi_random wraps the Terraform Random provider and gives you resource types like RandomPet, RandomString, and RandomPassword. These are useful for generating stable, reproducible names for cloud resources that must be globally unique.</description></item><item><title>2.3. Resources</title><link>https://cloud-native.labs.netrics.dev/2-pulumi-basics/3-resources/index.html</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://cloud-native.labs.netrics.dev/2-pulumi-basics/3-resources/index.html</guid><description>In this lab you declare your first real-world resources using the Docker provider — a local nginx container with a published port.
Step 1 — Add the Docker provider Open requirements.txt and add pulumi_docker:
pulumi==3.243.0 pulumi_random==4.21.0 pulumi_docker==5.0.0 Install the updated dependencies:
source venv/bin/activate pip install -r requirements.txt Explanation The Docker provider translates Pulumi resource declarations into Docker API calls — it can pull images, create containers, build images, and manage networks and volumes, all as Pulumi-managed resources.</description></item><item><title>2.4. Outputs and References</title><link>https://cloud-native.labs.netrics.dev/2-pulumi-basics/4-outputs-and-references/index.html</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://cloud-native.labs.netrics.dev/2-pulumi-basics/4-outputs-and-references/index.html</guid><description>This lab covers pulumi.Output — how to inspect, transform with apply(), and combine outputs with Output.all().
Step 1 — Inspect stack outputs The container from the previous lab already exports container_name. List all exported values for the current stack:
pulumi stack output Read a single output by name:
pulumi stack output container_name Explanation pulumi.export("key", value) declares a stack output — a named value that is written to state after every successful deploy. Stack outputs are the public interface of a stack:</description></item><item><title>2.5. Config and Secrets</title><link>https://cloud-native.labs.netrics.dev/2-pulumi-basics/5-config-and-secrets/index.html</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://cloud-native.labs.netrics.dev/2-pulumi-basics/5-config-and-secrets/index.html</guid><description>Config and secrets let each stack carry its own values — image versions, ports, credentials — without hardcoding them in __main__.py.
Step 1 — Make the image tag configurable Set a config value for the image tag, then read it in code:
pulumi config set image-tag 0.4-plain-text Update __main__.py to read the value:
import pulumi import pulumi_docker as docker def main(): config = pulumi.Config() image_tag = config.require("image-tag") image = docker.RemoteImage( "nginx-image", name=f"nginxdemos/hello:{image_tag}", keep_locally=True ) container = docker.Container( "nginx-container", image=image.image_id, ports=[docker.ContainerPortArgs(internal=80, external=8080)] ) message = container.name.apply( lambda name: f"Container '{name}' is running — curl http://localhost:8080" ) summary = pulumi.Output.all(container.name, image.name).apply( lambda args: f"[{args[0]}] running image: {args[1]}" ) pulumi.export("container_name", container.name) pulumi.export("message", message) pulumi.export("summary", summary) main() Deploy and inspect where the config value landed:</description></item><item><title>2.6. Stacks</title><link>https://cloud-native.labs.netrics.dev/2-pulumi-basics/6-stacks/index.html</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://cloud-native.labs.netrics.dev/2-pulumi-basics/6-stacks/index.html</guid><description>Stacks are Pulumi’s mechanism for running the same program against isolated environments — dev, staging, and prod each get their own state, their own config, and their own deployed resources.
Step 1 — Inspect the current stack Check which stack is currently active and list all stacks in the project:
pulumi stack pulumi stack ls Explanation Every Pulumi operation targets exactly one stack. pulumi stack prints the active stack and its last-known resource count. pulumi stack ls shows all stacks that exist in the current backend for this project.</description></item><item><title>2.7. Component Resources</title><link>https://cloud-native.labs.netrics.dev/2-pulumi-basics/7-component-resources/index.html</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://cloud-native.labs.netrics.dev/2-pulumi-basics/7-component-resources/index.html</guid><description>Component resources let you group related Pulumi resources into a reusable Python class with the same interface as built-in providers.
Step 1 — Clean up previous stacks Destroy any running resources and make sure dev is the active stack:
pulumi stack select dev pulumi destroy If a prod stack still exists, remove it too:
pulumi stack select prod pulumi destroy pulumi stack rm prod pulumi stack select dev Confirm the state is empty:</description></item><item><title>2.8. State Management</title><link>https://cloud-native.labs.netrics.dev/2-pulumi-basics/8-state-management/index.html</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://cloud-native.labs.netrics.dev/2-pulumi-basics/8-state-management/index.html</guid><description>Pulumi’s state file is the source of truth for every deployed resource — its properties, outputs, and dependencies. This lab covers how to inspect it, detect drift, and perform surgical repairs.
Step 1 — Inspect the state file Export the full state and browse it with jq:
pulumi stack export | jq . | less Find all container resources and list their URNs:</description></item></channel></rss>