generated from memes/repo-template
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.tf
84 lines (76 loc) · 2.01 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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
# Example Terraform to create an F5 XC Cloud Credential for GCP VPC Sites, with
# a service account assigned to the custom F5 XC role at the project level.
# Only supported on Terraform 1.3+
terraform {
required_version = ">= 1.3"
required_providers {
google = {
source = "hashicorp/google"
version = ">= 4.58"
}
volterra = {
source = "volterraedge/volterra"
version = ">= 0.11"
}
f5xc = {
source = "memes/f5xc"
version = ">= 0.1"
}
}
}
resource "google_service_account" "sa" {
project = var.project_id
account_id = var.name
display_name = "F5 XC"
description = "Service account for F5 XC GCP VPC management"
}
resource "google_service_account_key" "sa" {
service_account_id = google_service_account.sa.id
key_algorithm = "KEY_ALG_RSA_2048"
private_key_type = "TYPE_GOOGLE_CREDENTIALS_FILE"
keepers = {
name = google_service_account.sa.name
}
}
module "role" {
source = "memes/f5-distributed-cloud-role/google"
version = "1.0.9"
target_id = var.project_id
random_id_prefix = replace(var.name, "/[^a-z0-9_.]/", "_")
}
resource "google_project_iam_member" "sa" {
project = var.project_id
role = module.role.qualified_role_id
member = google_service_account.sa.member
depends_on = [
google_service_account.sa,
module.role,
]
}
resource "f5xc_blindfold" "sa" {
plaintext = google_service_account_key.sa.private_key
policy_document = {
name = "ves-io-allow-volterra"
namespace = "shared"
}
depends_on = [
google_project_iam_member.sa,
google_service_account_key.sa,
]
}
resource "volterra_cloud_credentials" "xc" {
name = var.name
namespace = "system"
description = "Example Blindfold GCP Cloud Credential"
gcp_cred_file {
credential_file {
blindfold_secret_info {
location = format("string:///%s", f5xc_blindfold.sa.sealed)
}
}
}
depends_on = [
google_service_account.sa,
google_service_account_key.sa,
]
}