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:
git clone --filter=blob:none --sparse https://github.com/pulumi/examples pulumi-examplesgit -C pulumi-examples sparse-checkout set aws-fs-s3-foldercd pulumi-examples/aws-fs-s3-folderA static website that uses S3’s website support.
Deploying and running the program#
-
Create a new stack:
Terminal window pulumi stack init dev -
Set the AWS region:
$ pulumi config set aws:region us-west-2 -
Run
pulumi upto preview and deploy changes.Terminal window Previewing update (dev):Type Name Plan+ pulumi:pulumi:Stack aws-cs-s3-folder-dev create+ └─ aws:s3:Bucket my-bucket create+ ├─ aws:s3:BucketObject index.html create+ └─ aws:s3:BucketObject favicon.png createResources:+ 4 to createDo you want to perform this update? yesUpdating (dev):Type Name Status+ pulumi:pulumi:Stack aws-cs-s3-folder-dev created+ └─ aws:s3:Bucket my-bucket created+ ├─ aws:s3:BucketObject index.html created+ └─ aws:s3:BucketObject favicon.png createdOutputs:endpoint: "http://my-bucket-1234567.s3-website.us-west-2.amazonaws.com" -
Navigate to the website URL:
Terminal window curl $(pulumi stack output endpoint)<html><head><title>Hello S3</title><meta charset="UTF-8"><link rel="shortcut icon" href="/favicon.png" type="image/png"></head><body><p>Hello, world!</p><p>Made with ❤️ with <a href="https://pulumi.com">Pulumi</a></p></body></html> -
To clean up resources, run
pulumi destroyand answer the confirmation question at the prompt.