Skip to content

Pulumi & YAML ​

Pulumi supports writing your infrastructure as code using Pulumi YAML. Pulumi YAML is a configuration language designed to make describing infrastructure as simple as possible. It supports managing infrastructure on any cloud, including Azure, AWS, and Google Cloud.

Prerequisites ​

All you need to use Pulumi YAML is the Pulumi CLI.

Example ​

yaml
name: simple-yaml
runtime: yaml
config:
  message:
    default: Hello, world!
    type: string
resources:
  my-bucket:
    type: aws:s3:Bucket
  my-bucket-website:
    type: aws:s3:BucketWebsiteConfigurationV2
    properties:
      bucket: ${my-bucket.bucket}
      indexDocument:
        suffix: index.html
  ownership-controls:
    type: aws:s3:BucketOwnershipControls
    properties:
      bucket: ${my-bucket.id}
      rule:
        objectOwnership: ObjectWriter
  public-access-block:
    type: aws:s3:BucketPublicAccessBlock
    properties:
      bucket: ${my-bucket.id}
      blockPublicAcls: false
  index.html:
    type: aws:s3:BucketObject
    properties:
      bucket: ${my-bucket}
      source:
        fn::stringAsset: <h1>${message}</h1>
      acl: public-read
      contentType: text/html
    options:
      dependsOn:
        - ${ownership-controls}
        - ${public-access-block}
outputs:
  bucketEndpoint: http://${my-bucket.websiteEndpoint}

INFO

The example is a fully valid and self-contained Pulumi project. You only need one file to create resources in Pulumi YAML.

Further examples are given in the Pulumi YAML GitHub repository. The specification for Pulumi YAML documents is in the Pulumi YAML reference.

Templates ​

The fastest way to start a new project is to use a template. The template will initialize a Pulumi project and set up starter resources for the chosen cloud. The yaml template is cloud agnostic.

  • pulumi new yaml: creates a minimal, cloud-agnostic Pulumi YAML project
  • pulumi new aws-yaml: creates a starter AWS Pulumi YAML project
  • pulumi new azure-yaml: creates a starter Azure Pulumi YAML project
  • pulumi new gcp-yaml: creates a starter Google Cloud Pulumi YAML project
  • pulumi new kubernetes-yaml: creates a starter Kubernetes Pulumi YAML project

By default, pulumi new provides a number of templates provided by Pulumi, but it can also use your own custom templates.

To learn more about building and working with custom templates, see Custom Templates and the pulumi new docs.

Pulumi Programming Model ​

The Pulumi programming model defines the core concepts you will use when creating infrastructure as code programs using Pulumi. Concepts describes these concepts with examples available in all supported languages, including Pulumi YAML.

To learn how the Pulumi Programming Model is implemented for Pulumi YAML, refer to the Pulumi YAML Reference Guide.

Limitations compared with other languages ​

Pulumi YAML is a declarative language, so it does not offer everything the general-purpose languages (TypeScript, Python, Go, C#, and Java) do. Consider the following before you choose it for a project.

AreaPulumi YAMLWhat to do instead
Loops, conditionals, arithmetic, and comparisonsNot supported.Generate the program with a compiler, or use a general-purpose language.
User-defined functionsNot supported. Only the built-in fn:: functions are available.Write the logic in a component in another language and use it from YAML.
Calling methods on componentsNot supported.Use a component's inputs and outputs.
A program split across filesNot supported. A program is a single Pulumi.yaml (or Main.yaml) file.Move reusable parts into components.
Resource hooks and transformsNot supported.Use a general-purpose language.
Authoring policy packsNot supported. Policy packs written in other languages still apply to YAML programs.Write the policy pack in TypeScript or Python.
Mocked unit tests, dynamic providers, and the Automation APINot available. These are features of the language SDKs.Use a general-purpose language.

Pulumi YAML can author components, which other Pulumi languages can consume. See the component reference.

If a YAML project outgrows these limits, pulumi convert translates it to another language.

Compiler support ​

Pulumi YAML includes native support for languages that compile to YAML/JSON via the compiler runtime option.

yaml
name: generated-from-cue
runtime:
  name: yaml
  options:
    compiler: cue export

Pulumi will run whatever program and arguments are specified in compiler and interpret the output as a Pulumi YAML program.

YAML Packages ​

The Pulumi Registry houses hundreds of YAML packages.

Content from the official Pulumi documentation (github.com/pulumi/docs).