Review the New Project

Let’s review some of the generated project files:

  • Pulumi.yaml defines the project.
  • Pulumi.dev.yaml contains configuration values for the stack we initialized.
  • index.jsindex.ts__main__.pymain.goProgram.csProgram.fsProgram.vb is the Pulumi program that defines our stack resources. Let’s examine it.
"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.Bucket("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.Bucket("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.Bucket('my-bucket')

# Export the name of the bucket
pulumi.export('bucket_name',  bucket.id)
using System.Collections.Generic;
using System.Threading.Tasks;
using Pulumi;
using Pulumi.Aws.S3;

class Program
{
    static Task Main()
    {
        return Deployment.RunAsync(() => {
            // Create an AWS resource (S3 Bucket)
            var bucket = new Bucket("my-bucket");

            // Export the name of the bucket
            return new Dictionary<string, object> {
                { "bucket_name" , bucket.Id },
            };
        });
    }
}

This Pulumi program creates an S3 bucket and exports the name of the bucket.

For Python, before we deploy the stack, the following commands need to be run to create a virtual environment, activate it, and install dependencies:

$ virtualenv -p python3 venv
$ source venv/bin/activate
$ pip3 install -r requirements.txt

Next, we’ll deploy the stack.