6
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

API Gateway から接続するための Cloud Run Ingress の設定を検証

Last updated at Posted at 2025-12-19

API Gateway から接続するための Cloud Run Ingress の設定を検証

はじめに

API Gateway を使って Cloud Run を公開する仕組みを構築する中で、ネットワーク上りの接続設定を指定する必要があります。

Google Cloud サービスなので「内部」を指定したくなるが、ドキュメントには記載がない。ので、「すべて」「内部」それぞれを選択したときの挙動を確認しました。

検証

Ingress = 「すべて」

Cloud Run 環境を作成する(Ingress = 「すべて」)

Cloud Run 環境を作成します。
「関数を作成」から作成開始します。

認証を「認証が必要」、Ingress を「すべて」に設定し、その他はデフォルトのまま作成します。

スクリーンショット 2025-11-20 145202.png

スクリーンショット 2025-11-20 145220.png

ソースコードもデフォルトのまま、コンテナにアクセスすると「Hello World!」と表示されます。

Cloud Run のデプロイに成功したら、ヘッダーの「https://」から始まる文字列をコピーしておきます。
これはコンテナのエンドポイントで、後述の API Gateway の構成で使用します。

スクリーンショット 2025-11-19 144938.png

API Gateway を用意する

API Gateway のゲートウェイを作成します。
API 仕様は以下の通りに指定しました。

openapi2-functions.yaml
# openapi2-functions.yaml
swagger: '2.0'
info:
  title: api-gateway-test1120
  description: API on API Gateway with a Google Cloud Functions backend
  version: 1.0.0
schemes:
  - https
produces:
  - application/json
x-google-backend:
  address: <コンテナのエンドポイント>
paths:
  /:
    get:
      summary: Get hello
      operationId: hello
      responses:
        '200':
          description: A successful response
          schema:
            type: string

接続テスト

ゲートウェイのURLにアクセスします。Get メソッドなのでブラウザから開くことができます。
スクリーンショット 2025-11-20 155454.png

画像の通り、「Hello World!」が表示されます。
スクリーンショット 2025-11-20 160332.png

Ingress = 「内部」

Cloud Run 環境の設定を変更

前述で作成した Cloud Run コンテナの Ingress を「内部」へ変更します。
スクリーンショット 2025-11-20 161610.png

接続テスト

前述と同じゲートウェイのURLにアクセスすると、404エラーが発生します。
スクリーンショット 2025-11-20 161915.png

検証結果

API Gateway から接続する Cloud Run コンテナは、Ingress の「すべて」にする必要がありました。

以上です。
誰かの参考になれば幸いです。

6
0
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
6
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?