1. Docs
  2. Pulumi IaC
  3. Get started
  4. AWS
  5. AWS
  6. Create project

Get started with Pulumi and AWS

    Create a new project

    A project is a program in your chosen language that defines a collection of related cloud resources. In this step, you will create a new project.

    Initializing your project

    Each project lives in its own directory. Create a new one:

    $ mkdir pulumi-start-aws
    
    > mkdir pulumi-start-aws
    

    Change into the new directory:

    $ cd pulumi-start-aws
    
    > cd pulumi-start-aws
    

    Now initialize a new Pulumi project for AWS using the pulumi new command:

    $ pulumi new aws-javascript
    
    > pulumi new aws-javascript
    
    $ pulumi new aws-typescript
    
    > pulumi new aws-typescript
    
    $ pulumi new aws-python
    
    > pulumi new aws-python
    
    $ pulumi new aws-go
    
    > pulumi new aws-go
    
    $ pulumi new aws-csharp
    
    > pulumi new aws-csharp
    
    $ pulumi new aws-java
    
    > pulumi new aws-java
    
    $ pulumi new aws-yaml
    
    > pulumi new aws-yaml
    

    The pulumi new command interactively walks through initializing a new project, as well as creating a stack and configuring it. A stack is an instance of your project and you may have many of them – like dev, staging, and prod – each with different configuration settings.

    You will be prompted for configuration values such as an AWS region. You can hit ENTER to accept the default of us-east-1, or can type in another value such as us-west-2:

    The AWS region to deploy into (aws:region) (us-east-1): us-west-2
    
    If this is your first time running Pulumi, you will be prompted to log into Pulumi Cloud. This is a free but optional service that makes IaC easy by safely and securely managing state for you. This guide explains what Pulumi Cloud is and this topic describes alternative Pulumi backend options.

    After some dependency installations from npm, the project and stack will be ready.

    After the command completes, the project and stack will be ready.

    After the command completes, the project and stack will be ready.

    After the command completes, the project and stack will be ready.

    Review your new project’s contents

    If you list the contents of your directory, you’ll see some key files:

    • src/main/java/myproject is the project’s Java package root
    • index.js index.ts main.py main.go Program.cs Program.fs Program.vb App.java Pulumi.yaml contains your project’s main code that declares a new S3 bucket
    • Pulumi.yaml is a project file containing metadata about your project like its name
    • Pulumi.yaml is a project file containing metadata about your project, like its name, as well as declaring your project’s resources
    • Pulumi.dev.yaml contains configuration values for the stack you just initialized

    Now examine the code in index.js index.ts __main__.py main.go Program.cs Program.fs Program.vb App.java Pulumi.yaml :

    "use strict";
    const pulumi = require("@pulumi/pulumi");
    const aws = require("@pulumi/aws");
    const awsx = require("@pulumi/awsx");
    
    // Create an AWS resource (S3 Bucket)
    const bucket = new aws.s3.BucketV2("my-bucket");
    
    // Export the name of the bucket
    exports.bucketName = bucket.id;
    
    import * as pulumi from "@pulumi/pulumi";
    import * as aws from "@pulumi/aws";
    import * as awsx from "@pulumi/awsx";
    
    // Create an AWS resource (S3 Bucket)
    const bucket = new aws.s3.BucketV2("my-bucket");
    
    // Export the name of the bucket
    export const bucketName = bucket.id;
    
    import pulumi
    from pulumi_aws import s3
    
    # Create an AWS resource (S3 Bucket)
    bucket = s3.BucketV2('my-bucket')
    
    # Export the name of the bucket
    pulumi.export('bucket_name', bucket.id)
    
    package main
    
    import (
    	"github.com/pulumi/pulumi-aws/sdk/v6/go/aws/s3"
    	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    )
    
    func main() {
        pulumi.Run(func(ctx *pulumi.Context) error {
            // Create an AWS resource (S3 Bucket)
            bucket, err := s3.NewBucketV2(ctx, "my-bucket", nil)
            if err != nil {
                return err
            }
    
            // Export the name of the bucket
            ctx.Export("bucketName", bucket.ID())
            return nil
    	  })
    }
    
    using Pulumi;
    using Pulumi.Aws.S3;
    using System.Collections.Generic;
    
    return await Deployment.RunAsync(() =>
    {
       // Create an AWS resource (S3 Bucket)
       var bucket = new BucketV2("my-bucket");
    
       // Export the name of the bucket
       return new Dictionary<string, object?>
       {
          ["bucketName"] = bucket.Id
       };
    });
    
    package myproject;
    
    import com.pulumi.Pulumi;
    import com.pulumi.aws.s3.BucketV2;
    
    public class App {
        public static void main(String[] args) {
            Pulumi.run(ctx -> {
                // Create an AWS resource (S3 Bucket)
                var bucket = new BucketV2("my-bucket");
    
                // Export the name of the bucket
                ctx.export("bucketName", bucket.bucket());
            });
        }
    }
    
    name: quickstart
    runtime: yaml
    description: A minimal AWS Pulumi YAML program
    
    resources:
      # Create an AWS resource (S3 Bucket)
      my-bucket:
        type: aws:s3:BucketV2
    
    outputs:
      # Export the name of the bucket
      bucketName: ${my-bucket.id}
    

    The program declares an AWS S3 BucketV2 resource and exports its ID as a stack output. Resources are just objects in our language of choice with properties capturing their inputs and outputs. Exporting the bucket’s ID makes it convenient to use afterwards.

    Now you’re ready for your first deployment!

      PulumiUP May 6, 2025. Register Now.