-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmain.tf
77 lines (64 loc) · 1.77 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
// Configure the Google Cloud provider
provider "google" {
credentials = "${file("credenciales.json")}"
project = "x-pivot-241800"
region = "us-west1"
}
// Terraform plugin for creating random ids
resource "random_id" "instance_id" {
byte_length = 8
}
// A single Google Cloud Engine instance
resource "google_compute_instance" "default" {
name = "flask-vm-${random_id.instance_id.hex}"
machine_type = "n1-standard-8"
zone = "us-west1-a"
boot_disk {
initialize_params {
image = "ubuntu-os-cloud/ubuntu-1804-lts"
}
}
// Make sure flask is installed on all new instances for later steps
metadata_startup_script = "sudo apt-get update; sudo apt-get install -yq build-essential python-pip rsync; pip install flask"
network_interface {
network = "default"
access_config {
// Include this section to give the VM an external ip address
}
}
metadata {
sshKeys = "matias:${file("~/.ssh/id_rsa.pub")}"
}
}
resource "google_compute_firewall" "default" {
name = "flask-app-firewall"
network = "default"
allow {
protocol = "tcp"
ports = ["5000"]
}
}
// A variable for extracting the external ip of the instance
output "ip" {
value = "${google_compute_instance.default.network_interface.0.access_config.0.nat_ip}"
}
resource "google_bigquery_dataset" "default" {
dataset_id = "Dataset_1"
friendly_name = "test"
description = "Dataset de prueba"
location = "EU"
labels = {
env = "default"
}
}
resource "google_bigquery_table" "default" {
dataset_id = "${google_bigquery_dataset.default.dataset_id}"
table_id = "Personas"
time_partitioning {
type = "DAY"
}
labels = {
env = "default"
}
schema = "${file("schema.json")}"
}