Skip to main content

Host a static website on Amazon S3

A static website hosted on AWS S3

This example lives in the pulumi/examples repository. Check out just this directory to use it:

Get started with this example
git clone --filter=blob:none --sparse https://github.com/pulumi/examples pulumi-examples
git -C pulumi-examples sparse-checkout set aws-go-s3-folder
cd pulumi-examples/aws-go-s3-folder

A static website that uses S3’s website support. For a detailed walkthrough of this example, see the tutorial Static Website on AWS S3.

Prerequisites#

  1. Install Pulumi
  2. Configure AWS credentials
  3. Install Go

Deploying the example#

  1. Create a new stack:

    Terminal window
    pulumi stack init website-testing
  2. Set the AWS region to deploy into:

    Terminal window
    pulumi config set aws:region us-west-2
  3. Install dependencies:

    Terminal window
    go mod download
  4. Deploy the stack:

    Terminal window
    pulumi up
    Performing changes:
    #: Resource Type Name Status Extra Inf
    1: pulumi:pulumi:Stack website-testing + created
    2: aws:s3:Bucket s3-website-bucket + created
    3: aws:s3:BucketPolicy bucketPolicy + created
    4: aws:s3:BucketObject favicon.png + created
    5: aws:s3:BucketObject index.html + created
    info: 5 changes performed:
    + 5 resources created
    Update duration: 8.827698762s
  5. To see the resources that were created, run pulumi stack:

    Terminal window
    pulumi stack
    Current stack is go-website-testing:
    Managed by https://api.pulumi.com
    Owner: swgillespie
    Last updated: 13 minutes ago (2018-06-15 14:19:06.856631155 -0700 PDT)
    Pulumi version: v0.14.0-rc1
    Plugin go [language] version: 0.14.0-rc1
    Plugin aws [resource] version: 0.14.0-rc1
    Current stack resources (5):
    TYPE NAME
    pulumi:pulumi:Stack website-testing
    aws:s3/bucket:Bucket s3-website-bucket
    aws:s3/bucketPolicy:BucketPolicy bucketPolicy
    aws:s3/bucketObject:BucketObject www/index.html
    aws:s3/bucketObject:BucketObject www/favicon.png

Cleaning up#

Once you’re finished experimenting, you can destroy your stack and remove it to avoid incurring any additional cost:

Terminal window
pulumi destroy
pulumi stack rm

Related

The infrastructure as code platform for any cloud.