Now that we have a basic project, let’s add the Pulumi AWS provider and configure our credentials.
Pulumi created a virtualenv
for us when we created our iac-workshop
project. We’ll need to activate it to install dependencies:
source venv/bin/activate
Add the following content to requirements.txt
:
pulumi_aws>=5.0.0,<6.0.0
Run the following command to install the AWS packages:
pip3 install -r requirements.txt
Now that the AWS package is installed, we need to import it as part of our project.
Add the following to the top of your __main.py__
:
import pulumi_aws as aws
✅ After this change, your
__main__.py
should look like this:
"""A Python Pulumi program"""
import pulumi
import pulumi_aws as aws
Configure the AWS region you would like to deploy to, replacing us-east-1
with your AWS region of choice:
pulumi config set aws:region us-east-1
Note that the previous command will create the file Pulumi.dev.yaml
which contains the configuration for our dev
stack. (Stacks are logical groupings of Pulumi resources.) We will be working with a single Pulumi stack in this tutorial, but we could define additional stacks to deploy our infrastructure to different regions/accounts with different parameters. To learn more about Pulumi stacks, see Stacks in the Pulumi docs.
If you are using an alternative AWS profile, you can tell Pulumi which to use in one of two ways:
export AWS_PROFILE=<profile name>
pulumi config set aws:profile <profile name>