-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.tf
More file actions
43 lines (39 loc) · 1.08 KB
/
main.tf
File metadata and controls
43 lines (39 loc) · 1.08 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
// Configure the Google Cloud provider
provider "google" {
credentials = "${file("${var.credentials}")}"
project = "${var.gcp_project}"
region = "${var.region}"
}
// Create VPC
resource "google_compute_network" "vpc" {
name = "${var.name}-vpc"
auto_create_subnetworks = "false"
}
// Create Subnet
resource "google_compute_subnetwork" "subnet" {
name = "${var.name}-subnet"
ip_cidr_range = "${var.subnet_cidr}"
network = "${var.name}-vpc"
depends_on = ["google_compute_network.vpc"]
region = "${var.region}"
}
// VPC firewall configuration
resource "google_compute_firewall" "firewall" {
name = "${var.name}-firewall"
network = "${google_compute_network.vpc.name}"
allow {
protocol = "icmp"
}
allow {
protocol = "tcp"
ports = ["22"]
}
source_ranges = ["0.0.0.0/0"]
}
//create cluster
resource "google_container_cluster" "gke-cluster" {
name = "my-first-gke-cluster"
network = "${google_compute_network.vpc.id}"
zone = "asia-east1-b"
initial_node_count = 3
}