Skip to content

Commit

Permalink
Resolve some naming conflicts and recover tenancy ocid
Browse files Browse the repository at this point in the history
  • Loading branch information
yupeiyang-oci committed Aug 4, 2022
1 parent 44d5628 commit 1f3cd18
Show file tree
Hide file tree
Showing 7 changed files with 35 additions and 9 deletions.
5 changes: 5 additions & 0 deletions budget/variables.tf
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
# -----------------------------------------------------------------------------
# Required inputs
# -----------------------------------------------------------------------------
variable "tenancy_ocid" {
type = string
description = "the ocid of tenancy"
}

variable "budget_amount" {
description = "The amount of the budget expressed as a whole number in the currency of the customer's rate card."
default = null
Expand Down
10 changes: 5 additions & 5 deletions compartments.tf
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ locals {
# Create Parent compartment, for top level organization
# -----------------------------------------------------------------------------
module "parent-compartment" {
source = "./compartments/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
Expand All @@ -29,7 +29,7 @@ module "parent-compartment" {
# Create compartment for common infrastructure compartments
# -----------------------------------------------------------------------------
module "common-infra-compartment" {
source = "./compartments/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
Expand All @@ -46,7 +46,7 @@ module "common-infra-compartment" {
# Create compartment for application compartments
# -----------------------------------------------------------------------------
module "applications-compartment" {
source = "./compartments/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
Expand All @@ -63,7 +63,7 @@ module "applications-compartment" {
# Create compartment for network components
# -----------------------------------------------------------------------------
module "network-compartment" {
source = "./compartments/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
Expand All @@ -80,7 +80,7 @@ module "network-compartment" {
# Create compartment for security components
# -----------------------------------------------------------------------------
module "security-compartment" {
source = "./compartments/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
Expand Down
5 changes: 5 additions & 0 deletions compartments/parent_compartment/variables.tf
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
# -----------------------------------------------------------------------------
# Required inputs
# -----------------------------------------------------------------------------
variable "tenancy_ocid" {
type = string
description = "root-level / tenancy OCID"
}

variable "compartment_name" {
type = string
description = "Name of the compartment to create"
Expand Down
6 changes: 5 additions & 1 deletion iam/policies/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -172,10 +172,14 @@ resource "oci_identity_policy" "security_admins_policy_network" {
]
}

resource "random_id" "security" {
byte_length = 4
}

resource "oci_identity_policy" "security_admins_policy_root" {
compartment_id = var.tenancy_ocid
description = "OCI Landing Zone Security Admin Root Policy"
name = "${var.security_admins_policy_name}-Root"
name = "${var.security_admins_policy_name}-Root-${random_id.security.hex}"

freeform_tags = {
"Description" = "Root Policy for Security Admin Users",
Expand Down
6 changes: 5 additions & 1 deletion security/audit/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,14 @@ resource "time_offset" "bucket_creation_timestamp" {
offset_days = 15
}

resource "random_id" "bucket" {
byte_length = 4
}

resource "oci_objectstorage_bucket" "audit_log_bucket" {
compartment_id = var.security_compartment_ocid
namespace = data.oci_objectstorage_namespace.ns.namespace
name = "${var.audit_log_bucket_name}${var.suffix}"
name = "${var.audit_log_bucket_name}${var.suffix}${random_id.bucket.hex}"
access_type = "NoPublicAccess"
kms_key_id = var.key_id
storage_tier = "Archive"
Expand Down
6 changes: 5 additions & 1 deletion security/cloud-guard/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,15 @@ resource "oci_cloud_guard_cloud_guard_configuration" "tenancy_cloud_guard_config
# ---------------------------------------------------------------------------------------------------------------------
# Cloud Guard policies
# ---------------------------------------------------------------------------------------------------------------------
resource "random_id" "cloudguard" {
byte_length = 4
}

resource "oci_identity_policy" "cloud_guard_policy" {
provider = oci.home_region
compartment_id = var.tenancy_ocid
description = "OCI Landing Zone Cloud Guard Policy"
name = "${var.cloud_guard_policy_name}${var.suffix}"
name = "${var.cloud_guard_policy_name}${var.suffix}${random_id.cloudguard.hex}"

freeform_tags = {
"Description" = "Cloud guard policy"
Expand Down
6 changes: 5 additions & 1 deletion security/flow-logs/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,14 @@ resource "oci_logging_log_group" "central_log_group" {
}
}

resource "random_id" "log" {
byte_length = 4
}

resource "oci_log_analytics_log_analytics_log_group" "log_analytics_log_group" {
count = var.using_third_party_siem ? 0 : 1
compartment_id = var.security_compartment_ocid
display_name = "${var.log_analytics_log_group_display_name}${var.suffix}"
display_name = "${var.log_analytics_log_group_display_name}${var.suffix}${random_id.log.hex}"
namespace = data.oci_log_analytics_namespaces.logging_analytics_namespaces.namespace_collection[0].items[0].namespace

freeform_tags = {
Expand Down

0 comments on commit 1f3cd18

Please sign in to comment.