File tree 9 files changed +169
-5
lines changed
9 files changed +169
-5
lines changed Original file line number Diff line number Diff line change @@ -35,3 +35,19 @@ module "backend_elastic_search" {
35
35
36
36
37
37
}
38
+
39
+ module "backend_pos_vm" {
40
+ module_wide_prefix_scope = " ${ var . config_release_name } -vm"
41
+ source = " ./modules/posvm"
42
+
43
+ depends_on = [module . backend_elastic_search ]
44
+
45
+ // Region and zone
46
+ vm_default_zone = var. config_gcp_default_zone
47
+ vm_pos_boot_image = var. config_vm_pos_boot_image
48
+ vm_pos_boot_disk_size = var. config_vm_pos_boot_disk_size
49
+ vm_pos_machine_type = var. config_vm_pos_machine_type
50
+ gs_etl = var. config_gs_etl
51
+ vm_elasticsearch_uri = module. backend_elastic_search . elasticsearch_vm_name
52
+
53
+ }
Original file line number Diff line number Diff line change @@ -17,7 +17,7 @@ resource "google_service_account" "gcp_service_acc_apis" {
17
17
18
18
19
19
resource "google_compute_instance" "elasticsearch_etl" {
20
- name = " ${ var . module_wide_prefix_scope } -elastic-search-template -${ random_string . random . result } "
20
+ name = " ${ var . module_wide_prefix_scope } -elastic-search-server -${ random_string . random . result } "
21
21
machine_type = " custom-${ var . vm_elastic_search_vcpus } -${ var . vm_elastic_search_mem } "
22
22
zone = var. vm_default_zone
23
23
allow_stopping_for_update = true
@@ -31,16 +31,13 @@ name = "${var.module_wide_prefix_scope}-elastic-search-template-${random_string.
31
31
}
32
32
}
33
33
34
-
35
34
network_interface {
36
35
network = " default"
37
36
access_config {
38
37
network_tier = " PREMIUM"
39
38
}
40
39
}
41
40
42
-
43
-
44
41
metadata = {
45
42
startup-script = templatefile (
46
43
" ${ path . module } /scripts/elasticsearch_startup.sh" ,
Original file line number Diff line number Diff line change 1
-
1
+ output "elasticsearch_vm_name" {
2
+ value = google_compute_instance. elasticsearch_etl . name
3
+ }
Original file line number Diff line number Diff line change
1
+ resource "random_string" "random" {
2
+ length = 8
3
+ lower = true
4
+ upper = false
5
+ special = false
6
+ keepers = {
7
+ vm_pos_boot_disk_size = var.vm_pos_boot_disk_size
8
+ }
9
+ }
10
+
11
+
12
+ resource "google_service_account" "gcp_service_acc_apis" {
13
+ account_id = " ${ var . module_wide_prefix_scope } -svc-${ random_string . random . result } "
14
+ display_name = " ${ var . module_wide_prefix_scope } -GCP-service-account"
15
+ }
16
+
17
+
18
+
19
+ resource "google_compute_instance" "pos_vm" {
20
+ name = " ${ var . module_wide_prefix_scope } -support-vm-${ random_string . random . result } "
21
+ machine_type = var. vm_pos_machine_type
22
+ zone = var. vm_default_zone
23
+ allow_stopping_for_update = true
24
+ can_ip_forward = true
25
+
26
+ boot_disk {
27
+ initialize_params {
28
+ image = " ${ var . vm_pos_boot_image } "
29
+ type = " pd-ssd"
30
+ size = " ${ var . vm_pos_boot_disk_size } "
31
+ }
32
+ }
33
+
34
+
35
+ network_interface {
36
+ network = " default"
37
+ access_config {
38
+ network_tier = " PREMIUM"
39
+ }
40
+ }
41
+
42
+ metadata = {
43
+ startup-script = templatefile (
44
+ " ${ path . module } /scripts/load_data.sh" ,
45
+ {
46
+ ELASTICSEARCH_URI = " ${ var . vm_elasticsearch_uri } "
47
+ }
48
+ )
49
+ google-logging-enabled = true
50
+ }
51
+
52
+ service_account {
53
+ email = google_service_account. gcp_service_acc_apis . email
54
+ scopes = [ " cloud-platform" ]
55
+ }
56
+ }
Original file line number Diff line number Diff line change
1
+ output "pos_support_vm_name" {
2
+ value = google_compute_instance. pos_vm . name
3
+ }
Original file line number Diff line number Diff line change
1
+ #! /bin/bash
2
+ # Startup script for Elastic Search VM Instance
3
+
4
+ echo " ---> [LAUNCH] POS support VM"
5
+
6
+ sudo apt update && sudo apt -y install python3-pip
7
+ sudo pip3 install elasticsearch-loader
8
+
9
+
10
+ echo " test cinzia"
11
+ echo $ELASTICSEARCH_URI
12
+
13
+ echo $$ ELASTICSEARCH_URI
14
+ echo $strin
Original file line number Diff line number Diff line change
1
+ // --- Module input parameters --- //
2
+ // General deployment input parameters --- //
3
+ variable "module_wide_prefix_scope" {
4
+ description = " The prefix provided here will scope names for those resources created by this module, default 'otpdeves'"
5
+ type = string
6
+ default = " otdevpos"
7
+ }
8
+
9
+ // --- ETL info --- //
10
+ variable "gs_etl" {
11
+ description = " Output of the ETL [root]. Eg. open-targets-data-releases/21.04/output"
12
+ type = string
13
+ }
14
+
15
+ // --- VM info --- //
16
+ variable "vm_pos_boot_image" {
17
+ description = " Boot image configuration for POS VM"
18
+ type = string
19
+ default = " debian-10"
20
+ }
21
+
22
+ variable "vm_default_zone" {
23
+ description = " Default zone when not specified in the module"
24
+ type = string
25
+ }
26
+
27
+ variable "vm_pos_boot_disk_size" {
28
+ description = " POS VM boot disk size, default '500GB'"
29
+ type = string
30
+ default = 500
31
+ }
32
+
33
+ variable "vm_pos_machine_type" {
34
+ description = " Machine type for POS vm"
35
+ type = string
36
+ }
37
+
38
+ variable "vm_elasticsearch_uri" {
39
+ description = " Elasticsearch Server"
40
+ type = string
41
+ }
Original file line number Diff line number Diff line change
1
+ output "elasticsearch_vm_name" {
2
+ value = module. backend_elastic_search . elasticsearch_vm_name
3
+ }
4
+
5
+ output "pos_support_vm_name" {
6
+ value = module. backend_pos_vm . pos_support_vm_name
7
+ }
Original file line number Diff line number Diff line change @@ -19,6 +19,12 @@ variable "config_project_id" {
19
19
type = string
20
20
}
21
21
22
+ // --- ETL info --- //
23
+ variable "config_gs_etl" {
24
+ description = " Output of the ETL [root]. Eg. open-targets-data-releases/21.04/output"
25
+ type = string
26
+ }
27
+
22
28
// --- Elastic Search Configuration --- //
23
29
24
30
variable "config_vm_elastic_boot_image" {
@@ -47,3 +53,25 @@ variable "config_vm_elastic_search_boot_disk_size" {
47
53
description = " Boot disk size to use for the deployed Elastic Search Instances"
48
54
type = string
49
55
}
56
+
57
+
58
+ // --- POS VM Configuration --- //
59
+
60
+ variable "config_vm_pos_boot_image" {
61
+ description = " Boot image configuration for POS VM"
62
+ type = string
63
+ default = " debian-10"
64
+ }
65
+
66
+
67
+ variable "config_vm_pos_boot_disk_size" {
68
+ description = " POS VM boot disk size, default '500GB'"
69
+ type = string
70
+ default = 500
71
+ }
72
+
73
+ variable "config_vm_pos_machine_type" {
74
+ description = " Machine type for POS vm"
75
+ type = string
76
+ default = " projects/cos-cloud/global/images/family/debian-cloud"
77
+ }
You can’t perform that action at this time.
0 commit comments