forked from site24x7/terraform-provider-site24x7
-
Notifications
You must be signed in to change notification settings - Fork 0
/
server_agent_installation_GCP.tf
149 lines (122 loc) · 4.5 KB
/
server_agent_installation_GCP.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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
terraform {
required_providers {
site24x7 = {
source = "site24x7/site24x7"
# Update the latest version from https://registry.terraform.io/providers/site24x7/site24x7/latest
}
}
}
// Defining the Google provider and adding the prokject and region details
// Make sure the terminal autnticated with GCP CLI
provider "google" {
project = "Project ID"
region = "us-central1"
}
// Authentication API doc - https://www.site24x7.com/help/api/#authentication
provider "site24x7" {
// (Required) The client ID will be looked up in the SITE24X7_OAUTH2_CLIENT_ID
// environment variable if the attribute is empty or omitted.
oauth2_client_id = "<SITE24X7_OAUTH2_CLIENT_ID>"
// (Required) The client secret will be looked up in the SITE24X7_OAUTH2_CLIENT_SECRET
// environment variable if the attribute is empty or omitted.
oauth2_client_secret = "<SITE24X7_OAUTH2_CLIENT_SECRET>"
// (Required) The refresh token will be looked up in the SITE24X7_OAUTH2_REFRESH_TOKEN
// environment variable if the attribute is empty or omitted.
oauth2_refresh_token = "<SITE24X7_OAUTH2_REFRESH_TOKEN>"
// (Required) Specify the data center from which you have obtained your
// OAuth client credentials and refresh token. It can be (US/EU/IN/AU/CN/JP/CA).
data_center = "US"
// (Optional) ZAAID of the customer under a MSP or BU
zaaid = "1234"
// (Optional) The minimum time to wait in seconds before retrying failed Site24x7 API requests.
retry_min_wait = 1
// (Optional) The maximum time to wait in seconds before retrying failed Site24x7 API
// requests. This is the upper limit for the wait duration with exponential
// backoff.
retry_max_wait = 30
// (Optional) Maximum number of Site24x7 API request retries to perform until giving up.
max_retries = 4
}
data "site24x7_device_key" "s247devicekey" {}
// Displays the device key
output "s247_device_key" {
description = "Device Key : "
value = data.site24x7_device_key.s247devicekey.id
}
// resource Google compute network
resource "google_compute_network" "vpc_network" {
name = "my-network"
auto_create_subnetworks = false
mtu = 1460
}
resource "google_compute_subnetwork" "default" {
name = "my-subnet"
ip_cidr_range = "10.0.1.0/24"
region = "us-central1"
network = google_compute_network.vpc_network.id
}
# [END compute__quickstart_vpc]
# [START compute__quickstart_vm]
# Create a single Compute Engine instance
resource "google_compute_instance" "default" {
name = "terraform-vm"
machine_type = "n1-standard-1"
zone = "us-central1-a"
tags = ["ssh"]
boot_disk {
initialize_params {
image = "debian-cloud/debian-11"
}
}
# Install
metadata_startup_script = "sudo apt-get update; sudo apt-get install -yq build-essential python3-pip rsync; wget https://staticdownloads.site24x7.com/server/Site24x7InstallScript.sh; bash Site24x7InstallScript.sh -i -key=${data.site24x7_device_key.s247devicekey.id} -automation=true; wget https://raw.githubusercontent.com/site24x7/plugins/master/check_updates/installer/Site24x7CheckUpdatesPluginInstaller.sh && sudo bash Site24x7CheckUpdatesPluginInstaller.sh"
network_interface {
subnetwork = google_compute_subnetwork.default.id
access_config {
# Include this section to give the VM an external IP address
}
}
}
# [END compute__quickstart_vm]
# [START vpc__quickstart_ssh_fw]
resource "google_compute_firewall" "ssh" {
name = "allowssh"
allow {
ports = ["22"]
protocol = "tcp"
}
direction = "INGRESS"
network = google_compute_network.vpc_network.id
priority = 1000
source_ranges = ["0.0.0.0/0"]
target_tags = ["ssh"]
}
# [END vpc__quickstart_ssh_fw]
# [START vpc__quickstart_5000_fw]
resource "google_compute_firewall" "firewall" {
name = "my-firewall"
network = google_compute_network.vpc_network.id
allow {
protocol = "tcp"
ports = ["5000"]
}
source_ranges = ["0.0.0.0/0"]
}
# [END vpc__quickstart_5000_fw]
# Create new multi-region storage bucket in the US
# with versioning enabled
# [START storage_bucket_tf_with_versioning]
resource "random_id" "bucket_prefix" {
byte_length = 8
}
resource "google_storage_bucket" "default" {
name = "${random_id.bucket_prefix.hex}-bucket-tfstate"
force_destroy = false
location = "US"
storage_class = "STANDARD"
versioning {
enabled = true
}
}
# [END storage_bucket_tf_with_versioning]
# [END storage__google_cloud_quickstart_parent_tag]