Skip to content

Commit

Permalink
Use google-native instead
Browse files Browse the repository at this point in the history
  • Loading branch information
Vivek Lakshmanan committed Apr 16, 2021
1 parent 99ab28c commit bd3e8f4
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 20 deletions.
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
name: gcp-functions
name: google-cloud-ts-functions
runtime: nodejs
description: GCP Functions example
description: Google Cloud Functions example
template:
config:
gcp:project:
google-native:project:
description: The Google Cloud project to deploy into
gcp:region:
google-native:region:
description: The Google Cloud region
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@

# Google Cloud Functions

An example of deploying an HTTP Google Cloud Function endpoint using GCP Native provider and TypeScript.
An example of deploying an HTTP Google Cloud Function endpoint using Google Cloud Native provider and TypeScript.

## Prerequisites

0. [Ensure you have the latest Node.js and NPM](https://nodejs.org/en/download/)
2. [Install the Pulumi CLI](https://www.pulumi.com/docs/get-started/install/)
3. [Configure Pulumi to access your GCP account](https://www.pulumi.com/docs/intro/cloud-providers/gcp/setup/)
3. [Configure Pulumi to access your Google Cloud account](https://www.pulumi.com/docs/intro/cloud-providers/google/setup/)

## Running the App

Expand All @@ -21,14 +21,14 @@ An example of deploying an HTTP Google Cloud Function endpoint using GCP Native
2. Create a new stack:
```
$ pulumi stack init gcp-fn
$ pulumi stack init google-fn
```
3. Configure your GCP project and region:
3. Configure your Google Cloud project and region:
```
$ pulumi config set gcp-native:project <projectname>
$ pulumi config set gcp-native:region <region>
$ pulumi config set google-native:project <projectname>
$ pulumi config set google-native:region <region>
```
4. Run `pulumi up` to preview and deploy changes:
Expand All @@ -50,11 +50,11 @@ An example of deploying an HTTP Google Cloud Function endpoint using GCP Native
```
$ pulumi stack output url
https://us-central1-pulumi-development.cloudfunctions.net/greeting-function-7f95447
$ curl "$(pulumi stack output url)"
$ curl "$(pulumi stack output functionUrl)"
Greetings from Google Cloud Functions!
```
6. Clean up your GCP and Pulumi resources:
6. Clean up your Google Cloud and Pulumi resources:
```
$ pulumi destroy
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
// Copyright 2016-2021, Pulumi Corporation.

import * as gcp from "@pulumi/gcp-native";
import * as gcloud from "@pulumi/google-native";
import * as pulumi from "@pulumi/pulumi";
import * as random from "@pulumi/random";

const config = new pulumi.Config("gcp-native");
const config = new pulumi.Config("google-native");
const project = config.require("project");
const region = config.require("region");

Expand All @@ -16,14 +16,14 @@ const randomString = new random.RandomString("name", {
});

const bucketName = pulumi.interpolate`bucket-${randomString.result}`;
const bucket = new gcp.storage.v1.Bucket("bucket", {
const bucket = new gcloud.storage.v1.Bucket("bucket", {
project: project,
bucket: bucketName,
name: bucketName,
});

const archiveName = "zip";
const bucketObject = new gcp.storage.v1.BucketObject(archiveName, {
const bucketObject = new gcloud.storage.v1.BucketObject(archiveName, {
object: archiveName,
name: archiveName,
bucket: bucket.name,
Expand All @@ -33,7 +33,7 @@ const bucketObject = new gcp.storage.v1.BucketObject(archiveName, {
});

const functionName = pulumi.interpolate`func-${randomString.result}`;
const func = new gcp.cloudfunctions.v1.Function("function-py", {
const func = new gcloud.cloudfunctions.v1.Function("function-py", {
projectsId: project,
locationsId: region,
functionsId: functionName,
Expand All @@ -47,7 +47,7 @@ const func = new gcp.cloudfunctions.v1.Function("function-py", {
ingressSettings: "ALLOW_ALL",
});

const invoker = new gcp.cloudfunctions.v1.FunctionIamPolicy("function-py-iam", {
const invoker = new gcloud.cloudfunctions.v1.FunctionIamPolicy("function-py-iam", {
projectsId: project,
locationsId: region,
functionsId: functionName, // func.name returns the long `projects/foo/locations/bat/functions/buzz` name which doesn't suit here
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
{
"name": "gcp-ts-functions",
"name": "google-cloud-ts-functions",
"version": "1.0.0",
"devDependencies": {
"@types/node": "^8.0.0",
"@types/express": "^4.16.0"
},
"dependencies": {
"@pulumi/gcp-native": "^0.0.2a",
"@pulumi/google-native": "^0.0.1a",
"@pulumi/pulumi": "^3.0.0a",
"@pulumi/random": "^4.0.0a"
}
Expand Down
File renamed without changes.
File renamed without changes.

0 comments on commit bd3e8f4

Please sign in to comment.