Skip to content

Commit

Permalink
Merge pull request pulumi#178 from pulumi/multi-cloud-example
Browse files Browse the repository at this point in the history
Add multi-cloud example targeting AWS and GCP
  • Loading branch information
jen20 committed Nov 16, 2018
2 parents c7cf24b + ad6060b commit 05d78b1
Show file tree
Hide file tree
Showing 6 changed files with 130 additions and 0 deletions.
2 changes: 2 additions & 0 deletions multicloud-ts-buckets/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
/bin/
/node_modules/
11 changes: 11 additions & 0 deletions multicloud-ts-buckets/Pulumi.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
name: multicloud-ts-buckets
runtime: nodejs
description: Example showing a single program deploying to both AWS and GCP
template:
description: Example showing a single program deploying to both AWS and GCP
config:
aws:region:
description: The AWS region in which to perform operations
default: us-east-1
gcp:project:
description: The ID of the GCP project in which deploy resources
69 changes: 69 additions & 0 deletions multicloud-ts-buckets/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
[![Deploy](https://get.pulumi.com/new/button.svg)](https://app.pulumi.com/new)

# Multi-Cloud in AWS and GCP using TypeScript

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.

## Getting Started

Install prerequisites with:

```shell
$ npm install
```

Create a new stack:

```shell
$ pulumi stack init multicloud-aws-gcp
```

Configure the Pulumi program with the AWS region in which to deploy, and the GCP project ID:

```shell
$ pulumi config set aws:region us-east-1
$ pulumi config set gcp:project my-project-id
```

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.

```shell
$ pulumi up
Previewing update (multicloud-ts-buckets-dev):

Type Name Plan
+ pulumi:pulumi:Stack multicloud-ts-buckets-multicloud-ts-buckets-dev create
+ ├─ gcp:storage:Bucket my-bucket create
+ └─ aws:s3:Bucket my-bucket create

Resources:
3 changes
+ 3 to create

Do you want to perform this update? yes
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 changes
+ 3 created

Duration: 21.713128552s

Permalink: https://app.pulumi.com/jen20/multicloud-ts-buckets-dev
```

15 changes: 15 additions & 0 deletions multicloud-ts-buckets/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import * as aws from "@pulumi/aws";
import * as gcp from "@pulumi/gcp";

// Create an AWS resource (S3 Bucket)
const awsBucket = new aws.s3.Bucket("my-bucket");

// Create a GCP resource (Storage Bucket)
const gcpBucket = new gcp.storage.Bucket("my-bucket");

// Export the names of the buckets
export const bucketNames = [
awsBucket.bucket,
gcpBucket.name,
];

11 changes: 11 additions & 0 deletions multicloud-ts-buckets/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"name": "aws-typescript",
"devDependencies": {
"@types/node": "latest"
},
"dependencies": {
"@pulumi/aws": "latest",
"@pulumi/gcp": "latest",
"@pulumi/pulumi": "latest"
}
}
22 changes: 22 additions & 0 deletions multicloud-ts-buckets/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"compilerOptions": {
"outDir": "bin",
"target": "es6",
"lib": [
"es6"
],
"module": "commonjs",
"moduleResolution": "node",
"sourceMap": true,
"experimentalDecorators": true,
"pretty": true,
"noFallthroughCasesInSwitch": true,
"noImplicitAny": true,
"noImplicitReturns": true,
"forceConsistentCasingInFileNames": true,
"strictNullChecks": true
},
"files": [
"index.ts"
]
}

0 comments on commit 05d78b1

Please sign in to comment.