Skip to content

Commit

Permalink
Merge pull request #1 from oracle-devrel/develop
Browse files Browse the repository at this point in the history
v2024.3.0 TF modules
  • Loading branch information
unamachi authored Jun 12, 2024
2 parents fc1b590 + 4e69a51 commit 684c958
Show file tree
Hide file tree
Showing 491 changed files with 58,069 additions and 0 deletions.
233 changes: 233 additions & 0 deletions examples/README.md

Large diffs are not rendered by default.

21 changes: 21 additions & 0 deletions examples/budget/backend.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/*This line will be removed when using remote state
# !!! WARNING !!! Terraform State Lock is not supported with OCI Object Storage.
# Pre-Requisite: Create a version enabled object storage bucket to store the state file.
# End Point Format: https://<namespace>.compat.objectstorage.<region>.oraclecloud.com
# Please look at the below doc for information about shared_credentials_file and other parameters:
# Reference: https://docs.oracle.com/en-us/iaas/Content/API/SDKDocs/terraformUsingObjectStore.htm
terraform {
backend "s3" {
key = "<folder/filename.tfstate>"
bucket = "<Object Storage Bucket Name>"
region = "<region>"
endpoint = "<Object Storage Bucket End Point>"
shared_credentials_file = "~/.aws/credentials"
skip_region_validation = true
skip_credentials_validation = true
skip_metadata_api_check = true
force_path_style = true
}
}
This line will be removed when using remote state*/
62 changes: 62 additions & 0 deletions examples/budget/budget.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
// Copyright (c) 2024, Oracle and/or its affiliates.

############################
# Module Block - Cost Management
# Create Budgets and Rule Alerts
############################

#locals {
# comp_ocids = {for key, val in var.budgets : key => [
# var.compartment_ocids[flatten([for targets in val.targets : targets])[0]]
# ] if val.target_type == "COMPARTMENT" }
#}



module "budget-alert-rules" {
source = "./modules/costmanagement/budget-alert-rule"
for_each = var.budget_alert_rules

#Required
budget_id = length(regexall("ocid1.budget.oc*", each.value.budget_id)) > 0 ? each.value.budget_id : merge(module.budgets.*...)[each.value.budget_id]["budget_tf_id"]
threshold = each.value.threshold
threshold_type = each.value.threshold_type
type = each.value.type

#Optional
description = each.value.description
display_name = each.value.display_name
defined_tags = each.value.defined_tags
freeform_tags = each.value.freeform_tags
message = each.value.message
recipients = each.value.recipients
}

module "budgets" {
source = "./modules/costmanagement/budget"
for_each = var.budgets

#Required
amount = each.value.amount
compartment_id = each.value.compartment_id != null ? (length(regexall("ocid1.compartment.oc*", each.value.compartment_id)) > 0 ? each.value.compartment_id : var.compartment_ocids[each.value.compartment_id]):var.tenancy_ocid

reset_period = each.value.reset_period != null ? each.value.reset_period : "MONTHLY"

#Optional
budget_processing_period_start_offset = each.value.budget_processing_period_start_offset
description = each.value.description
display_name = each.value.display_name
defined_tags = each.value.defined_tags
freeform_tags = each.value.freeform_tags
processing_period_type = each.value.processing_period_type
budget_start_date = each.value.processing_period_type == "SINGLE_USE" ? each.value.budget_start_date : null
budget_end_date = each.value.processing_period_type == "SINGLE_USE" ? each.value.budget_end_date : null

#target_compartment_id = each.value.target_compartment_id != null ? (length(regexall("ocid1.compartment.oc*", each.value.target_compartment_id)) > 0 ? each.value.target_compartment_id : var.compartment_ocids[each.value.target_compartment_id]) : null

target_type = each.value.target_type
#targets = each.value.targets

targets = each.value.target_type == "COMPARTMENT" ? (length(regexall("ocid1.compartment.oc*", each.value.targets[0])) > 0 ? each.value.targets : [var.compartment_ocids[each.value.targets[0]]]) : each.value.targets

}
42 changes: 42 additions & 0 deletions examples/budget/oci-data.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
// Copyright (c) 2021, 2022, Oracle and/or its affiliates.

############################
# Resource Block - Identity
# Fetch Compartments
############################

#Fetch Compartment Details
data "oci_identity_compartments" "compartments" {
#Required
compartment_id = var.tenancy_ocid

#Optional
#name = var.compartment_name
access_level = "ANY"
compartment_id_in_subtree = true
state = "ACTIVE"
}


############################
# Data Block - Network
# Fetch ADs
############################

data "oci_identity_availability_domains" "availability_domains" {
#Required
compartment_id = var.tenancy_ocid
}


/*
output "compartment_id_map" {
description = "Compartment ocid"
// This allows the compartment ID to be retrieved from the resource if it exists, and if not to use the data source.
value = zipmap(data.oci_identity_compartments.compartments.compartments.*.name,data.oci_identity_compartments.compartments.compartments.*.id)
}
output "ads" {
value = data.oci_identity_availability_domains.availability_domains.availability_domains.*.name
}
*/
24 changes: 24 additions & 0 deletions examples/budget/provider.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
// Copyright (c) 2021, 2022, Oracle and/or its affiliates.

############################
# Provider Block
# OCI
############################

provider "oci" {
tenancy_ocid = var.tenancy_ocid
user_ocid = var.user_ocid
fingerprint = var.fingerprint
private_key_path = var.private_key_path
region = var.region
ignore_defined_tags = ["Oracle-Tags.CreatedBy", "Oracle-Tags.CreatedOn"]
}

terraform {
required_providers {
oci = {
source = "oracle/oci"
version = "5.40.0"
}
}
}
Loading

0 comments on commit 684c958

Please sign in to comment.