-
Notifications
You must be signed in to change notification settings - Fork 19
/
compartments.tf
94 lines (84 loc) · 4.06 KB
/
compartments.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
locals {
compartments_map = {
( var.parent_compartment_name ) = module.parent-compartment.parent_compartment_id
( var.common_infra_compartment_name ) = module.common-infra-compartment.common_infra_compartment_id
( var.applications_compartment_name ) = module.applications-compartment.applications_compartment_id
( var.network_compartment_name ) = module.network-compartment.network_compartment_id
( var.security_compartment_name ) = module.security-compartment.security_compartment_id
}
}
# -----------------------------------------------------------------------------
# Create Parent compartment, for top level organization
# -----------------------------------------------------------------------------
module "parent-compartment" {
source = "./compartments/parent_compartment"
compartment_delete_enabled = var.is_sandbox_mode_enabled
tenancy_ocid = var.tenancy_ocid
compartment_name = var.parent_compartment_name
tag_geo_location = var.tag_geo_location
tag_cost_center = var.tag_cost_center
suffix = var.is_sandbox_mode_enabled == true ? "-${random_id.suffix.hex}" : ""
providers = {
oci = oci.home_region
}
}
# -----------------------------------------------------------------------------
# Create compartment for common infrastructure compartments
# -----------------------------------------------------------------------------
module "common-infra-compartment" {
source = "./compartments/common_infra_compartment"
compartment_delete_enabled = var.is_sandbox_mode_enabled
parent_compartment_ocid = module.parent-compartment.parent_compartment_id
compartment_name = var.common_infra_compartment_name
tag_geo_location = var.tag_geo_location
tag_cost_center = var.tag_cost_center
providers = {
oci = oci.home_region
}
depends_on = [module.parent-compartment]
}
# -----------------------------------------------------------------------------
# Create compartment for application compartments
# -----------------------------------------------------------------------------
module "applications-compartment" {
source = "./compartments/applications_compartment"
compartment_delete_enabled = var.is_sandbox_mode_enabled
parent_compartment_ocid = module.parent-compartment.parent_compartment_id
compartment_name = var.applications_compartment_name
tag_geo_location = var.tag_geo_location
tag_cost_center = var.tag_cost_center
providers = {
oci = oci.home_region
}
depends_on = [module.parent-compartment]
}
# -----------------------------------------------------------------------------
# Create compartment for network components
# -----------------------------------------------------------------------------
module "network-compartment" {
source = "./compartments/network_compartment"
compartment_delete_enabled = var.is_sandbox_mode_enabled
common_infra_compartment_ocid = module.common-infra-compartment.common_infra_compartment_id
compartment_name = var.network_compartment_name
tag_geo_location = var.tag_geo_location
tag_cost_center = var.tag_cost_center
providers = {
oci = oci.home_region
}
depends_on = [module.common-infra-compartment]
}
# -----------------------------------------------------------------------------
# Create compartment for security components
# -----------------------------------------------------------------------------
module "security-compartment" {
source = "./compartments/security_compartment"
compartment_delete_enabled = var.is_sandbox_mode_enabled
common_infra_compartment_ocid = module.common-infra-compartment.common_infra_compartment_id
compartment_name = var.security_compartment_name
tag_geo_location = var.tag_geo_location
tag_cost_center = var.tag_cost_center
providers = {
oci = oci.home_region
}
depends_on = [module.common-infra-compartment]
}