by shigemk2

当面は技術的なことしか書かない

GCP

terraform-google-workload-identity

workload identityをterraform管理するふうのやつだけど違う registry.terraform.io

terraform-google-service-accounts

サービスアカウントの管理 IAMのバインディングも管理 github.com

gcloud projects get-iam-policy

GCP

はい。 gcloud projects get-iam-policy example-project-id-1 --filter "bindings.members=(serviceAccount:xxxxxx@xxxxxx.iam.gserviceaccount.com)" cloud.google.com

terraform-google-modules/network firewall-rules

terraform-google-modules/networkのsubmodule firewall-rulesでcompute_firewallは管理できる。そんな難しくなかった。 registry.terraform.io registry.terraform.io

terraform-google-modules compute_instance

このサブモジュールを利用して作成されるリソースのタイプはgoogle_compute_instance_from_templateなので、google_compute_instanceじゃない。 google_compute_instanceを使いたい時はモジュール使わない方が良さそう github.com registry.terraform.io

Terraform zipmap

見て覚える感じ 二つのlistを合わせて一つのmapを作る > zipmap(["a", "b"], [1, 2]) { "a" = 1 "b" = 2 } Each pair of elements with the same index from the two lists will be used as the key and value of an element in the resulting map. If the s…

cannot find a common base type for all elements.

自分はterraform-google-modules/cloud-storageのsimple_bucketサブモジュールで遭遇したんだけど、必要なelementが足りてないってこと?あまりにも情報量が少ないのでめんくらっちゃった。 こういうふうに書いてterraform planしたらばrefreshing state自体…

限定公開クラスター

cloud.google.com Terraform的にはこの辺かな registry.terraform.io

google_service_account

サービスアカウント情報を管理。 resourceもdataもあるしdataはresourceを定義しなくても使える。 registry.terraform.io

terraform-google-kubernetes-engine timeouts

timeoutsの設定、masterにはマージされているけど現状最新の21.1.0じゃ設定にないから、内部で設定してあるデフォルト値のようなものが入る。 github.com github.com

google_compute_router_nat vs terraform-google-cloud-nat

addressとかnatとかが既に作成されているならregistryの書き方をなぞった方が早いかも registry.terraform.io github.com

terraform-google-kubernetes-engine timeouts

2022/06/17のmasterブランチにはtimeoutsオプションがありげだったけど2週間前にマージされた機能であるから、まだ21.1.0にはなかった github.com

terraform-google-network

network/subnetwork/routeをまとめて作るterraformのモジュールでGCP開発。 github.com flow log周りとかsecondary ip rangeとか、terraform-google-modulesのソースコードを見たらわかるけどループでぐるぐる回してる このモジュールの設定が、実際のterraf…

google_compute_route

ルートのリソース。 A Route resource must have exactly one specification of either nextHopGateway, nextHopInstance, nextHopIp, nextHopVpnTunnel, or nextHopIlb. なんかoptionalな風を見せてるけどnext hopの設定はどれか設定してやらないといけない…

gcloud beta resource-config list-resource-types

GCP

cloud.google.com exportできるリソースタイプのリストを出力する。 gcloud beta resource-config list-resource-types --[project|organization|folder]=<PARENT></parent>

supported asset types

GCP

gcloud beta resource-config bulk-exportのresoure-types、case sensitiveなんやね cloud.google.com

gsutilのlsとかrmとか

GCP

lsはなんかちょっとS3より直感的かも知れない。rmでオブジェクト削除。 cloud.google.com cloud.google.com

gcloud beta resource-config bulk-export

形式はTerraformです。 gcloud beta resource-config bulk-exportしてHCLファイルを出力し、gcloud beta resource-config terraform generate-importしてTerraformモジュールとimportスクリプトを出力し、スクリプトを実行してterraform importする。import…

GCP IAMロール

GCP

storage cloud.google.com compute cloud.google.com

gcs pap

GCP

public access preventionの略。公開アクセスの防止がenforcedでinheritedが組織ポリシーの制約適用。 cloud.google.com cloud.google.com

terraformerとtfc

terraformer importしてterraform initするところまでは一緒だけど、providerをreplaceしないといけない。terraformerが最新に合っていないのか、、 あとはprovider.tfにcloudブロックを入れて、terraform init $ terraform state replace-provider registry…

terraformer

Google謹製だから余程のことがない限りはメンテは続くと思う。 類似のterraformingがりどみで紹介されていたけど去年末にメンテ終了してしまった。 github.com 例 terraformer import google --resources=gcs,forwardingRules,httpHealthChecks --connect=tr…

Terraform google_secret_manager_secret

AWSのsecrets managerみたいなものか registry.terraform.io

Terraform google_bigquery_table

リソースを指定するときはデータセットもセットで。 $ terraform import google_bigquery_table.default gcp-project/foo/bar registry.terraform.io

Terraform google_storage_bucket

ポイントはこの辺 $ terraform import google_storage_bucket.image-store image-store-bucket $ terraform import google_storage_bucket.image-store tf-test-project/image-store-bucket registry.terraform.io

terraform import google_compute_instance

書き方。 $ terraform import google_compute_instance.default projects/{{project}}/zones/{{zone}}/instances/{{name}} $ terraform import google_compute_instance.default {{project}}/{{zone}}/{{name}} $ terraform import google_compute_instance.…

gcloud compute instances list

GCP

compute engineのインスタンスリスト cloud.google.com

gcloud projects add-iam-policy-binding

GCP

IAMをプロジェクトにバインド gcloud projects add-iam-policy-binding PROJECT_ID --member=PRINCIPAL --role=ROLE [--condition=[KEY=VALUE,…] | --condition-from-file=CONDITION_FROM_FILE] [GCLOUD_WIDE_FLAG …] cloud.google.com

GCP AWS Azureサービス比較表

どのサービスがどのサービスに相当するかの比較表(例 S3とGCSとAzure Blob Storage)など cloud.google.com