by shigemk2

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

Terraform

Terraform Meta Arguments

The Meta-Arguments section documents special arguments that can be used with every resource type, including depends_on, count, for_each, provider, and lifecycle. Terraformのリソースタイプで使えるメタ引数で、リソースの状態そのものに影響しな…

VPC間接続で他VPCのセキュリティグループID参照ができるケース + Terraform

SGはVPCに紐づいているので、VPCピアリングで繋いでやってからSGを指定する VPCピアリング SGのインバウンドルール設定 dev.classmethod.jp で、VPCピアリングはともかく、SGのインバウンドルール設定をTerraformで実現しようとすると、他アカウントのSGを参…

Terraform concat

一般的なconcatと動きは一緒、list型をくっつける。 > concat(["a", ""], ["b", "c"]) [ "a", "", "b", "c", ] developer.hashicorp.com

terraform cloud tutorial

terraform cloud tutorial developer.hashicorp.com

RFC 1034 メモ

When a user needs to type a domain name, the length of each label is omitted and the labels are separated by dots ("."). Since a complete domain name ends with the root label, this leads to a printed form which ends in a dot. We use this p…

terraform doc output

terraform-docs.io

aws_ecs_task_definitionのcontainer_definitions

jsonencodeでもfileでもいい なおTerraform自体がGoベースで、jsonencodeのところでterraform planに失敗したらGoなエラーログが出てくるので、Goの知識が多少必要 registry.terraform.io

aws_lb

まずCreateLoadBalancerしてから、削除保護やアクセスログの設定などについてModifyLoadBalancerAttributes感じの流れ registry.terraform.io なおS3アクセスログの設定をしたいのであれば、以下に沿ってバケットポリシーの設定をしてやらないと、対象S3バケ…

Terraform force-unlock

S3でバックエンド管理しててDynamoDBでロック管理している時にapplyがタイムアウトした時なんかにロックが発生する ので、terraform force-unlock (lock id)してやる developer.hashicorp.com

SSM Parameter CloudFormation と Terraform

SecureStringなパラメータストア、Terraformでは作れるがCFnでは作れない。でもTerraformで作れても値は平文でstateに保存されるので、ちょっと工夫が必要 https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/ssm_parameter docs…

s3_bucket_public_access_block

