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

Pulumi & AWS: Review project

    Let’s review some of the generated project files:

    • Pulumi.yaml defines both the project and the program that manages your stack resources.
    • Program.cs is the Pulumi program that defines your stack resources.
    • src/main/java/myproject defines the project’s Java package root.
    • __main__.py is the Pulumi program that defines your stack resources.
    • index.js index.ts main.py main.go Program.cs Program.fs Program.vb App.java Pulumi.yaml is the Pulumi program that defines your stack resources.

    Let’s examine 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.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)
    
    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.NewBucket(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 Bucket("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.Bucket;
    
    public class App {
        public static void main(String[] args) {
            Pulumi.run(ctx -> {
    
                // Create an AWS resource (S3 Bucket)
                var bucket = new Bucket("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:Bucket
    
    outputs:
      # Export the name of the bucket
      bucketName: ${my-bucket.id}
    

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

    exports.bucketName = bucket.id;
    
    export const bucketName = bucket.id;
    
    pulumi.export('bucket_name', bucket.id)
    
    ctx.Export("bucketName", bucket.ID())
    
    return new Dictionary<string, object?>
    {
       ["bucketName"] = bucket.Id
    };
    
    ctx.export("bucketName", bucket.bucket());
    
    outputs:
      bucketName: ${my-bucket.id}
    

    Next, you’ll deploy your stack, which will provision your S3 bucket.

      PulumiUP 2024. Watch On Demand.