-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Expand file tree
/
Copy pathmain.tf
More file actions
39 lines (39 loc) · 1.24 KB
/
main.tf
File metadata and controls
39 lines (39 loc) · 1.24 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
terraform {
required_providers {
google = {
source = "hashicorp/google"
}
}
}
resource "google_project_service" "compute" {
service = "compute.googleapis.com"
project = var.inputs.project_id
count = var.inputs.should_enable_apis_on_apply ? 1 : 0
disable_on_destroy = var.inputs.should_disable_apis_on_destroy
}
resource "google_project_service" "redis" {
service = "redis.googleapis.com"
project = var.inputs.project_id
count = var.inputs.should_enable_apis_on_apply ? 1 : 0
disable_on_destroy = var.inputs.should_disable_apis_on_destroy
}
locals {
redis_vpc_id = "redis-vpc"
}
resource "google_compute_network" "redis_vpc" {
count = var.inputs.should_create_redis_network ? 1 : 0
name = local.redis_vpc_id
depends_on = [
google_project_service.compute,
google_project_service.redis
]
}
resource "time_sleep" "for_2m_allowRedisVpcToFullyEnable" {
count = var.inputs.should_create_redis_network ? 1 : 0
depends_on = [google_compute_network.redis_vpc]
create_duration = "2m"
}
data "google_compute_network" "existing_network" {
count = var.inputs.should_create_redis_network ? 0 : 1
name = local.redis_vpc_id
}