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

More than 1 year has passed since last update.

Setup memo for "a custom domain with API Gateway" 🚪

Last updated at Posted at 2023-05-23

こんにちは。Enabling team の山本です。

2023年5月3回目は、「API Gateway でカスタム ドメインを使用する※」方法についてです。

※2023年5月23日時点では、Preview です。

一回、手順通りにやったつもりで撃沈したため、備忘録として書きます。

先日、とある会議で『API Gateway の URL って、ドメインに登録されてないですよね 😤!』と指摘を受けました。

確かに、、、

開発者にAPI Gateway を設定するよう伝えましたが、ドメインまでは気が回りませんでした。ごめんなさい。

と言うことで、今回は、誰も拾わないタスクを回収します。

TL;DR

  • backend service は、自分で作成しましょう。

Installation

echo $SERVERLESS_NEG_NAME
echo $REGION_ID
echo $GATEWAY_ID
echo $BACKEND_SERVICE_NAME
echo $URL_MAP_NAME
echo $SSL_CERTIFICATE_NAME
echo $DOMAIN
echo $TARGET_HTTP_PROXY_NAME
echo $HTTPS_FORWARDING_RULE_NAME
gcloud beta compute network-endpoint-groups create $SERVERLESS_NEG_NAME \
  --region=$REGION_ID \
  --network-endpoint-type=serverless \
  --serverless-deployment-platform=apigateway.googleapis.com \
  --serverless-deployment-resource=$GATEWAY_ID
  • GUI では、API Gateway の設定を確認できないようです。
    hoge-dev.jpg

  • describe すると API Gateway の NEG を確認できます。

yamamoto_daisuke@cloudshell:~ (hoge-368105)$ gcloud beta compute network-endpoint-groups describe $SERVERLESS_NEG_NAME --region=$REGION_ID
creationTimestamp: '2023-05-23T03:46:41.636-07:00'
id: '1666822574193583990'
kind: compute#networkEndpointGroup
name: api-gateway-serverless-neg-hoge-dev
networkEndpointType: SERVERLESS
region: https://www.googleapis.com/compute/beta/projects/hoge-368105/regions/asia-northeast1
selfLink: https://www.googleapis.com/compute/beta/projects/hoge-368105/regions/asia-northeast1/networkEndpointGroups/api-gateway-serverless-neg-hoge-dev
serverlessDeployment:
  platform: apigateway.googleapis.com
  resource: hoge-gateway-dev
size: 0
yamamoto_daisuke@cloudshell:~ (hoge-368105)$
  • backend service が最初に必要です。手順には、記載されていません。
  • Option の指定は必要ありません。
gcloud compute backend-services create $BACKEND_SERVICE_NAME \
  --global
gcloud compute backend-services add-backend $BACKEND_SERVICE_NAME \
  --global \
  --network-endpoint-group=$SERVERLESS_NEG_NAME \
  --network-endpoint-group-region=$REGION_ID
gcloud compute url-maps create $URL_MAP_NAME \
  --default-service $BACKEND_SERVICE_NAME
gcloud compute ssl-certificates create $SSL_CERTIFICATE_NAME \
  --domains $DOMAIN
gcloud compute target-https-proxies create $TARGET_HTTP_PROXY_NAME \
  --ssl-certificates=$SSL_CERTIFICATE_NAME \
  --url-map=$URL_MAP_NAME
gcloud compute forwarding-rules create $HTTPS_FORWARDING_RULE_NAME \
  --target-https-proxy=$TARGET_HTTP_PROXY_NAME \
  --global \
  --ports=443

Summary

API Gateway でカスタム ドメインを設定しました。
基本的には、Google の Docs に従えば、問題なく使えると思います。
ドメイン系は、「Provisioning」の待ち時間があり、成功か失敗か分かりにくいため、避けがちです。

最近、加齢とともに脳機能の衰えを感じ始めました。
聞くところによると、手書きで文章を書いたり、小さな目標を持つと前頭前野が活性化されるそうです。
日々、その日の目標と達成するタスクを残して行きます。
責任ある親として、健康に生きるために。

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