-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.tf
60 lines (51 loc) · 1.08 KB
/
main.tf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
variable "region" { }
variable "project_name" { }
variable "billing_account" { }
variable "org_id" { }
variable "rng_seed" {
type = string
}
locals {
project_prefix = join("", [lower(replace(var.project_name, " ", "-")), "-"])
}
provider "google" {
region = var.region
}
data "google_billing_account" "my_billing_account" {
billing_account = var.billing_account
}
resource "random_id" "id" {
byte_length = 4
keepers = {
random_seed = "${var.rng_seed}"
}
prefix = local.project_prefix
}
resource "google_project" "project" {
name = var.project_name
project_id = random_id.id.hex
billing_account = data.google_billing_account.my_billing_account.id
org_id = var.org_id
}
output "name" {
value = google_project.project.name
}
output "id" {
value = google_project.project.id
}
output "number" {
value = google_project.project.number
}
terraform {
required_version = ">= 1.0"
required_providers {
google = {
source = "hashicorp/google"
version = ">= 3.75"
}
random = {
source = "hashicorp/random"
version = ">= 3.1"
}
}
}