Skip to content

Commit 03337f8

Browse files
committed
[patch] Add GCP-only provider entrypoint
1 parent 50edbbc commit 03337f8

3 files changed

Lines changed: 567 additions & 0 deletions

File tree

providers/gcp/main.tf

Lines changed: 200 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,200 @@
1+
terraform {
2+
required_version = ">= 1.2.4"
3+
}
4+
5+
locals {
6+
template_name = lower(trimspace(var.template))
7+
8+
app_templates = {
9+
archivesspace = {
10+
repo = "https://github.com/libops/archivesspace.git"
11+
branch = "main"
12+
plugin = "archivesspace"
13+
packages = ["sitectl", "sitectl-archivesspace"]
14+
}
15+
ojs = {
16+
repo = "https://github.com/libops/ojs.git"
17+
branch = "main"
18+
plugin = "ojs"
19+
packages = ["sitectl", "sitectl-ojs"]
20+
}
21+
isle = {
22+
repo = "https://github.com/libops/isle"
23+
branch = "main"
24+
plugin = "isle"
25+
packages = ["sitectl", "sitectl-drupal", "sitectl-isle"]
26+
}
27+
drupal = {
28+
repo = "https://github.com/libops/drupal.git"
29+
branch = "main"
30+
plugin = "drupal"
31+
packages = ["sitectl", "sitectl-drupal"]
32+
}
33+
wp = {
34+
repo = "https://github.com/libops/wp.git"
35+
branch = "main"
36+
plugin = "wp"
37+
packages = ["sitectl", "sitectl-wp"]
38+
}
39+
"omeka-s" = {
40+
repo = "https://github.com/libops/omeka-s.git"
41+
branch = "main"
42+
plugin = "omeka-s"
43+
packages = ["sitectl", "sitectl-omeka-s"]
44+
}
45+
"omeka-classic" = {
46+
repo = "https://github.com/libops/omeka-classic.git"
47+
branch = "main"
48+
plugin = "omeka-classic"
49+
packages = ["sitectl", "sitectl-omeka-classic"]
50+
}
51+
}
52+
empty_template = {
53+
repo = ""
54+
branch = "main"
55+
plugin = "core"
56+
packages = ["sitectl"]
57+
}
58+
template = local.template_name == "" ? local.empty_template : try(local.app_templates[local.template_name], local.empty_template)
59+
60+
input_compose = var.runtime.compose
61+
input_sitectl = var.runtime.sitectl
62+
63+
runtime = merge(var.runtime, {
64+
compose = merge(local.input_compose, {
65+
repo = (
66+
trimspace(local.input_compose.repo) != ""
67+
? local.input_compose.repo
68+
: local.template.repo
69+
)
70+
branch = (
71+
trimspace(local.input_compose.branch) != ""
72+
? local.input_compose.branch
73+
: local.template.branch
74+
)
75+
})
76+
sitectl = merge(local.input_sitectl, {
77+
packages = (
78+
local.template_name != "" && length(local.input_sitectl.packages) == 1 && local.input_sitectl.packages[0] == "sitectl"
79+
? local.template.packages
80+
: local.input_sitectl.packages
81+
)
82+
plugin = (
83+
local.template_name != "" && local.input_sitectl.plugin == "core"
84+
? local.template.plugin
85+
: local.input_sitectl.plugin
86+
)
87+
})
88+
})
89+
90+
compose = local.runtime.compose
91+
sitectl = local.runtime.sitectl
92+
docker = local.runtime.docker
93+
managed = local.runtime.managed_runtime
94+
vault = local.runtime.vault
95+
96+
gcp_instance = var.gcp.instance
97+
gcp_disks = var.gcp.disks
98+
gcp_identity = var.gcp.identity
99+
gcp_network = var.gcp.network
100+
gcp_snapshots = var.gcp.snapshots
101+
gcp_overlay = var.gcp.overlay
102+
gcp_artifact_registry = var.gcp.artifact_registry
103+
gcp_cloud_init = var.gcp.cloud_init
104+
gcp_power_management = var.gcp.power_management
105+
gcp_rollout = var.gcp.rollout
106+
}
107+
108+
module "gcp" {
109+
source = "../../modules/gcp"
110+
111+
name = var.name
112+
project_id = var.gcp.project_id
113+
project_number = var.gcp.project_number
114+
region = var.gcp.region
115+
zone = var.gcp.zone
116+
117+
service_account_email = local.gcp_identity.vm_service_account_email
118+
app_service_account_email = local.gcp_identity.app_service_account_email
119+
120+
machine_type = local.gcp_instance.machine_type
121+
os = local.gcp_instance.os
122+
production = local.gcp_instance.production
123+
124+
disk_type = local.gcp_disks.type
125+
disk_size_gb = local.gcp_disks.docker_volumes_size_gb
126+
127+
ingress_port = local.compose.ingress_port
128+
primary_compose_project = local.compose.primary
129+
sitectl_ingress = local.compose.ingress
130+
docker_compose_repo = local.compose.repo
131+
docker_compose_branch = local.compose.branch
132+
compose_projects = local.compose.projects
133+
docker_compose_init = local.compose.init
134+
docker_compose_up = local.compose.up
135+
docker_compose_down = local.compose.down
136+
docker_compose_rollout = local.compose.rollout
137+
138+
sitectl_packages = local.sitectl.packages
139+
sitectl_version = local.sitectl.version
140+
sitectl_context_name = local.sitectl.context_name
141+
sitectl_plugin = local.sitectl.plugin
142+
sitectl_environment = local.sitectl.environment
143+
sitectl_healthcheck_timeout = local.sitectl.healthcheck_timeout
144+
sitectl_healthcheck_interval = local.sitectl.healthcheck_interval
145+
sitectl_verify_args = local.sitectl.verify_args
146+
147+
docker_compose_version = local.docker.compose_version
148+
docker_buildx_version = local.docker.buildx_version
149+
150+
libops_managed_runtime_enabled = local.managed.enabled
151+
libops_internal_services_enabled = local.managed.internal_services_enabled
152+
libops_internal_services_auto_update = local.managed.internal_services_auto_update
153+
libops_lightsout_image = local.managed.lightsout_image
154+
libops_cap_image = local.managed.cap_image
155+
libops_cadvisor_image = local.managed.cadvisor_image
156+
libops_managed_artifacts = local.managed.artifacts
157+
158+
allowed_ips = local.gcp_network.power_button_allowed_ips
159+
allowed_ssh_ipv4 = local.gcp_network.ssh_ipv4
160+
allowed_ssh_ipv6 = local.gcp_network.ssh_ipv6
161+
162+
create_network = local.gcp_network.create
163+
network_name = local.gcp_network.name
164+
subnetwork_name = local.gcp_network.subnetwork
165+
network_ip_cidr_range = local.gcp_network.ip_cidr_range
166+
167+
run_snapshots = local.gcp_snapshots.enabled
168+
overlay_source_instance = local.gcp_overlay.source_instance
169+
volume_names = local.gcp_overlay.volume_names
170+
171+
users = local.runtime.users
172+
rootfs = local.runtime.rootfs
173+
runcmd = local.gcp_cloud_init.runcmd
174+
initcmd = local.gcp_cloud_init.initcmd
175+
176+
artifact_registry_repository = local.gcp_artifact_registry.repository
177+
artifact_registry_location = local.gcp_artifact_registry.location
178+
179+
power_management_enabled = local.gcp_power_management.enabled
180+
frontend = local.gcp_power_management.frontend
181+
182+
rollout_enabled = local.gcp_rollout.enabled
183+
rollout_release_url = local.gcp_rollout.release_url
184+
rollout_release_sha256 = local.gcp_rollout.release_sha256
185+
rollout_port = local.gcp_rollout.port
186+
rollout_jwks_uri = local.gcp_rollout.jwks_uri
187+
rollout_jwt_audience = local.gcp_rollout.jwt_audience
188+
rollout_custom_claims = local.gcp_rollout.custom_claims
189+
rollout_allowed_ipv4 = local.gcp_rollout.allowed_ipv4
190+
191+
vault_addr = local.vault.addr
192+
vault_namespace = local.vault.namespace
193+
vault_role = local.vault.role
194+
vault_agent_enabled = local.vault.agent_enabled
195+
vault_auth_method = local.vault.auth_method
196+
vault_gcp_auth_mount_path = local.vault.gcp_auth_mount_path
197+
vault_agent_token_path = local.vault.agent_token_path
198+
vault_agent_templates = local.vault.agent_templates
199+
vault_agent_additional_config = local.vault.agent_additional_config
200+
}

