by shigemk2

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

Terraform

Terraform ステートロック

ロックファイルっていうとtf.lockの方が出てこないこともないけれど、ロックの実態はバックエンド上にtflockファイルとして配置されている。 バックエンドによってはロックをサポートしていない場合もある。 ロック状態が終わらないならforce-unlockしてもい…

terraform-google-memorystore

importするときはredis_versionは指定しなくてもいい read_replica_modeはtierがSTANDARD_HAの時に必要なパラメータだけど、空文字列で指定してもいい registry.terraform.io github.com

terraform-google-kubernetes-engine beta-private-cluster min_master_version

Minimum master kubernetes version ってあるけど、HCLを見るとrelease_channelがUNSPECIFIEDの場合はmaster_versionを見てて、master_versionはリージョン指定ありならkubernetes_versionか最新のバージョンを取得しようとしてる。ドキュメントが書かれてい…

compute_address vs compute_global_address

リージョン付きなのがcompute_addressで、リージョンなしなのがcompute_global_address registry.terraform.io registry.terraform.io

terraform-google-memorystoreのread_replicas_mode

read_replicas_mode - (Optional) Optional. Read replica mode. Can only be specified when trying to create the instance. If not set, Memorystore Redis backend will default to READ_REPLICAS_DISABLED. HCL見てみると、tierがSTANDARD_HAが指定され…

Terraform を使用するためのベスト プラクティス importしない

マジか、と思ったけど、GKEなんかは特に感じる 可能であれば、(terraform import を使用して)既存のリソースをインポートすることは避けてください。手動で作成したリソースの来歴や構成を完全に把握することは困難です。代わりに Terraform を使用して新…

kms decrypters encrypters

decryptersとかencryptersとかカンマ区切り文字列のlistとか改行できないしいけてないよなあとか思ってたけど複数keyに権限割り振りたいとか要望あるからそうせざるをえなさそうだったhttps://t.co/CXNOdvl9iF— shigemk2 (@shigemk2) 2022年7月21日 list str…

terraform-google-modules/kms

やっていることはこの辺 Simple Cloud KMS module that allows managing a keyring, zero or more keys in the keyring, and IAM role bindings on individual keys. The resources/services/activations/deletions that this module will create/trigger ar…

tfenv 3.0.0

Release v3.0.0 - Major Update · tfutils/tfenv · GitHub Refactor bashlog Fixes for Macs Fixes to Auto Install logic and Use logic Support for netrc and remote-order-reversal for private mirrors あっさりしてる

setup-terraformのupdateCommentについて

github.com サンプルの通りにやればterraform planの結果をプルリクにコメントできるのだけれど、書き方によってはplanするたびに新規投稿していくパターンと最初のplan結果のコメントを更新していくパターンの2種類があって、updateCommentを何回やっても投…

terraform-google-kms

サービスアカウントにどっちかの権限が必要 Cloud KMS Admin: roles/cloudkms.admin Owner: roles/owner github.com

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

vscode-infracost

GitHub - infracost/vscode-infracost: See cost estimates for Terraform right in your editor💰📉 来週試すかも

GitHub Actions inputs

boolじゃなくてboolean on: workflow_dispatch: inputs: name: type: choice description: Who to greet options: - monalisa - cschleiden message: required: true use-emoji: type: boolean description: Include emojis environment: type: environment …

sopsとTerraform メモ

sopsとterraform-provider-sops この方法にしても秘匿情報を環境変数に入れるにしても、tfstateは平文が入る github.com github.com chroju.dev tfstateをGit管理するのはベストプラクティスではない stackoverflow.com

terraform-google-memorystore

GCPのmemorystoreをいい感じに作ってくれるやつ github.com

IntelliJのCannot locate module locally

こういう書き方するとCannot locate module locallyエラーが出てきて module "gce-container-c1" { source = "terraform-google-modules/container-vm/google" version = "~> 2.0" container = { image = "eu.gcr.io/XXXX" } restart_policy = "Always" } so…

Terraform backend GCS 暗号化

GOOGLE_ENCRYPTION_KEYは環境変数でtfvarsではない 設定の中でdataは使えないから、例えばcarlpett/terraform-provider-sopsを使って暗号化した情報を参照させる方法は使えない customer-supplied-keysは本当にcustomer-supplied-keysなので独自の暗号鍵を自…

google_container_cluster.primary.addons_config[0].http_load_balancing is empty list of object

21.2.0。 モジュールを利用したgoogle_container_node_poolのterraform importで以下エラーが出る。 google_container_cluster.primary.addons_config[0].horizontal_pod_autoscaling is empty list of object http_load_balancingとhorizontal_pod_autoscal…

google_pubsub_subscription_iam_member google_pubsub_topic_iam_member

topicとかsubscriptionに火もづくIAMポリシー google_pubsub_subscription_iam_member: Non-authoritative. Updates the IAM policy to grant a role to a new member. Other members for the role for the subscription are preserved. registry.terraform.…

max_ports_per_vm

cloud natのterraformにない max_ports_per_vm (Optional) Maximum number of ports allocated to a VM from this NAT. This field can only be set when enableDynamicPortAllocation is enabled. とな registry.terraform.io モジュールは対応中 github.com…

google-beta

google providerのβ版 workload identity系のところでprovider google-betaになる registry.terraform.io registry.terraform.io 初見だとどこに書いていいかわからないかもしれないけどこの辺に書く resource "google_iam_workload_identity_pool" "this" {…

terraform-google-workload-identity

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

terraform-google-service-accounts

サービスアカウントの管理 IAMのバインディングも管理 github.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