Create a new google cloud project.
This commit is contained in:
parent
1ae9f8601d
commit
f70303193b
1
terraform/.gitignore
vendored
Normal file
1
terraform/.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
||||
.terraform
|
62
terraform/.terraform.lock.hcl
Normal file
62
terraform/.terraform.lock.hcl
Normal file
@ -0,0 +1,62 @@
|
||||
# This file is maintained automatically by "terraform init".
|
||||
# Manual edits may be lost in future updates.
|
||||
|
||||
provider "registry.terraform.io/hashicorp/google" {
|
||||
version = "5.36.0"
|
||||
constraints = "5.36.0"
|
||||
hashes = [
|
||||
"h1:ZEMkbWcaEqnSb6UQhMXFzs6B2xDgvbKlkBIrrk862V8=",
|
||||
"zh:091f4e82ee4ba77cd37b67d9c24448a1317e8e103bd5f3191f7b4b26b314f2e6",
|
||||
"zh:15aed0b4cc85ee275aa32740ecf745f4ff6da09ed7c705900d93f5d0e454fcd1",
|
||||
"zh:403cc4daf32aa31fe89940aca6d1d320531103801d5c4678107f3c952d126875",
|
||||
"zh:539c774fb97bc2dd6cd67f436ae062c2fc50d9181aa4f4ae626dc428dce1bb82",
|
||||
"zh:5857cf533a5db0853f81f2662681e95556b0972cae0bd5cff02d24f2a0cb395e",
|
||||
"zh:7e802ee04b9ea84f1667ac8e970dc559709628555e1350b4996f07b067da041d",
|
||||
"zh:90a62593c84543f8d8f7848ae3b75d3190e6ad36cf38e2d5ca321771668c77e6",
|
||||
"zh:9e2cf799c61dd4f534f84705db3ab00142d0a5b58ea147a6a67f5bd902f31eba",
|
||||
"zh:b3470f63ef5621eab6501c7024ba74480def676cb58331755484ffcf1c64b3d8",
|
||||
"zh:b6a640f7cbee78880e901512d193e6863339eb18f552903e7298ceb023543486",
|
||||
"zh:cddaca8c950334a22849b6499c0dde289ac8e9767d29ee1504e70872201d8da8",
|
||||
"zh:f569b65999264a9416862bca5cd2a6177d94ccb0424f3a4ef424428912b9cb3c",
|
||||
]
|
||||
}
|
||||
|
||||
provider "registry.terraform.io/hashicorp/google-beta" {
|
||||
version = "5.36.0"
|
||||
constraints = "5.36.0"
|
||||
hashes = [
|
||||
"h1:Hj9tw3fkPV5f1/CviqSfW0Ex2Pg/bba+HXq1ek/tszQ=",
|
||||
"zh:1516867331b7c1e53d28e929d4bcc77199e9ed2c733b1dd805a0445c7bd55708",
|
||||
"zh:25750a11add3099e8773c512e7820a4c5e04a66b431626a47d37e992308387dc",
|
||||
"zh:5085899f0d71fa03798da4285e6334464abf8ad8bc86017c795942aceeac1b34",
|
||||
"zh:53f2b06d25948ba222a2d8cc4583bb14c588aa37e2eeca4b63eaa609665d9e72",
|
||||
"zh:5a78890d4e88085b4f17b7d3266773ae1d95ac2376a945defb77125831fa3546",
|
||||
"zh:5cdb4c91c65688a3a6341f543aaee5e4645003f9af152189bd324589f3449535",
|
||||
"zh:6cfa032855dbb86325a7c832164346b83fda7ee41a6e679d1b06fb3d4eebd5d6",
|
||||
"zh:9d4c34d545fcafa928d38c41b76d8638109924a176e9d8da74eca835874c0181",
|
||||
"zh:a330ec2300476d553f553863f1d6183053ac669f6e9663f095cf3f712485b666",
|
||||
"zh:d1fa47a22727931d16282a7b14c0476383820db5bc266632e5df5a2506562735",
|
||||
"zh:e243237d3415452935b3e42dd90ab170feb4fc1511819e6a99f895c29e9a73c1",
|
||||
"zh:f569b65999264a9416862bca5cd2a6177d94ccb0424f3a4ef424428912b9cb3c",
|
||||
]
|
||||
}
|
||||
|
||||
provider "registry.terraform.io/hashicorp/random" {
|
||||
version = "3.6.2"
|
||||
constraints = "3.6.2"
|
||||
hashes = [
|
||||
"h1:wmG0QFjQ2OfyPy6BB7mQ57WtoZZGGV07uAPQeDmIrAE=",
|
||||
"zh:0ef01a4f81147b32c1bea3429974d4d104bbc4be2ba3cfa667031a8183ef88ec",
|
||||
"zh:1bcd2d8161e89e39886119965ef0f37fcce2da9c1aca34263dd3002ba05fcb53",
|
||||
"zh:37c75d15e9514556a5f4ed02e1548aaa95c0ecd6ff9af1119ac905144c70c114",
|
||||
"zh:4210550a767226976bc7e57d988b9ce48f4411fa8a60cd74a6b246baf7589dad",
|
||||
"zh:562007382520cd4baa7320f35e1370ffe84e46ed4e2071fdc7e4b1a9b1f8ae9b",
|
||||
"zh:5efb9da90f665e43f22c2e13e0ce48e86cae2d960aaf1abf721b497f32025916",
|
||||
"zh:6f71257a6b1218d02a573fc9bff0657410404fb2ef23bc66ae8cd968f98d5ff6",
|
||||
"zh:78d5eefdd9e494defcb3c68d282b8f96630502cac21d1ea161f53cfe9bb483b3",
|
||||
"zh:9647e18f221380a85f2f0ab387c68fdafd58af6193a932417299cdcae4710150",
|
||||
"zh:bb6297ce412c3c2fa9fec726114e5e0508dd2638cad6a0cb433194930c97a544",
|
||||
"zh:f83e925ed73ff8a5ef6e3608ad9225baa5376446349572c2449c0c0b3cf184b7",
|
||||
"zh:fbef0781cb64de76b1df1ca11078aecba7800d82fd4a956302734999cfd9a4af",
|
||||
]
|
||||
}
|
79
terraform/main.tf
Normal file
79
terraform/main.tf
Normal file
@ -0,0 +1,79 @@
|
||||
terraform {
|
||||
backend "gcs" {
|
||||
bucket = "tf-state-4b00"
|
||||
prefix = "terraform/api_gateway_test"
|
||||
}
|
||||
|
||||
required_providers {
|
||||
google = {
|
||||
source = "hashicorp/google"
|
||||
version = "5.36.0"
|
||||
}
|
||||
google-beta = {
|
||||
source = "hashicorp/google-beta"
|
||||
version = "5.36.0"
|
||||
}
|
||||
random = {
|
||||
source = "hashicorp/random"
|
||||
version = "3.6.2"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
variable "provider_project" {
|
||||
description = "Project ID."
|
||||
type = string
|
||||
default = "terraform-management-427323"
|
||||
}
|
||||
|
||||
variable "region" {
|
||||
description = "Region."
|
||||
type = string
|
||||
default = "us-central1"
|
||||
}
|
||||
|
||||
variable "zone" {
|
||||
description = "Zone."
|
||||
type = string
|
||||
default = "us-central1-c"
|
||||
}
|
||||
|
||||
# manual step: enable cloudbilling.googleapis.com in the terraform provider project
|
||||
# https://console.developers.google.com/apis/api/cloudbilling.googleapis.com/overview?project=terraform-management-427323
|
||||
provider "google" {
|
||||
project = var.provider_project
|
||||
region = var.region
|
||||
zone = var.zone
|
||||
billing_project = var.provider_project
|
||||
user_project_override = true
|
||||
}
|
||||
|
||||
provider "google-beta" {
|
||||
project = var.provider_project
|
||||
region = var.region
|
||||
zone = var.zone
|
||||
billing_project = var.provider_project
|
||||
user_project_override = true
|
||||
}
|
||||
|
||||
resource "random_id" "project" {
|
||||
byte_length = 4
|
||||
}
|
||||
|
||||
data "google_billing_account" "acct" {
|
||||
display_name = "My Billing Account"
|
||||
open = true
|
||||
}
|
||||
|
||||
resource "google_project" "project" {
|
||||
name = "Api Gateway Test"
|
||||
project_id = "api-gateway-test-${random_id.project.hex}"
|
||||
billing_account = data.google_billing_account.acct.id
|
||||
}
|
||||
|
||||
resource "google_project_service" "service" {
|
||||
project = google_project.project.project_id
|
||||
for_each = toset(["discoveryengine", "dialogflow"])
|
||||
service = "${each.key}.googleapis.com"
|
||||
disable_dependent_services = true
|
||||
}
|
Loading…
Reference in New Issue
Block a user