providers/gcp/outputs.tf

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
output "cloud_provider" {
2+
value = "gcp"
3+
description = "Selected cloud provider."
4+
}
5+
6+
output "template" {
7+
value = local.template_name
8+
description = "Selected compose template preset."
9+
}
10+
11+
output "instance" {
12+
value = module.gcp.instance
13+
description = "Selected provider VM instance details."
14+
}
15+
16+
output "instance_id" {
17+
value = module.gcp.instance_id
18+
description = "Selected provider VM instance ID."
19+
}
20+
21+
output "external_ip" {
22+
value = module.gcp.external_ip
23+
description = "Selected provider VM public IPv4 address."
24+
}
25+
26+
output "internal_ip" {
27+
value = module.gcp.internal_ip
28+
description = "Selected provider VM private IPv4 address."
29+
}
30+
31+
output "volumes" {
32+
value = null
33+
description = "Selected provider persistent volume details where available."
34+
}
35+
36+
output "serviceGsa" {
37+
value = module.gcp.serviceGsa
38+
description = "The Google Service Account internal services run as."
39+
}
40+
41+
output "appGsa" {
42+
value = module.gcp.appGsa
43+
description = "The Google Service Account the app can use for app-scoped auth."
44+
}
45+
46+
output "urls" {
47+
value = module.gcp.urls
48+
description = "Cloud Run ingress URLs by region."
49+
}
50+
51+
output "backend" {
52+
value = module.gcp.backend
53+
description = "Backend service ID for attaching Cloud Run ingress to an external HTTPS load balancer."
54+
}
55+
56+
output "rollout" {
57+
value = module.gcp.rollout
58+
description = "Optional rollout API endpoint details."
59+
}
60+
61+
output "compose_projects" {
62+
value = module.gcp.compose_projects
63+
description = "Normalized compose project manifest."
64+
}
65+
66+
output "primary_compose_project" {
67+
value = module.gcp.primary_compose_project
68+
description = "Normalized primary compose project."
69+
}

0 commit comments

Comments
 (0)