Closed2

GCPでIPアドレス固定にする方法

しんのすけしんのすけ

IP アドレス 固定

静的 IPアドレス 発行

gcloud compute addresses create production-ip --region=asia-northeast1

VPC ネットワーク 作成

gcloud compute networks create production-vpc --subnet-mode=custom --mtu=1460 --bgp-routing-mode=regional

カスタムサブネット 作成

gcloud compute networks subnets create production-subnet \
    --range=192.168.1.0/24 \
    --stack-type=IPV4_ONLY \
    --network=production-vpc \
    --region=asia-northeast1

サーバーレス VPC アクセス 作成

gcloud compute networks vpc-access connectors create production-connector \
    --region=asia-northeast1 \
    --network=production-vpc \
    --range=10.8.0.0/28 \
    --min-instances=2 \
    --max-instances=10 \
    --machine-type=e2-micro

Cloud Router 作成

gcloud compute routers create production-router \
    --network=production-vpc \
    --region=asia-northeast1

Cloud NAT 作成

gcloud compute routers nats create production-nat \
    --router=production-router \
    --region=asia-northeast1 \
    --nat-all-subnet-ip-ranges \
    --nat-external-ip-pool=production-ip \
    --enable-dynamic-port-allocation \
    --min-ports-per-vm=4096 \
    --max-ports-per-vm=65536 \
    --enable-logging \
    --log-filter=ERRORS_ONLY
しんのすけしんのすけ

Cloud functionsで固定したIPアドレス経由で外部にアクセスする

gcloud functions deploy [NAME] \
    --trigger-http \
    --egress-settings all \
    --vpc-connector=production-connector \
    --allow-unauthenticated
このスクラップは2ヶ月前にクローズされました