3.2 Installing and Configuring the AWS and AWSX Providers

Now that we have our project boilerplate, we will add 2 Pulumi providers:

  1. AWS Classic, which gives us all the fundamental AWS resources, like VPC subnets.
  2. AWSx, which contains higher level Pulumi components, like a full, production-ready VPC that includes subnets, NAT gateways, routing tables, and so on.

Step 1 — Install the AWS and AWSx Packages

Run the following commands to install the AWS Classic and AWSX packages:

npm i @pulumi/aws @pulumi/awsx

Step 2 — Import the AWS Package

Now that our packages are installed, we need to import them as part of our project.

Add the following to your index.ts:

import * as aws from "@pulumi/aws";
import * as awsx from "@pulumi/awsx";

After this change, your __main__.py should look like this:

import * as pulumi from "@pulumi/pulumi";
import * as aws from "@pulumi/aws";
import * as awsx from "@pulumi/awsx";

(Optional) Step 3 — Configure an AWS Region

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.

(Optional) Step 4 — Configure an AWS Profile

If you are using an alternative AWS profile, you can tell Pulumi which to use in one of two ways:

  • Using an environment variable: export AWS_PROFILE=<profile name>
  • Using configuration: pulumi config set aws:profile <profile name>