Skip to content

Commit 4343550

Browse files
author
Luke Hoban
authored
Add virtualenv option to Python examples (#885)
Use the automatically managed `virtualenv: venv` support in all Python examples. See https://www.pulumi.com/docs/intro/languages/python/#virtual-environments. Also update the READMEs to no longer mention needing to manually create the virtual environment. The Pulumi CLI, as of v2.15.1, will automatically create & install dependencies in a virtual environment if the `virtualenv` runtime option is set in `Pulumi.yaml` and the configured directory is empty or doesn't exist.
1 parent 327afe3 commit 4343550

File tree

95 files changed

+237
-579
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

95 files changed

+237
-579
lines changed

aws-django-voting-app/Pulumi.yaml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
name: voting-app
2-
runtime: python
2+
runtime:
3+
name: python
4+
options:
5+
virtualenv: venv
36
description: Voting app that uses containers
47
template:
58
config:

aws-django-voting-app/README.md

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -39,16 +39,6 @@ The example shows how easy it is to deploy containers into production and to con
3939
$ pulumi config set django-secret-key <VALUE> --secret
4040
```
4141
42-
1. Create a Python virtualenv, activate it, and install dependencies:
43-
44-
This installs the dependent packages [needed](https://www.pulumi.com/docs/intro/concepts/how-pulumi-works/) for our Pulumi program.
45-
46-
```bash
47-
$ python3 -m venv venv
48-
$ source venv/bin/activate
49-
$ pip3 install -r requirements.txt
50-
```
51-
5242
1. Run `pulumi up -y` to deploy changes:
5343
5444
```bash

aws-py-appsync/Pulumi.yaml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
name: aws-py-appsync
2-
runtime: python
2+
runtime:
3+
name: python
4+
options:
5+
virtualenv: venv
36
description: Basic example of defining an AWS AppSync endpoint from Pulumi in Python
47
template:
58
config:

aws-py-appsync/README.md

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -18,17 +18,6 @@ This example shows how to setup a basic GraphQL endpoint in AWS AppSync. The end
1818
$ pulumi config set aws:region us-east-2
1919
```
2020

21-
1. Create a Python virtualenv, activate it, and install dependencies:
22-
23-
This installs the dependent packages [needed](https://www.pulumi.com/docs/intro/concepts/how-pulumi-works/) for our Pulumi program.
24-
25-
26-
```bash
27-
$ python3 -m venv venv
28-
$ source venv/bin/activate
29-
$ pip3 install -r requirements.txt
30-
```
31-
3221
1. Run `pulumi up` to preview and deploy changes:
3322

3423
```bash

aws-py-assume-role/README.md

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -23,19 +23,10 @@ resources.
2323
You'll need to set the `create-role:unprivilegedUsername` configuration variable to the name of the unprivilged user, as
2424
well as the AWS region in which to operate.
2525

26-
First, you need install dependencies. In this example we will install them in
27-
a virtual environment named `venv`.
26+
First, you need to create a new stack:
2827

2928
```bash
3029
$ cd create-role
31-
$ python3 -m venv venv
32-
$ source venv/bin/activate
33-
$ pip install -r requirements.txt
34-
```
35-
36-
Now create a new stack:
37-
38-
```bash
3930
$ pulumi stack init assume-role-create
4031
$ pulumi config set create-role:unprivilegedUsername [email protected]
4132
$ pulumi config set aws:region us-east-1
@@ -70,8 +61,7 @@ with the unprivileged user credentials created in Part 1. This can be configured
7061
directory, replacing `{YOUR_STACK_PATH/assume-role-create}` with the full name of your stack from Part 1. Full name of your stack is available at [`app.pulumi.com`][app]
7162

7263
```bash
73-
$ cd assume-role
74-
$ npm install
64+
$ cd ../assume-role
7565
$ export AWS_ACCESS_KEY_ID="$(pulumi stack output --stack {YOUR_STACK_PATH/assume-role-create} accessKeyId)"
7666
$ export AWS_SECRET_ACCESS_KEY="$(pulumi stack output --stack {YOUR_STACK_PATH/assume-role-create} --show-secrets secretAccessKey)"
7767
```
Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
11
name: assume-role
2-
runtime: python
2+
runtime:
3+
name: python
4+
options:
5+
virtualenv: venv
36
description: Demonstrate use of AWS AssumeRole Functionality
Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
11
name: create-role
2-
runtime: python
2+
runtime:
3+
name: python
4+
options:
5+
virtualenv: venv
36
description: Demonstrate use of AWS AssumeRole Functionality

aws-py-dynamicresource/README.md

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -28,16 +28,6 @@ A simple example demonstrating how to write Dynamic Providers using Pulumi.
2828
$ pulumi config set sql-user-password <PASSWORD> --secret
2929
```
3030

31-
1. Create a Python virtualenv, activate it, and install dependencies:
32-
33-
This installs the dependent packages [needed](https://www.pulumi.com/docs/intro/concepts/how-pulumi-works/) for our Pulumi program.
34-
35-
```bash
36-
$ python3 -m venv venv
37-
$ source venv/bin/activate
38-
$ pip3 install -r requirements.txt
39-
```
40-
4131
1. Run `pulumi up -y` to deploy changes:
4232

4333
```bash

aws-py-ec2-provisioners/Pulumi.yaml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
11
name: aws-py-ec2-provisioners
2-
runtime: python
2+
runtime:
3+
name: python
4+
options:
5+
virtualenv: venv
36
description: An example of manually configuring an AWS EC2 virtual machine

aws-py-ec2-provisioners/README.md

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,6 @@ https://github.com/pulumi/pulumi/issues/1691 tracks designing and developing a c
1010

1111
First, create a stack, using `pulumi stack init`.
1212

13-
Now, we need to ensure that our dependencies are installed:
14-
15-
```
16-
$ python3 -m venv venv
17-
$ source venv/bin/activate
18-
$ pip3 install -r requirements.txt
19-
```
20-
2113
Next, generate an OpenSSH keypair for use with your server - as per the AWS [Requirements][1]
2214

2315
```

0 commit comments

Comments
 (0)