Filters
Zo zoek je
  • Gewone woorden vinden namen, teksten en voorbeelden.
  • "twee woorden" vindt precies die zin.
  • --naam of -x vindt een optie.
  • #woord zoekt alleen in commando's.
  • @grep vindt lessen en labs die grep gebruiken.
  • Filters: cat:network · in:labs · in:notes · level:rhcsa · ch:8 · root:yes. Zet ! voor een woord om het weg te laten. OR tussen woorden betekent één ervan.
  • ↑ ↓ bewegen · Enter openen · Esc sluiten · / zoeken

pulumi

Infrastructure as code in a real programming language (TypeScript, Python, Go, C#) — preview and apply like Terraform.

Niveau
DevOps-tool
Groep
Infrastructuur als code en cloud
Root nodig
Nee
Pakket
pulumi

Dit deel is nog niet vertaald. Je ziet de Engelse tekst.

Wat het doet

pulumi describes cloud resources with normal code: loops, functions, classes and tests. Like Terraform it keeps state, shows a preview of the changes and then applies them (up). A stack is one copy of the project (dev, staging, prod) with its own config and state.

State lives in Pulumi Cloud, or in your own backend (S3, Azure Blob, a local folder). Secrets in the config are encrypted.

Zo schrijf je het

pulumi COMMAND [OPTIONS]

Belangrijkste delen

Commands

new TEMPLATE
Start a project (for example azure-typescript).
preview
Show what would change.
up
Create or change the resources.
destroy
Delete all resources of the stack.
stack init|select|ls|output
Make / choose / list stacks; show outputs.
config set [--secret] KEY VALUE
Set a config value (or an encrypted secret).
refresh
Read the real state from the cloud.
import TYPE NAME ID
Bring an existing resource under Pulumi.
login [URL]
Choose the state backend (file://, s3://, azblob://).
state delete URN
Remove a resource from the state only.
cancel
Stop a running update.

Opties 8

Meest gebruikt

Options

-s, --stack NAME
Use this stack.
-y, --yes
Do not ask (CI).
--diff
Show a detailed diff.
--target URN
Only this resource.
--refresh
Refresh before the update.
--skip-preview
Do not show the preview first.
--non-interactive
No prompts or colours (CI).
--json
JSON output.

Voorbeelden 10

$ als gewone gebruiker# als root (of met sudo)

  1. 1Start a new Azure project in TypeScript

    pulumi new azure-typescript -n shop-infra
  2. 2Keep state in your own storage (no Pulumi Cloud)

    pulumi login azblob://pulumi-state
    pulumi login s3://acme-pulumi-state
  3. 3A small program (TypeScript)

    cat index.ts
    import * as resources from "@pulumi/azure-native/resources";
    import * as storage from "@pulumi/azure-native/storage";
    const rg = new resources.ResourceGroup("rg-shop");
    const sa = new storage.StorageAccount("stshop", {
      resourceGroupName: rg.name, kind: "StorageV2", sku: { name: "Standard_LRS" },
      minimumTlsVersion: "TLS1_2", allowBlobPublicAccess: false,
    });
    export const account = sa.name;
  4. 4Preview, then apply

    pulumi preview --diff
    pulumi up
  5. 5Stacks per environment

    pulumi stack init prod
    pulumi config set azure-native:location westeurope
    pulumi config set --secret dbPassword 'S3cr3t!'
  6. 6Read an output

    pulumi stack output account
  7. 7In CI without prompts

    pulumi up --stack prod --yes --non-interactive
  8. 8Find drift (changes made by hand)

    pulumi refresh --stack prod --yes
  9. 9Bring an existing resource in

    pulumi import azure-native:resources:ResourceGroup rg-old /subscriptions/SUB/resourceGroups/rg-old
  10. 10Delete a test stack completely

    pulumi destroy --stack dev --yes
    pulumi stack rm dev

Let op

  • destroy deletes real resources. Protect important ones with protect: true.
  • Code can do anything — keep the program simple and reviewed like app code.
  • Back up the state backend; lost state means Pulumi forgets what it made.

Bestanden

Pulumi.yaml
Project name and runtime.
Pulumi.STACK.yaml
Config of one stack (secrets encrypted).

Tips om te onthouden

  • Terraform and OpenTofu have more jobs and examples; Pulumi is popular in teams of developers.

Exitcodes

0OK.
255Error.

Volledige handleiding

Deze pagina legt het commando uit in eenvoudige woorden. De originele handleiding heeft elk detail.

In je terminal: man pulumi