---
title: "Google Cloud TypeScript Starter"
description: "A minimal Google Cloud TypeScript Pulumi program"
url: "https://www.pulumi.com/dev/templates/gcp-typescript/"
image: "https://www.pulumi.com/assets/og/dev/templates/gcp-typescript.png"
---

# Google Cloud TypeScript Starter

A minimal Google Cloud TypeScript Pulumi program

## Before you begin

For this walkthrough, you'll need:

- [x] The [Pulumi CLI](https://www.pulumi.com/docs/install/)
- [x] A [Google Cloud account](https://cloud.google.com/free)
- [x] The [gcloud CLI](https://cloud.google.com/sdk/docs/install) (optional, but recommended and used in this guide)
- [x] Pulumi [configured with your Google Cloud credentials](https://www.pulumi.com/registry/packages/gcp/installation-configuration#credentials)
- [x] Permission to manage Cloud Storage
- [x] A current version of [Node.js](https://nodejs.org/en/download) and [npm](https://www.npmjs.com/package/npm) installed locally

## Create a new project

This starter creates a Google Cloud Storage bucket in the `US` multi-region and exports the bucket's `gs://` URL.

```bash
mkdir my-project; cd my-project
pulumi new gcp-typescript
```

The `pulumi new` command walks you through creating and configuring the new project and stack. A [stack](https://www.pulumi.com/docs/iac/concepts/stacks/) is an instance of a project, and you can have many of them (`dev`, `staging`, `prod`), each with its own [configuration](https://www.pulumi.com/docs/iac/concepts/config/) settings. Depending on the language, you may also be asked for your preferred package manager or toolchain.

It also asks for the template's setting, `gcp:project`. It has no default, so enter the ID of the Google Cloud project to deploy into:

| Key | Description | Default |
| --- | --- | --- |
| `gcp:project` | The Google Cloud project to deploy into | — |

You can change values like these later with `pulumi config set`:

```bash
pulumi config set gcp:project <value>
```

## Review the code

When setup completes, you'll see a few files:

- `Pulumi.yaml` contains the project name and the language it's written in.
- `Pulumi.dev.yaml` contains the `dev` stack's settings, including the values you just entered.
- `index.ts` contains the program code that declares your cloud resources.

Take a moment to open them up and have a look. Here's what's in `index.ts`:

```typescript title="index.ts"
import * as pulumi from "@pulumi/pulumi";
import * as gcp from "@pulumi/gcp";

// Create a GCP resource (Storage Bucket)
const bucket = new gcp.storage.Bucket("my-bucket", {
    location: "US"
});

// Export the bucket's gs:// URL
export const bucketName = bucket.url;
```

## Deploy the project

Deploy with [`pulumi up`](https://www.pulumi.com/docs/iac/cli/commands/pulumi_up). It starts with a preview of what it's about to create and asks before it changes anything. Choose `yes` to deploy.

Pulumi adds a random suffix to most resource names, so `my-bucket` becomes something like `my-bucket-4f8a2c1`. This is [autonaming](https://www.pulumi.com/docs/iac/concepts/resources/names/#autonaming). It lets you deploy the same program to more than one stack, and lets Pulumi create a replacement before it deletes the old resource, without names colliding.

```bash
$ pulumi up
```

When it finishes, Pulumi prints the stack's outputs, values it only knows once the resources exist. This program exports the bucket's `gs://` URL. Read it any time with `pulumi stack output <name>`, or pass it to another command. This one prints the bucket's details, including its name and location:

```bash
$ gcloud storage buckets describe $(pulumi stack output bucketName)
```

**Need help?**

If `pulumi up` reports `failed to load application credentials`, sign in again:

```bash
$ gcloud auth application-default login
```

Still stuck? [Let us know](https://github.com/pulumi/docs/issues/new).

## Customize the project

Put a file in the bucket. In `index.ts`, add this below the bucket:

```typescript
new gcp.storage.BucketObject("hello", {
    bucket: bucket.name,
    name: "hello.txt",
    content: "Hello, Pulumi!",
});
```

Deploy again. The preview shows one object to create:

```bash
$ pulumi up
```

Then read the file back from the bucket. It prints `Hello, Pulumi!`:

```bash
$ gcloud storage cat "$(pulumi stack output bucketName)/hello.txt"
```

To see what else you can add, browse the [Google Cloud provider](https://www.pulumi.com/registry/packages/gcp/) in the Pulumi Registry.

## Cleaning up

You can destroy the stack and all of its infrastructure with [`pulumi destroy`](https://www.pulumi.com/docs/iac/cli/commands/pulumi_destroy), then remove the stack with [`pulumi stack rm`](https://www.pulumi.com/docs/iac/cli/commands/pulumi_stack_rm):

```bash
$ pulumi destroy
$ pulumi stack rm
```

## Links

- Deploy with Pulumi: https://app.pulumi.com/new?template=https%3A%2F%2Fgithub.com%2Fpulumi%2Ftemplates%2Ftree%2Fmaster%2Fgcp-typescript
- Source on GitHub: https://github.com/pulumi/templates/tree/master/gcp-typescript
