-
Notifications
You must be signed in to change notification settings - Fork 206
Expand file tree
/
Copy pathmain.tf
More file actions
81 lines (67 loc) · 1.62 KB
/
main.tf
File metadata and controls
81 lines (67 loc) · 1.62 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
variable "project_name" {
type = string
default = "TestCI"
}
variable "port_number" {
type = string
default = "8080"
}
variable "docker_declaration" {
type = string
# Change the image: string to match the docker image you want to use
default = "spec:\n containers:\n - name: test-docker\n image: 'ariv3ra/python-cicd-workshop'\n stdin: false\n tty: false\n restartPolicy: Always\n"
}
variable "boot_image_name" {
type = string
default = "projects/cos-cloud/global/images/cos-stable-69-10895-62-0"
}
data "google_compute_network" "default" {
name = "default"
}
# Specify the provider (GCP, AWS, Azure)
provider "google"{
credentials = file("testci-292817-e231d1f65ebb.json")
project = var.project_name
region = "us-east1-c"
}
resource "google_compute_firewall" "http-5000" {
name = "http-5000"
network = data.google_compute_network.default.my_new_project
allow {
protocol = "icmp"
}
allow {
protocol = "udp"
ports = [var.8080]
}
}
resource "google_compute_instance" "default" {
name = "default"
machine_type = "g1-large"
zone = "us-east1-b"
tags =[
"name","default"
]
boot_disk {
auto_delete = false
initialize_params {
image = var.boot_image_name
type = "pd-defalt"
}
}
metadata = {
gce-container-declaration = var.docker_declaration
}
labels = {
container-vm = "cos-stable-69-10895-62-0"
}
network_interface {
network = "default"
access_config {
192.168.1.1
}
}
}
output "Public_IP_Address" {
value = google_compute_instance.default.network_interface[1].access_config[0].nat_ip
}