Skip to main content

Search the Dev Center

Search tutorials, templates, examples, and more.

AWS and GCP resources

Example showing a single program deploying to both AWS and GCP

This example lives in the pulumi/examples repository. Check out just this directory to use it:

Get started with this example
git clone --filter=blob:none --sparse https://github.com/pulumi/examples pulumi-examples
git -C pulumi-examples sparse-checkout set multicloud-ts-buckets
cd pulumi-examples/multicloud-ts-buckets

This example uses a single Pulumi program to provision resources in both AWS and GCP. It was prepared by starting with the aws-typescript template, and then installing the @pulumi/gcp package from NPM.

Prerequisites#

  1. Install Pulumi
  2. Configure AWS credentials
  3. Configure GCP credentials
  4. Install Node.js

Deploying the example#

  1. Install dependencies:

    Terminal window
    npm install
  2. Create a new stack:

    Terminal window
    pulumi stack init multicloud-aws-gcp
  3. Configure the Pulumi program with the AWS region in which to deploy, and the GCP project ID:

    Terminal window
    pulumi config set aws:region us-east-1
    pulumi config set gcp:project my-project-id
  4. Run the program with pulumi up, with ambient AWS and GCP credentials available. The preview shows resources will be created in both clouds. Confirm the update, and resources are created in each cloud. The outputs show the name of the AWS and GCP buckets respectively.

    Terminal window
    pulumi up
    Updating (multicloud-ts-buckets-dev):
    Type Name Status
    + pulumi:pulumi:Stack multicloud-ts-buckets-multicloud-ts-buckets-dev created
    + ├─ gcp:storage:Bucket my-bucket created
    + └─ aws:s3:Bucket my-bucket created
    Outputs:
    bucketNames: [
    [0]: "my-bucket-c819937"
    [1]: "my-bucket-f722eb9"
    ]
    Resources:
    + 3 created
    Duration: 21.713128552s

Cleaning up#

Once you’re finished experimenting, destroy your stack and remove it to avoid incurring any additional cost:

Terminal window
pulumi destroy
pulumi stack rm

Related

The infrastructure as code platform for any cloud.