-
Notifications
You must be signed in to change notification settings - Fork 16
Expand file tree
/
Copy pathmain.tf
More file actions
95 lines (87 loc) · 2.69 KB
/
main.tf
File metadata and controls
95 lines (87 loc) · 2.69 KB
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
/**
* Copyright 2023 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
terraform {
required_providers {
google = {
source = "hashicorp/google"
version = "7.29.0"
}
google-beta = {
source = "hashicorp/google-beta"
version = "6.50.0"
}
}
}
provider "google" {
user_project_override = true
billing_project = var.project_id
}
provider "google-beta" {
region = "us-central1"
zone = "us-central1-a"
user_project_override = true
billing_project = var.project_id
}
# Enable gcloud project APIs
locals {
standard_labels = {
e2e_test_resource = "true"
landscape = var.environment_name
}
}
##
# This is how you do an output file containing terraform data for use by
# a subsequent script.
# First, create the output data structure as a local variable
locals {
output_json = {
public = {
postgres = {
instance = google_sql_database_instance.instance.connection_name
dbName = google_sql_database.db.name
rootUser = "postgres"
rootPassword = random_id.db_password.hex
}
mysql = {
instance = google_sql_database_instance.mysql.connection_name
dbName = google_sql_database.db.name
rootUser = google_sql_user.mysql_user.name
rootPassword = google_sql_user.mysql_user.password
}
mssql = {
instance = google_sql_database_instance.mssql.connection_name
dbName = google_sql_database.db.name
rootUser = google_sql_user.mssql_user.name
rootPassword = google_sql_user.mssql_user.password
}
kubeconfig = var.kubeconfig_path
}
private = {
postgres = {
instance = google_sql_database_instance.private_postgres.connection_name
dbName = google_sql_database.private_db.name
rootUser = "postgres"
rootPassword = random_id.db_password.hex
}
kubeconfig = var.private_kubeconfig_path
}
}
}
# Then write the output data to a local file in json format
resource "local_file" "testinfra" {
content = jsonencode(local.output_json)
filename = var.output_json_path
}