Skip to content

Commit

Permalink
clean up of python examples, update vitrtual environment instructions
Browse files Browse the repository at this point in the history
  • Loading branch information
spara committed Feb 29, 2020
1 parent 81f9ff0 commit 8113590
Show file tree
Hide file tree
Showing 24 changed files with 277 additions and 248 deletions.
25 changes: 13 additions & 12 deletions aws-py-appsync/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,31 +6,32 @@ This example shows how to setup a basic GraphQL endpoint in AWS AppSync. The end

## Deploying and running the Pulumi App

1. Create a new stack:
1. Create a new stack:

```bash
$ pulumi stack init dev
```

1. Set the AWS region:
1. Set the AWS region:

```
```bash
$ pulumi config set aws:region us-east-2
```

1. Create a Python virtualenv, activate it, and install dependencies:
1. Create a Python virtualenv, activate it, and install dependencies:

This installs the dependent packages [needed](https://www.pulumi.com/docs/intro/concepts/how-pulumi-works/) for our Pulumi program.

```
$ virtualenv -p python3 venv

```bash
$ python3 -m venv venv
$ source venv/bin/activate
$ pip3 install -r requirements.txt
```

1. Run `pulumi up` to preview and deploy changes:
1. Run `pulumi up` to preview and deploy changes:

```
```bash
$ pulumi up
Previewing update (dev):
...
Expand All @@ -42,9 +43,9 @@ This example shows how to setup a basic GraphQL endpoint in AWS AppSync. The end
Duration: 20s
```

1. Check the deployed GraphQL endpoint:
1. Check the deployed GraphQL endpoint:

```
```bash
$ pulumi stack output endpoint
https://***.appsync-api.us-east-2.amazonaws.com/graphql
$ pulumi stack output key
Expand All @@ -62,6 +63,6 @@ This example shows how to setup a basic GraphQL endpoint in AWS AppSync. The end

## Clean up

1. Run `pulumi destroy` to tear down all resources.
1. Run `pulumi destroy` to tear down all resources.

1. To delete the stack itself, run `pulumi stack rm`. Note that this command deletes all deployment history from the Pulumi Console.
1. To delete the stack itself, run `pulumi stack rm`. Note that this command deletes all deployment history from the Pulumi Console.
30 changes: 15 additions & 15 deletions aws-py-fargate/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,12 @@ Next, to deploy the application and its infrastructure, follow these steps:
$ pulumi config set aws:region us-east-1 # any valid AWS region will work
```

3. Create a Python virtualenv, activate it, and install dependencies:
3. Create a Python virtualenv, activate it, and install dependencies:

