|
| 1 | +[](https://app.pulumi.com/new) |
| 2 | + |
| 3 | +# Static Website Hosted on AWS S3 |
| 4 | + |
| 5 | +A static website that uses [S3's website support](https://docs.aws.amazon.com/AmazonS3/latest/dev/WebsiteHosting.html). |
| 6 | +For a detailed walkthrough of this example, see the tutorial [Static Website on AWS S3](https://pulumi.io/quickstart/aws-s3-website.html). |
| 7 | + |
| 8 | +## Deploying and running the program |
| 9 | + |
| 10 | +Note: some values in this example will be different from run to run. These values are indicated |
| 11 | +with `***`. |
| 12 | + |
| 13 | +1. Create a new stack: |
| 14 | + |
| 15 | + ```bash |
| 16 | + $ pulumi stack init website-testing |
| 17 | + ``` |
| 18 | + |
| 19 | +1. Set the AWS region: |
| 20 | + |
| 21 | + ``` |
| 22 | + $ pulumi config set aws:region us-west-2 |
| 23 | + ``` |
| 24 | + |
| 25 | +1. Create a Python virtualenv, activate it, and install dependencies: |
| 26 | + |
| 27 | + ``` |
| 28 | + $ virtualenv -p python3 venv |
| 29 | + $ source venv/bin/activate |
| 30 | + $ pip3 install -r requirements.txt |
| 31 | + ``` |
| 32 | + |
| 33 | +1. Run `pulumi up` to preview and deploy changes. After the preview is shown you will be |
| 34 | + prompted if you want to continue or not. |
| 35 | + |
| 36 | + ```bash |
| 37 | + $ pulumi up |
| 38 | + Previewing update (dev): |
| 39 | +
|
| 40 | + Type Name Plan |
| 41 | + + pulumi:pulumi:Stack aws-py-s3-folder-dev create |
| 42 | + + ├─ aws:s3:Bucket s3-website-bucket create |
| 43 | + + ├─ aws:s3:BucketObject index.html create |
| 44 | + + ├─ aws:s3:BucketObject python.png create |
| 45 | + + ├─ aws:s3:BucketObject favicon.png create |
| 46 | + + └─ aws:s3:BucketPolicy bucket-policy create |
| 47 | + |
| 48 | + Resources: |
| 49 | + + 6 to create |
| 50 | +
|
| 51 | + Do you want to perform this update? |
| 52 | + > yes |
| 53 | + no |
| 54 | + details |
| 55 | + ``` |
| 56 | + |
| 57 | +1. To see the resources that were created, run `pulumi stack output`: |
| 58 | + |
| 59 | + ```bash |
| 60 | + $ pulumi stack output |
| 61 | + Current stack outputs (2): |
| 62 | + OUTPUT VALUE |
| 63 | + bucket_name s3-website-bucket-*** |
| 64 | + website_url ***.s3-website-us-west-2.amazonaws.com |
| 65 | + ``` |
| 66 | + |
| 67 | +1. To see that the S3 objects exist, you can either use the AWS Console or the AWS CLI: |
| 68 | + |
| 69 | + ```bash |
| 70 | + $ aws s3 ls $(pulumi stack output bucket_name) |
| 71 | + 2018-04-17 15:40:47 13731 favicon.png |
| 72 | + 2018-04-17 15:40:48 249 index.html |
| 73 | + ``` |
| 74 | + |
| 75 | +1. Open the site URL in a browser to see both the rendered HTML, the favicon, and Python splash image: |
| 76 | + |
| 77 | + ```bash |
| 78 | + $ pulumi stack output website_url |
| 79 | + ***.s3-website-us-west-2.amazonaws.com |
| 80 | + ``` |
| 81 | + |
| 82 | +1. To clean up resources, run `pulumi destroy` and answer the confirmation question at the prompt. |
0 commit comments