特に書くことはなく、以下4つをtrue falseするだけ resource "aws_s3_bucket" "example" { bucket = "example" } resource "aws_s3_bucket_public_access_block" "example" { bucket = aws_s3_bucket.example.id block_public_acls = true block_public_poli…

TerraformでS3バケットのindex_documentを設定する方法

index_documentはsuffixを使う。aws_s3_bucketの中のindex_document(depcreated)だとsuffixが必要なかった。 resource "aws_s3_bucket_website_configuration" "example" { bucket = aws_s3_bucket.example.id index_document { suffix = "index.html" } } h…

aws_s3_bucket_server_side_encryption_configuration

The server_side_encryption_configuration attribute is deprecated. See aws_s3_bucket_server_side_encryption_configuration for examples with server side encryption configured. なので、SSEは別ブロックで対応する。 デフォルトだとこういう感じな…

importブロック

v1.5.0以上の機能。idが事前にわかってないとimportブロックは使えないそうだがどういうidはproviderのドキュメントを読め、とのこと。 import { to = aws_instance.example id = "i-abcd1234" } resource "aws_instance" "example" { name = "hashi" # (oth…

Terraform data aws_subnets

データソース aws_subnets はサブネットIDのセットを取得する We removed the aws_subnet_ids data source. Use the aws_subnets data source instead. 似た名前のaws_subnet_idsは5でなくなりました Terraformのmap(string)は { name: value } ではなく { n…

vpc_security_group_ids

If you are creating Instances in a VPC, use vpc_security_group_ids instead. VPC内でEC2インスタンスを作成するときにvpc_security_group_idsではなくsecurity_groupsを指定すると、後でapplyする時にインスタンス強制再作成となってしまうので、ドキュ…

terraform backend s3

Stores the state as a given key in a given bucket on Amazon S3. This backend also supports state locking and consistency checking via Dynamo DB, which can be enabled by setting the dynamodb_table field to an existing DynamoDB table name. A…

terraform type map

map (or object): a group of values identified by named labels, like {name = "Mabel", age = 52}. map(any)だと↑のような書き方になる developer.hashicorp.com

wafv2_ip_set

scope - (Required) Specifies whether this is for an AWS CloudFront distribution or for a regional application. Valid values are CLOUDFRONT or REGIONAL. To work with CloudFront, you must also specify the Region US East (N. Virginia). ってい…

terraform google_composer_environment

We STRONGLY recommend you read the GCP guides as the Environment resource requires a long deployment process and involves several layers of GCP infrastructure, including a Kubernetes Engine cluster, Cloud Storage, and Compute networking re…

terraform-google-secret-manager

そのうちterraform-google-modulesに移行しそうな気はしている github.com registry.terraform.io registry.terraform.io

max_time_travel_hours近況

2023年2月などに出たプルリクでmax_time_travel_hoursなるパラメータ対応が出てきた。 マージ自体はされているが、リリースには出ていないので、5.4.3をダウンロードしてもmax_time_travel_hoursには対応していない。 詳しく調べきれていないけれど、タイム…

terrafrom target

You can use Terraform's -target option to target specific resources, modules, or collections of resources. In this tutorial, you will provision an S3 bucket with some objects in it, then apply changes incrementally with -target. terrafrom …

Cloud BuildでTerraformのCICDするチュートリアル

ざっくり リポジトリにCloud Build GitHub appをインストール Cloud Build用のサービスアカウントを作成して、editor権限を付与 Cloud Buildからリポジトリに接続 Cloud Buildのトリガー作成 cloudbuild.yamlを書く cloud.google.com github.com

IAM policy for Google Cloud KMS crypto key

KMSのencryptor decryptorをいい感じに設定するためのIAMポリシーのところ registry.terraform.io $ terraform import google_kms_crypto_key_iam_binding.crypto_key "your-project-id/location-name/key-ring-name/key-name roles/editor"

まっさらなプロジェクトでterraform-google-memorystoreでredisを立てる時のメモ

v6.0.0 module "redis_test_00001" { source = "terraform-google-modules/memorystore/google" version = "6.0.0" enable_apis = false name = "redis_test_00001" project = data.google_project.current.project_id connect_mode = "PRIVATE_SERVICE_ACCE…

An IP range in the local network (xxxxxxxxxxx) allocated by resource (xxxxxxxxxxxx) overlaps with an IP range (xxxxxxxxxxxx) in an active peer of the peer network.”

ピアリング接続を作成しようとしたらエラーが出た。 「注: ピアリングした VPC ネットワーク内のサブネットの IP 範囲は重複してはなりません。」 って注意されているんだから、ピアリングしたVPCネットワークでサブネットのIPが重複していたらダメだよね。 …

Existing secondary range cannot be modified

サブネットワークのセカンダリ ipv4 レンジをTerraformで更新しようとしたら失敗するやつ github.com 更新ができないなら削除して追加をTerraformの内々で実行すればいいんだろうけど、このIssueが起票されてから数年間ずっと緑が続いているのを考えると、諦…

terraformer

resourcesは省略できない resourcesでワイルドカードは使えない resourcesで対応していないリソースタイプがある(Secret Managerとか) 実行した後にterraform.tfstateにステートファイルとして残るので、これをバックエンドの適当なところにアップロードすれ…

Terraform Modules

Terraformのモジュール、いろんな概念があってわかりづらい Root Modules Every Terraform configuration has at least one module, known as its root module, which consists of the resources defined in the .tf files in the main working directory. T…