From 51eaf678476ee931be68eebcb331ebbe61cb9a83 Mon Sep 17 00:00:00 2001 From: Toshinori Sugita Date: Sun, 28 Aug 2022 17:04:00 +0900 Subject: [PATCH] Update two-layer-architecture/ --- two-layer-architecture/.terraform.lock.hcl | 28 +++++++++++++++++++ two-layer-architecture/README.md | 3 +- two-layer-architecture/main.tf | 13 +++------ .../terraform.tfvars.sapmple | 9 +++--- 4 files changed, 39 insertions(+), 14 deletions(-) create mode 100644 two-layer-architecture/.terraform.lock.hcl diff --git a/two-layer-architecture/.terraform.lock.hcl b/two-layer-architecture/.terraform.lock.hcl new file mode 100644 index 0000000..d38d8ff --- /dev/null +++ b/two-layer-architecture/.terraform.lock.hcl @@ -0,0 +1,28 @@ +# This file is maintained automatically by "terraform init". +# Manual edits may be lost in future updates. + +provider "registry.terraform.io/hashicorp/google" { + version = "4.32.0" + hashes = [ + "h1:hGZiuBPYAQyjp4D8/nLNcNM6T+FYn1YHGM1NdBPGojQ=", + ] +} + +provider "registry.terraform.io/hashicorp/tls" { + version = "4.0.1" + hashes = [ + "h1:suLkTTvsuB5kqV5gc12PyGT4zY0J9G0RTyWMlZDwSVY=", + "zh:1aa2e4c07ddf87f7bda65a4a0f3b45c3edfbe983768d49a105f7ab9f2e4f8320", + "zh:1b7993daaf659dec421043ccf2dea021972ebacf47e5da3387e1ef35a0ffecbe", + "zh:1c40b056af93fe792fd468a96f317a6ce918849799906cf619a1b8cf01e79ccb", + "zh:3874421e4c975e987ade5bdece6d1eacd41065841c82856cc12fde405ea2fe38", + "zh:4f27e1a90d779ac4bbdbd3db735b4777a90aefc8005905a8ed450bb517c323db", + "zh:b4eb5438dc4bfbed7223c0044b775a210d52b631a9f37d884d567a3eacc31b92", + "zh:b9808ee16fa06b7113a72c8d74f1cb322d0e7364fc34ba4bfdd0424ef7fd93d8", + "zh:bc5b1913fe841a0d40f28ff70d76e1c22fa3f469ae28011422d12c6001dcb954", + "zh:bdba092ae2939cb7e28380c5fd4a33ee96bead1abadbf9ec95d559cea8c04c3c", + "zh:f569b65999264a9416862bca5cd2a6177d94ccb0424f3a4ef424428912b9cb3c", + "zh:f80791f95f0ea5b332913e533c79ed4820e8c9243c508d8c7d6240b212160aaa", + "zh:fe34ecc33c990f045ca5e3828e8aeb8ee86c9072e098e0ac0e4b47cbcb01edc0", + ] +} diff --git a/two-layer-architecture/README.md b/two-layer-architecture/README.md index 22fc6e1..8af1657 100644 --- a/two-layer-architecture/README.md +++ b/two-layer-architecture/README.md @@ -3,8 +3,9 @@ This example doesn't specify a credential and a project intentionally. ```shell $ gcloud auth application-default login +# replace 【YOUR PROJECT】 with your project +# e.g. # export GOOGLE_PROJECT=terraform-toshi0607 -# 【YOUR PROJECT】をあなたのGCPプロジェクトに置き換えてください。 $ export GOOGLE_PROJECT=【YOUR PROJECT】 $ terraform init diff --git a/two-layer-architecture/main.tf b/two-layer-architecture/main.tf index 34eafcf..6686149 100644 --- a/two-layer-architecture/main.tf +++ b/two-layer-architecture/main.tf @@ -1,5 +1,5 @@ terraform { - required_version = ">= 0.12" + required_version = ">= 1.2" } # https://www.terraform.io/docs/providers/google/index.html @@ -19,16 +19,12 @@ resource "google_compute_instance_template" "default" { tags = ["allow-ssh", "allow-service"] disk { - source_image = "debian-cloud/debian-9" + source_image = "debian-cloud/debian-11" } service_account { - scopes = [ - "https://www.googleapis.com/auth/compute", - "https://www.googleapis.com/auth/logging.write", - "https://www.googleapis.com/auth/monitoring.write", - "https://www.googleapis.com/auth/devstorage.full_control", - ] + # https://cloud.google.com/compute/docs/access/service-accounts#authorization + scopes = ["cloud-platform"] } network_interface { @@ -156,7 +152,6 @@ resource "tls_private_key" "example" { # https://registry.terraform.io/providers/hashicorp/tls/latest/docs/resources/self_signed_cert resource "tls_self_signed_cert" "example" { - key_algorithm = tls_private_key.example.algorithm private_key_pem = tls_private_key.example.private_key_pem # Certificate expires after 12 hours. diff --git a/two-layer-architecture/terraform.tfvars.sapmple b/two-layer-architecture/terraform.tfvars.sapmple index 7e81dc7..56354d5 100644 --- a/two-layer-architecture/terraform.tfvars.sapmple +++ b/two-layer-architecture/terraform.tfvars.sapmple @@ -1,7 +1,8 @@ -# 利用する場合は拡張子の .sample 部分を削除してください +# remove .sample when you try tfvars +# replace 【YOUR PROJECT】 with your project +# e.g. # project = "terraform-toshi0607" -# 【YOUR PROJECT】をあなたのGCPプロジェクトに置き換えてください。 -project = 【YOUR PROJECT】 +gcp_project = 【YOUR PROJECT】 gcp_region = "asia-northeast1" -gcp_zone = "asia-northeast1-a" +gcp_zone = "asia-northeast1-c"