This installs the dependent packages [needed](https://www.pulumi.com/docs/intro/concepts/how-pulumi-works/) for our Pulumi program.

```
$ virtualenv -p python3 venv
```bash
$ python3 -m venv venv
$ source venv/bin/activate
$ pip3 install -r requirements.txt
```
Expand All @@ -51,7 +51,7 @@ Next, to deploy the application and its infrastructure, follow these steps:

After being prompted and selecting "yes", your deployment will begin. It'll complete in a few minutes:

```
```bash
Updating (dev):
Type Name Status
+ pulumi:pulumi:Stack aws-py-fargate-dev created
Expand All @@ -64,21 +64,21 @@ Next, to deploy the application and its infrastructure, follow these steps:
+ ├─ aws:lb:LoadBalancer app-lb created
+ ├─ aws:lb:Listener web created
+ └─ aws:ecs:Service app-svc created

Outputs:
url: "app-lb-ad43707-1433933240.us-west-2.elb.amazonaws.com"

Resources:
+ 10 created

Duration: 2m56s

Permalink: https://app.pulumi.com/acmecorp/aws-python-fargate/dev/updates/1
```

Notice that the automatically assigned load-balancer URL is printed as a stack output.

6. At this point, your app is running -- let's curl it. The CLI makes it easy to grab the URL:
5. At this point, your app is running -- let's curl it. The CLI makes it easy to grab the URL:

```bash
$ curl http:https://$(pulumi stack output url)
Expand Down Expand Up @@ -111,7 +111,7 @@ Next, to deploy the application and its infrastructure, follow these steps:

**Please Note**: It may take a few minutes for the app to start up. Until that point, you may receive a 503 error response code.

7. Try making some changes, and rerunning `pulumi up`. For example, let's scale up to 3 instances:
6. Try making some changes, and rerunning `pulumi up`. For example, let's scale up to 3 instances:

Running `pulumi up` will show you the delta and then, after confirming, will deploy just those changes:

Expand All @@ -121,26 +121,26 @@ Next, to deploy the application and its infrastructure, follow these steps:

Notice that `pulumi up` redeploys just the parts of the application/infrastructure that you've edited.

```
```bash
Updating (dev):

Type Name Status Info
pulumi:pulumi:Stack aws-py-fargate-dev
~ └─ aws:ecs:Service app-svc updated [diff: ~desiredCount]

Outputs:
url: "app-lb-ad43707-1433933240.us-west-2.elb.amazonaws.com"

Resources:
~ 1 updated
9 unchanged

Duration: 14s

Permalink: https://app.pulumi.com/acmecorp/aws-python-fargate/dev/updates/2
```

8. Once you are done, you can destroy all of the resources, and the stack:
7. Once you are done, you can destroy all of the resources, and the stack:

```bash
$ pulumi destroy
Expand Down
2 changes: 1 addition & 1 deletion aws-py-resources/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ $ pulumi stack init dev
$ pulumi config set aws:region us-east-2

# Install dependencies
$ virtualenv -p python3 venv
$ python3 -m venv venv
$ source venv/bin/activate
$ pip3 install -r requirements.txt

Expand Down
26 changes: 14 additions & 12 deletions aws-py-s3-folder/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,27 +10,29 @@ For a detailed walkthrough of this example, see the tutorial [Static Website on
Note: some values in this example will be different from run to run. These values are indicated
with `***`.

1. Create a new stack:
1. Create a new stack:

```bash
$ pulumi stack init website-testing
```

1. Set the AWS region:
1. Set the AWS region:

```
```bash
$ pulumi config set aws:region us-west-2
```

1. Create a Python virtualenv, activate it, and install dependencies:
1. Create a Python virtualenv, activate it, and install dependencies:

```
$ virtualenv -p python3 venv
This installs the dependent packages [needed](https://www.pulumi.com/docs/intro/concepts/how-pulumi-works/) for our Pulumi program.

```bash
$ python3 -m venv venv
$ source venv/bin/activate
$ pip3 install -r requirements.txt
```

1. Run `pulumi up` to preview and deploy changes. After the preview is shown you will be
1. Run `pulumi up` to preview and deploy changes. After the preview is shown you will be
prompted if you want to continue or not.

```bash
Expand All @@ -44,7 +46,7 @@ with `***`.
+ ├─ aws:s3:BucketObject python.png create
+ ├─ aws:s3:BucketObject favicon.png create
+ └─ aws:s3:BucketPolicy bucket-policy create

Resources:
+ 6 to create

Expand All @@ -54,7 +56,7 @@ with `***`.
details
```

1. To see the resources that were created, run `pulumi stack output`:
1. To see the resources that were created, run `pulumi stack output`:

```bash
$ pulumi stack output
Expand All @@ -64,19 +66,19 @@ with `***`.
website_url ***.s3-website-us-west-2.amazonaws.com
```

1. To see that the S3 objects exist, you can either use the AWS Console or the AWS CLI:
1. To see that the S3 objects exist, you can either use the AWS Console or the AWS CLI:

```bash
$ aws s3 ls $(pulumi stack output bucket_name)
2018-04-17 15:40:47 13731 favicon.png
2018-04-17 15:40:48 249 index.html
```

1. Open the site URL in a browser to see both the rendered HTML, the favicon, and Python splash image:
1. Open the site URL in a browser to see both the rendered HTML, the favicon, and Python splash image:

```bash
$ pulumi stack output website_url
***.s3-website-us-west-2.amazonaws.com
```

1. To clean up resources, run `pulumi destroy` and answer the confirmation question at the prompt.
1. To clean up resources, run `pulumi destroy` and answer the confirmation question at the prompt.
18 changes: 10 additions & 8 deletions aws-py-stackreference/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
This example creates a "team" EC2 Instance with tags set from _upstream_ "company" and "department"
stacks via [StackReference](https://www.pulumi.com/docs/intro/concepts/organizing-stacks-projects/#inter-stack-dependencies).

```
```sh
/**
* company
* └─ department
Expand All @@ -18,14 +18,16 @@ stacks via [StackReference](https://www.pulumi.com/docs/intro/concepts/organizin
```bash
$ cd company
````

1. Create a Python virtualenv, activate it, and install dependencies:

```
$ virtualenv -p python3 venv
$ source venv/bin/activate
$ pip3 install -r requirements.txt
```
This installs the dependent packages [needed](https://www.pulumi.com/docs/intro/concepts/how-pulumi-works/) for our Pulumi program.

```bash
$ python3 -m venv venv
$ source venv/bin/activate
$ pip3 install -r requirements.txt
```

1. Create a new stack:

Expand Down Expand Up @@ -76,7 +78,7 @@ stacks via [StackReference](https://www.pulumi.com/docs/intro/concepts/organizin

1. Create a Python virtualenv, activate it, and install dependencies:

```
```bash
$ virtualenv -p python3 venv
$ source venv/bin/activate
$ pip3 install -r requirements.txt
Expand Down
26 changes: 14 additions & 12 deletions aws-py-static-website/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,27 +26,29 @@ set:
Note: some values in this example will be different from run to run. These values are indicated
with `***`.

1. Create a new stack:
1. Create a new stack:

```bash
$ pulumi stack init website-testing
```

1. Set the AWS region:
1. Set the AWS region:

```bash
$ pulumi config set aws:region us-west-2
```

1. Create a Python virtualenv, activate it, and install dependencies:
1. Create a Python virtualenv, activate it, and install dependencies:

This installs the dependent packages [needed](https://www.pulumi.com/docs/intro/concepts/how-pulumi-works/) for our Pulumi program.

```bash
$ virtualenv -p python3 venv
$ python3 -m venv venv
$ source venv/bin/activate
$ pip3 install -r requirements.txt
```

1. Run `pulumi up` to preview and deploy changes. After the preview is shown you will be
1. Run `pulumi up` to preview and deploy changes. After the preview is shown you will be
prompted if you want to continue or not.

```bash
Expand All @@ -66,7 +68,7 @@ with `***`.
+ └─ aws:route53:Record *** create
```

1. To see the resources that were created, run `pulumi stack output`:
1. To see the resources that were created, run `pulumi stack output`:

```bash
$ pulumi stack output
Expand All @@ -78,17 +80,17 @@ with `***`.
target_domain_endpoint https://***/
```

1. To see that the S3 objects exist, you can either use the AWS Console or the AWS CLI:
1. To see that the S3 objects exist, you can either use the AWS Console or the AWS CLI:

```bash
$ aws s3 ls $(pulumi stack output content_bucket_url)
2020-02-21 16:58:48 262 404.html
2020-02-21 16:58:48 394 index.html
```

1. Open a browser to the target domain endpoint from above to see your beautiful static website. (Since we don't wait for the CloudFront distribution to completely sync, you may have to wait a few minutes)
1. Open a browser to the target domain endpoint from above to see your beautiful static website. (Since we don't wait for the CloudFront distribution to completely sync, you may have to wait a few minutes)

1. To clean up resources, run `pulumi destroy` and answer the confirmation question at the prompt.
1. To clean up resources, run `pulumi destroy` and answer the confirmation question at the prompt.

## Troubleshooting

Expand All @@ -114,18 +116,18 @@ This is caused by CloudFront confirming the ETag of the resource before applying
ETag is essentially a "version", and AWS is rejecting any requests that are trying to update
any version but the "latest".

This error will occurr when the state of the ETag get out of sync between the Pulumi Service
This error will occur when the state of the ETag gets out of sync between the Pulumi Service
and AWS. (Which can happen when inspecting the CloudFront distribution in the AWS console.)

You can fix this by running `pulumi refresh` to pickup the newer ETag values.

## Deployment Speed

This example creates a `aws.S3.BucketObject` for every file served from the website. When deploying
This example creates an `aws.S3.BucketObject` for every file served from the website. When deploying
large websites, that can lead to very long updates as every individual file is checked for any
changes.

It may be more efficient to not manage individual files using Pulumi and and instead just use the
It may be more efficient to not manage individual files using Pulumi and instead just use the
AWS CLI to sync local files with the S3 bucket directly.

Remove the call to `crawlDirectory` and run `pulumi up`. Pulumi will then delete the contents
Expand Down
Loading

0 comments on commit 8113590

Please sign in to comment.