1. Packages
  2. AWS Classic
  3. How-to Guides
  4. Host a Static Website on Amazon S3

Try AWS Native preview for resources not in the classic version.

AWS Classic v6.31.0 published on Monday, Apr 15, 2024 by Pulumi

Host a Static Website on Amazon S3

aws logo

Try AWS Native preview for resources not in the classic version.

AWS Classic v6.31.0 published on Monday, Apr 15, 2024 by Pulumi

    View Code Deploy

    A static website that uses S3’s website support.

    Deploying and running the program

    1. Create a new stack:

      $ pulumi stack init dev
      
    2. Set the AWS region:

      $ pulumi config set aws:region us-west-2
      
    3. Run pulumi up to preview and deploy changes.

      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           create     
      
      Resources:
          + 4 to create
      
      Do you want to perform this update? yes
      Updating (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           created     
      
      Outputs:
          Endpoint: "http://my-bucket-1234567.s3-website.us-west-2.amazonaws.com"
      
    4. Navigate to the website URL:

      $ 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>
      
    5. To clean up resources, run pulumi destroy and answer the confirmation question at the prompt.

    aws logo

    Try AWS Native preview for resources not in the classic version.

    AWS Classic v6.31.0 published on Monday, Apr 15, 2024 by Pulumi