LoginSignup
1
2

More than 5 years have passed since last update.

UbuntuにGoogle Cloud Functions 環境構築

Last updated at Posted at 2018-02-17

公式のドキュメントにUbuntu向けの内容があるので、それに従えばよい。

GCPプロジェクトの準備

Quickstart: Using the gcloud Command-Line Tool  |  Cloud Functions Documentation  |  Google Cloud Platform
Before you beginの1~3を済ませる

Cloud SDKのインストール

Google Cloud SDK ドキュメント  |  Cloud SDK  |  Google Cloud Platform
"DEBIAN、UBUNTU"の内容に従う
gcloud init時先ほど作成したプロジェクトのIDを選択する

内容が重複していそうな↓のページがあるが、こちらはgcloud initについて詳しく書かれている
Debian / Ubuntu 用のクイックスタート  |  Cloud SDK のドキュメント  |  Google Cloud Platform

Node.js開発環境

Node.js 開発環境のセットアップ  |  Node.js  |  Google Cloud Platform

Hello World

Quickstart: Using the gcloud Command-Line Tool  |  Cloud Functions Documentation  |  Google Cloud Platform
Create a function以降を実施

/**
 * HTTP Cloud Function.
 *
 * @param {Object} req Cloud Function request context.
 * @param {Object} res Cloud Function response context.
 */
exports.helloGET = (req, res) => {
  res.send('Hello World!');
};

デプロイしたい関数はexports.ほにゃららの形で定義する

1
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
2