From 947cd85f388d11a96f409815c848e3cf652f971d Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 8 Jan 2025 09:50:06 +0100 Subject: [PATCH 1/7] Bump path-to-regexp and express (#195) Bumps [path-to-regexp](https://github.com/pillarjs/path-to-regexp) to 0.1.12 and updates ancestor dependency [express](https://github.com/expressjs/express). These dependencies need to be updated together. Updates `path-to-regexp` from 0.1.10 to 0.1.12 - [Release notes](https://github.com/pillarjs/path-to-regexp/releases) - [Changelog](https://github.com/pillarjs/path-to-regexp/blob/master/History.md) - [Commits](https://github.com/pillarjs/path-to-regexp/compare/v0.1.10...v0.1.12) Updates `express` from 4.21.1 to 4.21.2 - [Release notes](https://github.com/expressjs/express/releases) - [Changelog](https://github.com/expressjs/express/blob/4.21.2/History.md) - [Commits](https://github.com/expressjs/express/compare/4.21.1...4.21.2) --- updated-dependencies: - dependency-name: path-to-regexp dependency-type: indirect - dependency-name: express dependency-type: direct:production ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .../flightbooker-backend/package-lock.json | 34 +++++++++++-------- .../flightbooker-backend/package.json | 2 +- 2 files changed, 20 insertions(+), 16 deletions(-) diff --git a/03-Azure/01-01-App Innovation/03_ServerlessMicroservices/Flightbooker/flightbooker-backend/package-lock.json b/03-Azure/01-01-App Innovation/03_ServerlessMicroservices/Flightbooker/flightbooker-backend/package-lock.json index e8f944951..4389b8354 100644 --- a/03-Azure/01-01-App Innovation/03_ServerlessMicroservices/Flightbooker/flightbooker-backend/package-lock.json +++ b/03-Azure/01-01-App Innovation/03_ServerlessMicroservices/Flightbooker/flightbooker-backend/package-lock.json @@ -10,7 +10,7 @@ "license": "ISC", "dependencies": { "cors": "^2.8.5", - "express": "^4.21.1" + "express": "^4.21.2" }, "devDependencies": { "@babel/cli": "^7.23.4", @@ -2507,9 +2507,9 @@ } }, "node_modules/express": { - "version": "4.21.1", - "resolved": "https://registry.npmjs.org/express/-/express-4.21.1.tgz", - "integrity": "sha512-YSFlK1Ee0/GC8QaO91tHcDxJiE/X4FbpAyQWkxAvG6AXCuR65YzK8ua6D9hvi/TzUfZMpc+BwuM1IPw8fmQBiQ==", + "version": "4.21.2", + "resolved": "https://registry.npmjs.org/express/-/express-4.21.2.tgz", + "integrity": "sha512-28HqgMZAmih1Czt9ny7qr6ek2qddF4FclbMzwhCREB6OFfH+rXAnuNCwo1/wFvrtbgsQDb4kSbX9de9lFbrXnA==", "dependencies": { "accepts": "~1.3.8", "array-flatten": "1.1.1", @@ -2530,7 +2530,7 @@ "methods": "~1.1.2", "on-finished": "2.4.1", "parseurl": "~1.3.3", - "path-to-regexp": "0.1.10", + "path-to-regexp": "0.1.12", "proxy-addr": "~2.0.7", "qs": "6.13.0", "range-parser": "~1.2.1", @@ -2545,6 +2545,10 @@ }, "engines": { "node": ">= 0.10.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/express" } }, "node_modules/fill-range": { @@ -3248,9 +3252,9 @@ "dev": true }, "node_modules/path-to-regexp": { - "version": "0.1.10", - "resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-0.1.10.tgz", - "integrity": "sha512-7lf7qcQidTku0Gu3YDPc8DJ1q7OOucfa/BSsIwjuh56VU7katFvuM8hULfkwB3Fns/rsVF7PwPKVw1sl5KQS9w==" + "version": "0.1.12", + "resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-0.1.12.tgz", + "integrity": "sha512-RA1GjUVMnvYFxuqovrEqZoxxW5NUZqbwKtYz/Tt7nXerk0LbLblQmrsgdeOxV5SFHf0UDggjS/bSeOZwt1pmEQ==" }, "node_modules/picocolors": { "version": "1.0.0", @@ -5518,9 +5522,9 @@ "integrity": "sha512-aIL5Fx7mawVa300al2BnEE4iNvo1qETxLrPI/o05L7z6go7fCw1J6EQmbK4FmJ2AS7kgVF/KEZWufBfdClMcPg==" }, "express": { - "version": "4.21.1", - "resolved": "https://registry.npmjs.org/express/-/express-4.21.1.tgz", - "integrity": "sha512-YSFlK1Ee0/GC8QaO91tHcDxJiE/X4FbpAyQWkxAvG6AXCuR65YzK8ua6D9hvi/TzUfZMpc+BwuM1IPw8fmQBiQ==", + "version": "4.21.2", + "resolved": "https://registry.npmjs.org/express/-/express-4.21.2.tgz", + "integrity": "sha512-28HqgMZAmih1Czt9ny7qr6ek2qddF4FclbMzwhCREB6OFfH+rXAnuNCwo1/wFvrtbgsQDb4kSbX9de9lFbrXnA==", "requires": { "accepts": "~1.3.8", "array-flatten": "1.1.1", @@ -5541,7 +5545,7 @@ "methods": "~1.1.2", "on-finished": "2.4.1", "parseurl": "~1.3.3", - "path-to-regexp": "0.1.10", + "path-to-regexp": "0.1.12", "proxy-addr": "~2.0.7", "qs": "6.13.0", "range-parser": "~1.2.1", @@ -6047,9 +6051,9 @@ "dev": true }, "path-to-regexp": { - "version": "0.1.10", - "resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-0.1.10.tgz", - "integrity": "sha512-7lf7qcQidTku0Gu3YDPc8DJ1q7OOucfa/BSsIwjuh56VU7katFvuM8hULfkwB3Fns/rsVF7PwPKVw1sl5KQS9w==" + "version": "0.1.12", + "resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-0.1.12.tgz", + "integrity": "sha512-RA1GjUVMnvYFxuqovrEqZoxxW5NUZqbwKtYz/Tt7nXerk0LbLblQmrsgdeOxV5SFHf0UDggjS/bSeOZwt1pmEQ==" }, "picocolors": { "version": "1.0.0", diff --git a/03-Azure/01-01-App Innovation/03_ServerlessMicroservices/Flightbooker/flightbooker-backend/package.json b/03-Azure/01-01-App Innovation/03_ServerlessMicroservices/Flightbooker/flightbooker-backend/package.json index 8687c5bbb..33053fbc2 100644 --- a/03-Azure/01-01-App Innovation/03_ServerlessMicroservices/Flightbooker/flightbooker-backend/package.json +++ b/03-Azure/01-01-App Innovation/03_ServerlessMicroservices/Flightbooker/flightbooker-backend/package.json @@ -1,7 +1,7 @@ { "dependencies": { "cors": "^2.8.5", - "express": "^4.21.1" + "express": "^4.21.2" }, "name": "flightbooker-backend", "version": "1.0.0", From dc07320e8eca3dc5ce054a9867b36fcd1b37385a Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 8 Jan 2025 09:50:56 +0100 Subject: [PATCH 2/7] Bump nanoid (#196) Bumps [nanoid](https://github.com/ai/nanoid) from 3.3.7 to 3.3.8. - [Release notes](https://github.com/ai/nanoid/releases) - [Changelog](https://github.com/ai/nanoid/blob/main/CHANGELOG.md) - [Commits](https://github.com/ai/nanoid/compare/3.3.7...3.3.8) --- updated-dependencies: - dependency-name: nanoid dependency-type: indirect ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .../flightbooker-frontend/package-lock.json | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/03-Azure/01-01-App Innovation/03_ServerlessMicroservices/Flightbooker/flightbooker-frontend/package-lock.json b/03-Azure/01-01-App Innovation/03_ServerlessMicroservices/Flightbooker/flightbooker-frontend/package-lock.json index 652e9dfa7..6c5eda927 100644 --- a/03-Azure/01-01-App Innovation/03_ServerlessMicroservices/Flightbooker/flightbooker-frontend/package-lock.json +++ b/03-Azure/01-01-App Innovation/03_ServerlessMicroservices/Flightbooker/flightbooker-frontend/package-lock.json @@ -848,9 +848,9 @@ } }, "node_modules/nanoid": { - "version": "3.3.7", - "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.3.7.tgz", - "integrity": "sha512-eSRppjcPIatRIMC1U6UngP8XFcz8MQWGQdt1MTBQ7NaAmvXDfvNxbvWV3x2y6CdEUciCSsDHDQZbhYaB8QEo2g==", + "version": "3.3.8", + "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.3.8.tgz", + "integrity": "sha512-WNLf5Sd8oZxOm+TzppcYk8gVOgP+l58xNy58D0nbUnOxOWRWvlcCV4kUF7ltmI6PsrLl/BgKEyS4mqsGChFN0w==", "funding": [ { "type": "github", @@ -1497,9 +1497,9 @@ } }, "nanoid": { - "version": "3.3.7", - "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.3.7.tgz", - "integrity": "sha512-eSRppjcPIatRIMC1U6UngP8XFcz8MQWGQdt1MTBQ7NaAmvXDfvNxbvWV3x2y6CdEUciCSsDHDQZbhYaB8QEo2g==" + "version": "3.3.8", + "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.3.8.tgz", + "integrity": "sha512-WNLf5Sd8oZxOm+TzppcYk8gVOgP+l58xNy58D0nbUnOxOWRWvlcCV4kUF7ltmI6PsrLl/BgKEyS4mqsGChFN0w==" }, "picocolors": { "version": "1.1.0", From a8466826b0c321f7be892304681551e71adb2049 Mon Sep 17 00:00:00 2001 From: christian <8876980+cpinotossi@users.noreply.github.com> Date: Fri, 10 Jan 2025 15:40:01 +0100 Subject: [PATCH 3/7] Update featurerequest.yaml (#199) add oracle on azure microhack --- .github/ISSUE_TEMPLATE/featurerequest.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/ISSUE_TEMPLATE/featurerequest.yaml b/.github/ISSUE_TEMPLATE/featurerequest.yaml index 24595b801..65c056c98 100644 --- a/.github/ISSUE_TEMPLATE/featurerequest.yaml +++ b/.github/ISSUE_TEMPLATE/featurerequest.yaml @@ -32,6 +32,7 @@ body: - 03-Azure/01-03-Infrastructure/05_Azure_VMware_Solution - 03-Azure/01-03-Infrastructure/06_Migration_Datacenter_Modernization - 03-Azure/01-03-Infrastructure/07_Azure_Monitor + - 03-Azure/01-03-Infrastructure/10_Oracle_on_Azure - 03-Azure/01-04- AI/01_Azure_OpenAI_Service - 04-Microsoft-365 validations: From acbba13f10da2e50e78ba2fad8133410b41c48e4 Mon Sep 17 00:00:00 2001 From: Orthodoxos Kipouridis Date: Mon, 13 Jan 2025 21:39:36 +0100 Subject: [PATCH 4/7] Oracle_on_Azure IaC for Environment Deployment (#205) * initial commit of Oracle_on_Azure Microhack containing Terraform scripts for deploying the IaaS resources required for executing the hackathon. Only the VMs are deployed with this commit, not Oracle databases * add licence file --------- Co-authored-by: akiskips --- .../10_Oracle_on_Azure/Challenges/README.md | 0 .../10_Oracle_on_Azure/Walkthrough/README.md | 1 + .../resources/environment_setup/README.md | 78 ++++ .../terraform/data_guard/LICENSE | 21 + .../terraform/data_guard/backend.tf | 3 + .../terraform/data_guard/jit_rule.tf | 91 +++++ .../terraform/data_guard/module.tf | 257 ++++++++++++ .../common_infrastructure/infrastructure.tf | 149 +++++++ .../monitoring_settings.tf | 127 ++++++ .../modules/common_infrastructure/outputs.tf | 98 +++++ .../common_infrastructure/providers.tf | 24 ++ .../common_infrastructure/resource_lock.tf | 27 ++ .../common_infrastructure/role_assignments.tf | 17 + .../common_infrastructure/variables_global.tf | 95 +++++ .../common_infrastructure/variables_local.tf | 43 ++ .../modules/compute/availability_set.tf | 17 + .../data_guard/modules/compute/data.tf | 14 + .../modules/compute/monitoring_settings.tf | 10 + .../data_guard/modules/compute/outputs.tf | 32 ++ .../modules/compute/variable_global.tf | 366 ++++++++++++++++++ .../modules/compute/variable_local.tf | 116 ++++++ .../data_guard/modules/compute/vm.tf | 45 +++ .../modules/network/diagnostic_settings.tf | 145 +++++++ .../data_guard/modules/network/nsg.tf | 26 ++ .../data_guard/modules/network/outputs.tf | 20 + .../data_guard/modules/network/pip.tf | 24 ++ .../data_guard/modules/network/providers.tf | 24 ++ .../modules/network/resource_lock.tf | 27 ++ .../modules/network/role_assignments.tf | 82 ++++ .../modules/network/variables_global.tf | 128 ++++++ .../modules/network/variables_local.tf | 13 + .../data_guard/modules/network/vnet_main.tf | 37 ++ .../data_guard/modules/storage/data_disk.tf | 83 ++++ .../data_guard/modules/storage/outputs.tf | 24 ++ .../data_guard/modules/storage/providers.tf | 24 ++ .../modules/storage/resource_lock.tf | 8 + .../modules/storage/role_assignments.tf | 17 + .../modules/storage/variables_global.tf | 92 +++++ .../modules/storage/variables_local.tf | 51 +++ .../terraform/data_guard/outputs.tf | 70 ++++ .../terraform/data_guard/providers.tf | 29 ++ .../data_guard/resources.telemetry.tf | 15 + .../terraform/data_guard/transform.tf | 39 ++ .../terraform/data_guard/variables.md | 173 +++++++++ .../terraform/data_guard/variables_global.tf | 184 +++++++++ .../terraform/data_guard/variables_local.tf | 46 +++ 46 files changed, 3012 insertions(+) create mode 100644 03-Azure/01-03-Infrastructure/10_Oracle_on_Azure/Challenges/README.md create mode 100644 03-Azure/01-03-Infrastructure/10_Oracle_on_Azure/Walkthrough/README.md create mode 100644 03-Azure/01-03-Infrastructure/10_Oracle_on_Azure/resources/environment_setup/README.md create mode 100644 03-Azure/01-03-Infrastructure/10_Oracle_on_Azure/resources/environment_setup/terraform/data_guard/LICENSE create mode 100644 03-Azure/01-03-Infrastructure/10_Oracle_on_Azure/resources/environment_setup/terraform/data_guard/backend.tf create mode 100644 03-Azure/01-03-Infrastructure/10_Oracle_on_Azure/resources/environment_setup/terraform/data_guard/jit_rule.tf create mode 100644 03-Azure/01-03-Infrastructure/10_Oracle_on_Azure/resources/environment_setup/terraform/data_guard/module.tf create mode 100644 03-Azure/01-03-Infrastructure/10_Oracle_on_Azure/resources/environment_setup/terraform/data_guard/modules/common_infrastructure/infrastructure.tf create mode 100644 03-Azure/01-03-Infrastructure/10_Oracle_on_Azure/resources/environment_setup/terraform/data_guard/modules/common_infrastructure/monitoring_settings.tf create mode 100644 03-Azure/01-03-Infrastructure/10_Oracle_on_Azure/resources/environment_setup/terraform/data_guard/modules/common_infrastructure/outputs.tf create mode 100644 03-Azure/01-03-Infrastructure/10_Oracle_on_Azure/resources/environment_setup/terraform/data_guard/modules/common_infrastructure/providers.tf create mode 100644 03-Azure/01-03-Infrastructure/10_Oracle_on_Azure/resources/environment_setup/terraform/data_guard/modules/common_infrastructure/resource_lock.tf create mode 100644 03-Azure/01-03-Infrastructure/10_Oracle_on_Azure/resources/environment_setup/terraform/data_guard/modules/common_infrastructure/role_assignments.tf create mode 100644 03-Azure/01-03-Infrastructure/10_Oracle_on_Azure/resources/environment_setup/terraform/data_guard/modules/common_infrastructure/variables_global.tf create mode 100644 03-Azure/01-03-Infrastructure/10_Oracle_on_Azure/resources/environment_setup/terraform/data_guard/modules/common_infrastructure/variables_local.tf create mode 100644 03-Azure/01-03-Infrastructure/10_Oracle_on_Azure/resources/environment_setup/terraform/data_guard/modules/compute/availability_set.tf create mode 100644 03-Azure/01-03-Infrastructure/10_Oracle_on_Azure/resources/environment_setup/terraform/data_guard/modules/compute/data.tf create mode 100644 03-Azure/01-03-Infrastructure/10_Oracle_on_Azure/resources/environment_setup/terraform/data_guard/modules/compute/monitoring_settings.tf create mode 100644 03-Azure/01-03-Infrastructure/10_Oracle_on_Azure/resources/environment_setup/terraform/data_guard/modules/compute/outputs.tf create mode 100644 03-Azure/01-03-Infrastructure/10_Oracle_on_Azure/resources/environment_setup/terraform/data_guard/modules/compute/variable_global.tf create mode 100644 03-Azure/01-03-Infrastructure/10_Oracle_on_Azure/resources/environment_setup/terraform/data_guard/modules/compute/variable_local.tf create mode 100644 03-Azure/01-03-Infrastructure/10_Oracle_on_Azure/resources/environment_setup/terraform/data_guard/modules/compute/vm.tf create mode 100644 03-Azure/01-03-Infrastructure/10_Oracle_on_Azure/resources/environment_setup/terraform/data_guard/modules/network/diagnostic_settings.tf create mode 100644 03-Azure/01-03-Infrastructure/10_Oracle_on_Azure/resources/environment_setup/terraform/data_guard/modules/network/nsg.tf create mode 100644 03-Azure/01-03-Infrastructure/10_Oracle_on_Azure/resources/environment_setup/terraform/data_guard/modules/network/outputs.tf create mode 100644 03-Azure/01-03-Infrastructure/10_Oracle_on_Azure/resources/environment_setup/terraform/data_guard/modules/network/pip.tf create mode 100644 03-Azure/01-03-Infrastructure/10_Oracle_on_Azure/resources/environment_setup/terraform/data_guard/modules/network/providers.tf create mode 100644 03-Azure/01-03-Infrastructure/10_Oracle_on_Azure/resources/environment_setup/terraform/data_guard/modules/network/resource_lock.tf create mode 100644 03-Azure/01-03-Infrastructure/10_Oracle_on_Azure/resources/environment_setup/terraform/data_guard/modules/network/role_assignments.tf create mode 100644 03-Azure/01-03-Infrastructure/10_Oracle_on_Azure/resources/environment_setup/terraform/data_guard/modules/network/variables_global.tf create mode 100644 03-Azure/01-03-Infrastructure/10_Oracle_on_Azure/resources/environment_setup/terraform/data_guard/modules/network/variables_local.tf create mode 100644 03-Azure/01-03-Infrastructure/10_Oracle_on_Azure/resources/environment_setup/terraform/data_guard/modules/network/vnet_main.tf create mode 100644 03-Azure/01-03-Infrastructure/10_Oracle_on_Azure/resources/environment_setup/terraform/data_guard/modules/storage/data_disk.tf create mode 100644 03-Azure/01-03-Infrastructure/10_Oracle_on_Azure/resources/environment_setup/terraform/data_guard/modules/storage/outputs.tf create mode 100644 03-Azure/01-03-Infrastructure/10_Oracle_on_Azure/resources/environment_setup/terraform/data_guard/modules/storage/providers.tf create mode 100644 03-Azure/01-03-Infrastructure/10_Oracle_on_Azure/resources/environment_setup/terraform/data_guard/modules/storage/resource_lock.tf create mode 100644 03-Azure/01-03-Infrastructure/10_Oracle_on_Azure/resources/environment_setup/terraform/data_guard/modules/storage/role_assignments.tf create mode 100644 03-Azure/01-03-Infrastructure/10_Oracle_on_Azure/resources/environment_setup/terraform/data_guard/modules/storage/variables_global.tf create mode 100644 03-Azure/01-03-Infrastructure/10_Oracle_on_Azure/resources/environment_setup/terraform/data_guard/modules/storage/variables_local.tf create mode 100644 03-Azure/01-03-Infrastructure/10_Oracle_on_Azure/resources/environment_setup/terraform/data_guard/outputs.tf create mode 100644 03-Azure/01-03-Infrastructure/10_Oracle_on_Azure/resources/environment_setup/terraform/data_guard/providers.tf create mode 100644 03-Azure/01-03-Infrastructure/10_Oracle_on_Azure/resources/environment_setup/terraform/data_guard/resources.telemetry.tf create mode 100644 03-Azure/01-03-Infrastructure/10_Oracle_on_Azure/resources/environment_setup/terraform/data_guard/transform.tf create mode 100644 03-Azure/01-03-Infrastructure/10_Oracle_on_Azure/resources/environment_setup/terraform/data_guard/variables.md create mode 100644 03-Azure/01-03-Infrastructure/10_Oracle_on_Azure/resources/environment_setup/terraform/data_guard/variables_global.tf create mode 100644 03-Azure/01-03-Infrastructure/10_Oracle_on_Azure/resources/environment_setup/terraform/data_guard/variables_local.tf diff --git a/03-Azure/01-03-Infrastructure/10_Oracle_on_Azure/Challenges/README.md b/03-Azure/01-03-Infrastructure/10_Oracle_on_Azure/Challenges/README.md new file mode 100644 index 000000000..e69de29bb diff --git a/03-Azure/01-03-Infrastructure/10_Oracle_on_Azure/Walkthrough/README.md b/03-Azure/01-03-Infrastructure/10_Oracle_on_Azure/Walkthrough/README.md new file mode 100644 index 000000000..30404ce4c --- /dev/null +++ b/03-Azure/01-03-Infrastructure/10_Oracle_on_Azure/Walkthrough/README.md @@ -0,0 +1 @@ +TODO \ No newline at end of file diff --git a/03-Azure/01-03-Infrastructure/10_Oracle_on_Azure/resources/environment_setup/README.md b/03-Azure/01-03-Infrastructure/10_Oracle_on_Azure/resources/environment_setup/README.md new file mode 100644 index 000000000..452569f55 --- /dev/null +++ b/03-Azure/01-03-Infrastructure/10_Oracle_on_Azure/resources/environment_setup/README.md @@ -0,0 +1,78 @@ +# Step-by-step Instructions how to Deploy Oracle Data Guard on Azure VMs - Terraform Automation + +## Overview + +This repository contains code to install and configure Oracle databases on Azure VM IaaS in an automated fashion. The scenario of two VMs in an Oracle Dataguard configuration, deployed through Terraform (TODO: and Ansible). + +For more information about how to install and configure Data Guard on an Azure virtual machine (VM) with CLI refer to the documentation [here](https://docs.microsoft.com/en-us/azure/virtual-machines/linux/oracle-dataguard). + +__Important Note - Disclaimer__: The code of this repository is largely based on the Oracle Deployment Automation repository (lza-oracle), which can be found [here](https://github.com/Azure/lza-oracle). The goal of the Terraform automation scripts in this repository is primarily to facilitate the successful execution of the Microhack. The code in this repository is not intended for production use and should be used with caution. +At the lza-oracle repository, you can find the code for deploying Oracle databases on Azure VMs using different scenarios, such as single and Dataguard using Terraform, Bicept and Ansible. +If you are interested in deploying Oracle databases on Azure VMs, we recommend you to check the [lza-oracle](https://github.com/Azure/lza-oracle) repository. + +Note that Oracle licensing is not a part of this solution. Please verify that you have the necessary Oracle licenses to run Oracle software on Azure IaaS. + + +The above resources can be deployed using the sample Github action workflows provided in the repository. The workflows are designed to deploy the infrastructure and configure the Oracle database on the VMs. This is the recommended way to deploy the infrastructure and configure the Oracle database. Alternatively the infrastructure can be deployed using Azure CLI and the Oracle database can be configured using Ansible. + +Note that the code provided in this repository is for demonstration purposes only and should not be used in a production environment without thorough testing. + +## Prerequisites + +1. Azure Entra ID Tenant. +2. Minimum 1 subscription, for when deploying VMs. If you don't have an Azure subscription, create a [free account](https://azure.microsoft.com/en-us/free/?ref=microsoft.com&utm_source=microsoft.com&utm_medium=docs&utm_campaign=visualstudio) before you begin. +3. Azure CLI installed on your local machine. You can install Azure CLI from [here](https://docs.microsoft.com/en-us/cli/azure/install-azure-cli). +4. Terraform installed on your local machine. You can install Terraform from [here](https://learn.hashicorp.com/tutorials/terraform/install-cli). + + +## 1. Authenticate Terraform to Azure + +To use Terraform commands against your Azure subscription, you must first authenticate Terraform to that subscription. [This doc](https://learn.microsoft.com/en-us/azure/developer/terraform/authenticate-to-azure?tabs=bash) describes how to authenticate Terraform to your Azure subscription. + +### 2. Create SSH Key + +To deploy Oracle Data Guard on the VMs, you can use **data_guard** module in this repo. The module is located on `terraform/data_guard` directory. + +Before using this module, you have to create your own ssh key to deploy and connect to the two virtual machines you will create. + +```bash +ssh-keygen -f ~/.ssh/mh-oracle-data-guard + +ls -lha ~/.ssh/ +-rw------- 1 yourname staff 2.6K 8 17 2023 mh-oracle-data-guard +-rw-r--r-- 1 yourname staff 589B 8 17 2023 mh-oracle-data-guard.pub +``` + +### 4. Define Variables + +Define the variables such as location and Resource Group name in the `global_variables.tf` file. For more reference on all variables you can set, see [variables description](variables.md) + +Next, you go to `terraform/data_guard` directory and create `fixtures.tfvars` file, then copy the contents of the ssh public key used for deploying virtual machines on Azure (~/.ssh/mh-oracle-data-guard.pub). + +This is a sample `fixtures.tfvars` file. + +```tf:fixtures.tfvars +ssh_key = "ssh-rsa xxxxxxxxxxxxxx=" +``` +### 5. Execute Terraform Commands +Execute below Terraform commands. When you deploy resources to Azure, you have to indicate `fixtures.tfvars` as a variable file, which contains the ssh public key. + +```bash + +$ terraform init + +$ terraform plan -var-file=fixtures.tfvars + +$ terraform apply -var-file=fixtures.tfvars +``` + +You can connect to the virtual machine with ssh private key. While deploying resources, a public ip address is generated and attached to the virtual machine, so that you can connect to the virtual machine with this IP address. The username is `oracle`, which is fixed in `terraform/data_guard/module.tf`. + +``` +$ ssh -i ~/.ssh/mh-oracle-data-guard oracle@ + + + +## Trademarks + +This project may contain trademarks or logos for projects, products, or services. Authorized use of Microsoft trademarks or logos is subject to and must follow [Microsoft's Trademark & Brand Guidelines](https://www.microsoft.com/en-us/legal/intellectualproperty/trademarks/usage/general). Use of Microsoft trademarks or logos in modified versions of this project must not cause confusion or imply Microsoft sponsorship. Any use of third-party trademarks or logos are subject to those third-party's policies. diff --git a/03-Azure/01-03-Infrastructure/10_Oracle_on_Azure/resources/environment_setup/terraform/data_guard/LICENSE b/03-Azure/01-03-Infrastructure/10_Oracle_on_Azure/resources/environment_setup/terraform/data_guard/LICENSE new file mode 100644 index 000000000..9e841e7a2 --- /dev/null +++ b/03-Azure/01-03-Infrastructure/10_Oracle_on_Azure/resources/environment_setup/terraform/data_guard/LICENSE @@ -0,0 +1,21 @@ + MIT License + + Copyright (c) Microsoft Corporation. + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE diff --git a/03-Azure/01-03-Infrastructure/10_Oracle_on_Azure/resources/environment_setup/terraform/data_guard/backend.tf b/03-Azure/01-03-Infrastructure/10_Oracle_on_Azure/resources/environment_setup/terraform/data_guard/backend.tf new file mode 100644 index 000000000..556a8c85c --- /dev/null +++ b/03-Azure/01-03-Infrastructure/10_Oracle_on_Azure/resources/environment_setup/terraform/data_guard/backend.tf @@ -0,0 +1,3 @@ +terraform { + backend "local" {} +} diff --git a/03-Azure/01-03-Infrastructure/10_Oracle_on_Azure/resources/environment_setup/terraform/data_guard/jit_rule.tf b/03-Azure/01-03-Infrastructure/10_Oracle_on_Azure/resources/environment_setup/terraform/data_guard/jit_rule.tf new file mode 100644 index 000000000..39ba4ff7d --- /dev/null +++ b/03-Azure/01-03-Infrastructure/10_Oracle_on_Azure/resources/environment_setup/terraform/data_guard/jit_rule.tf @@ -0,0 +1,91 @@ +######################################################################################### +# # +# JIT Access Policy # +# # +######################################################################################### +data "azurerm_virtual_machine" "oracle_primary_vm" { + name = module.vm_primary.vm.name + resource_group_name = module.common_infrastructure.resource_group.name + + depends_on = [module.vm_primary, + module.storage_primary + ] +} + +data "azurerm_virtual_machine" "oracle_secondary_vm" { + name = module.vm_secondary.vm.name + resource_group_name = module.common_infrastructure.resource_group.name + + depends_on = [module.vm_secondary + , module.storage_secondary + ] +} + +resource "time_sleep" "wait_for_primary_vm_creation" { + create_duration = var.jit_wait_for_vm_creation + + depends_on = [data.azurerm_virtual_machine.oracle_primary_vm, + module.storage_primary + ] +} + +resource "time_sleep" "wait_for_secondary_vm_creation" { + create_duration = var.jit_wait_for_vm_creation + + depends_on = [data.azurerm_virtual_machine.oracle_secondary_vm + , module.storage_secondary + ] +} + + +resource "azapi_resource" "jit_ssh_policy_primary" { + count = module.vm_primary.database_server_count + name = "JIT-SSH-Policy-primary" + parent_id = "${module.common_infrastructure.resource_group.id}/providers/Microsoft.Security/locations/${module.common_infrastructure.resource_group.location}" + type = "Microsoft.Security/locations/jitNetworkAccessPolicies@2020-01-01" + schema_validation_enabled = false + body = jsonencode({ + "kind" : "Basic" + "properties" : { + "virtualMachines" : [{ + "id" : "/subscriptions/${module.common_infrastructure.current_subscription.subscription_id}/resourceGroups/${module.common_infrastructure.resource_group.name}/providers/Microsoft.Compute/virtualMachines/${module.vm_primary.vm.name}", + "ports" : [ + { + "number" : 22, + "protocol" : "TCP", + "allowedSourceAddressPrefix" : "*", + "maxRequestAccessDuration" : "PT3H" + } + ] + }] + } + }) + + depends_on = [time_sleep.wait_for_primary_vm_creation] +} + +resource "azapi_resource" "jit_ssh_policy_secondary" { + count = module.vm_secondary.database_server_count + name = "JIT-SSH-Policy-secondary" + parent_id = "${module.common_infrastructure.resource_group.id}/providers/Microsoft.Security/locations/${module.common_infrastructure.resource_group.location}" + type = "Microsoft.Security/locations/jitNetworkAccessPolicies@2020-01-01" + schema_validation_enabled = false + body = jsonencode({ + "kind" : "Basic" + "properties" : { + "virtualMachines" : [{ + "id" : "/subscriptions/${module.common_infrastructure.current_subscription.subscription_id}/resourceGroups/${module.common_infrastructure.resource_group.name}/providers/Microsoft.Compute/virtualMachines/${module.vm_secondary.vm.name}", + "ports" : [ + { + "number" : 22, + "protocol" : "TCP", + "allowedSourceAddressPrefix" : "*", + "maxRequestAccessDuration" : "PT3H" + } + ] + }] + } + }) + + depends_on = [time_sleep.wait_for_secondary_vm_creation] +} diff --git a/03-Azure/01-03-Infrastructure/10_Oracle_on_Azure/resources/environment_setup/terraform/data_guard/module.tf b/03-Azure/01-03-Infrastructure/10_Oracle_on_Azure/resources/environment_setup/terraform/data_guard/module.tf new file mode 100644 index 000000000..2e94560c4 --- /dev/null +++ b/03-Azure/01-03-Infrastructure/10_Oracle_on_Azure/resources/environment_setup/terraform/data_guard/module.tf @@ -0,0 +1,257 @@ +data "azurerm_client_config" "current" {} + +module "common_infrastructure" { + source = "./modules/common_infrastructure" + + infrastructure = local.infrastructure + is_data_guard = true + is_diagnostic_settings_enabled = var.is_diagnostic_settings_enabled + diagnostic_target = var.diagnostic_target + tags = var.resourcegroup_tags + +} + +module "vm_primary" { + source = "./modules/compute" + + resource_group_name = module.common_infrastructure.created_resource_group_name + location = var.location + vm_name = "vm-primary-0" + public_key = var.ssh_key + sid_username = "oracle" + vm_sku = var.vm_sku + + vm_source_image_reference = var.vm_source_image_reference + aad_system_assigned_identity = true + public_ip_address_resource_id = module.network.db_server_puplic_ip_resources[0].id + + + is_diagnostic_settings_enabled = module.common_infrastructure.is_diagnostic_settings_enabled + diagnostic_target = module.common_infrastructure.diagnostic_target + storage_account_id = module.common_infrastructure.target_storage_account_id + storage_account_sas_token = module.common_infrastructure.target_storage_account_sas + log_analytics_workspace = module.common_infrastructure.log_analytics_workspace != null ? { + id = module.common_infrastructure.log_analytics_workspace.id + name = module.common_infrastructure.log_analytics_workspace.name + } : null + data_collection_rules = module.common_infrastructure.data_collection_rules + eventhub_authorization_rule_id = module.common_infrastructure.eventhub_authorization_rule_id + partner_solution_id = module.common_infrastructure.partner_solution_id + tags = module.common_infrastructure.tags + db_subnet = module.network.db_subnet + + availability_zone = 1 + + + + vm_user_assigned_identity_id = var.vm_user_assigned_identity_id + + vm_os_disk = { + name = "osdisk-primary" + caching = "ReadWrite" + storage_account_type = "Premium_LRS" + disk_encryption_set_id = null + disk_size_gb = 128 + } + + role_assignments = { + role_assignment_1 = { + role_definition_id_or_name = "Virtual Machine Contributor" + principal_id = data.azurerm_client_config.current.object_id + skip_service_principal_aad_check = false + } + } + + role_assignments_nic = { + role_assignment_1 = { + role_definition_id_or_name = "Contributor" + principal_id = data.azurerm_client_config.current.object_id + skip_service_principal_aad_check = false + } + } + + vm_extensions = { + azure_monitor_agent = { + name = "vm-primary-azure-monitor-agent" + publisher = "Microsoft.Azure.Monitor" + type = "AzureMonitorLinuxAgent" + type_handler_version = "1.0" + auto_upgrade_minor_version = true + automatic_upgrade_enabled = true + settings = null + } + } + + depends_on = [module.network, module.common_infrastructure] +} + + +module "vm_secondary" { + source = "./modules/compute" + + resource_group_name = module.common_infrastructure.created_resource_group_name + location = var.location + vm_name = "vm-secondary-0" + public_key = var.ssh_key + sid_username = "oracle" + vm_sku = var.vm_sku + + vm_source_image_reference = var.vm_source_image_reference + vm_user_assigned_identity_id = var.vm_user_assigned_identity_id + aad_system_assigned_identity = true + public_ip_address_resource_id = module.network.db_server_puplic_ip_resources[1].id + + is_diagnostic_settings_enabled = module.common_infrastructure.is_diagnostic_settings_enabled + diagnostic_target = module.common_infrastructure.diagnostic_target + storage_account_id = module.common_infrastructure.target_storage_account_id + storage_account_sas_token = module.common_infrastructure.target_storage_account_sas + log_analytics_workspace = module.common_infrastructure.log_analytics_workspace != null ? { + id = module.common_infrastructure.log_analytics_workspace.id + name = module.common_infrastructure.log_analytics_workspace.name + } : null + data_collection_rules = module.common_infrastructure.data_collection_rules + eventhub_authorization_rule_id = module.common_infrastructure.eventhub_authorization_rule_id + partner_solution_id = module.common_infrastructure.partner_solution_id + tags = module.common_infrastructure.tags + db_subnet = module.network.db_subnet + + + + vm_os_disk = { + name = "osdisk-secondary" + caching = "ReadWrite" + storage_account_type = "Premium_LRS" + disk_encryption_set_id = null + disk_size_gb = 128 + } + + role_assignments = { + role_assignment_1 = { + role_definition_id_or_name = "Virtual Machine Contributor" + principal_id = data.azurerm_client_config.current.object_id + skip_service_principal_aad_check = false + } + } + + vm_extensions = { + azure_monitor_agent = { + name = "vm-secondary-azure-monitor-agent" + publisher = "Microsoft.Azure.Monitor" + type = "AzureMonitorLinuxAgent" + type_handler_version = "1.1" + auto_upgrade_minor_version = true + automatic_upgrade_enabled = true + settings = null + } + } + #ToDo: Pending + # role_assignments_nic = { + # role_assignment_1 = { + # role_definition_id_or_name = "Contributor" + # principal_id = data.azurerm_client_config.current.object_id + # skip_service_principal_aad_check = false + # } + # } + + depends_on = [module.network, module.common_infrastructure] +} + +module "network" { + source = "./modules/network" + + resource_group = module.common_infrastructure.resource_group + is_data_guard = module.common_infrastructure.is_data_guard + is_diagnostic_settings_enabled = module.common_infrastructure.is_diagnostic_settings_enabled + diagnostic_target = module.common_infrastructure.diagnostic_target + storage_account_id = module.common_infrastructure.target_storage_account_id + log_analytics_workspace_id = try(module.common_infrastructure.log_analytics_workspace.id, "") + eventhub_authorization_rule_id = module.common_infrastructure.eventhub_authorization_rule_id + partner_solution_id = module.common_infrastructure.partner_solution_id + tags = module.common_infrastructure.tags + + + #ToDo: role_assignments_nic + # role_assignments_nic = { + # role_assignment_1 = { + # name = "Contributor" + # skip_service_principal_aad_check = false + # } + # } + + role_assignments_pip = { + role_assignment_1 = { + name = "Contributor" + skip_service_principal_aad_check = false + } + } + + role_assignments_nsg = { + role_assignment_1 = { + name = "Contributor" + skip_service_principal_aad_check = false + } + } + + role_assignments_vnet = { + role_assignment_1 = { + name = "Contributor" + skip_service_principal_aad_check = false + } + } + + role_assignments_subnet = { + role_assignment_1 = { + name = "Contributor" + skip_service_principal_aad_check = false + } + } +} + + +module "storage_primary" { + source = "./modules/storage" + + resource_group = module.common_infrastructure.resource_group + is_data_guard = module.common_infrastructure.is_data_guard + naming = "oracle-primary" + vm = module.vm_primary.vm + tags = module.common_infrastructure.tags + database_disks_options = { + data_disks = var.database_disks_options.data_disks + asm_disks = var.database_disks_options.asm_disks + redo_disks = var.database_disks_options.redo_disks + } + availability_zone = module.vm_primary.availability_zone + + role_assignments = { + role_assignment_1 = { + name = "Contributor" + skip_service_principal_aad_check = false + } + } +} + +module "storage_secondary" { + source = "./modules/storage" + + resource_group = module.common_infrastructure.resource_group + is_data_guard = module.common_infrastructure.is_data_guard + naming = "oracle-secondary" + vm = module.vm_secondary.vm + tags = module.common_infrastructure.tags + database_disks_options = { + data_disks = var.database_disks_options.data_disks + asm_disks = var.database_disks_options.asm_disks + redo_disks = var.database_disks_options.redo_disks + } + availability_zone = module.vm_secondary.availability_zone + + role_assignments = { + role_assignment_1 = { + name = "Contributor" + skip_service_principal_aad_check = false + } + } +} + + diff --git a/03-Azure/01-03-Infrastructure/10_Oracle_on_Azure/resources/environment_setup/terraform/data_guard/modules/common_infrastructure/infrastructure.tf b/03-Azure/01-03-Infrastructure/10_Oracle_on_Azure/resources/environment_setup/terraform/data_guard/modules/common_infrastructure/infrastructure.tf new file mode 100644 index 000000000..a91ed21d9 --- /dev/null +++ b/03-Azure/01-03-Infrastructure/10_Oracle_on_Azure/resources/environment_setup/terraform/data_guard/modules/common_infrastructure/infrastructure.tf @@ -0,0 +1,149 @@ +######################################################################################### +# # +# Subscription # +# # +######################################################################################### +data "azurerm_subscription" "current" {} + +######################################################################################### +# # +# Resource Group # +# # +######################################################################################### +resource "azurerm_resource_group" "rg" { + count = local.resource_group_exists ? 0 : 1 + name = local.rg_name + location = var.infrastructure.region + tags = var.tags + + lifecycle { + ignore_changes = [ + tags + ] + } +} + +data "azurerm_resource_group" "rg" { + name = local.rg_name + + depends_on = [azurerm_resource_group.rg] +} + +######################################################################################### +# # +# Diagnostic Settings # +# # +######################################################################################### +resource "azurerm_storage_account" "diagnostic" { + count = var.is_diagnostic_settings_enabled ? 1 : 0 + name = "${local.prefix}diag${random_string.suffix.result}" + resource_group_name = data.azurerm_resource_group.rg.name + location = data.azurerm_resource_group.rg.location + tags = merge(local.tags, var.tags) + + account_tier = "Standard" + account_replication_type = "LRS" +} + +data "azurerm_storage_account" "diagnostic" { + count = var.is_diagnostic_settings_enabled ? 1 : 0 + name = azurerm_storage_account.diagnostic[count.index].name + resource_group_name = data.azurerm_resource_group.rg.name + + depends_on = [azurerm_storage_account.diagnostic] +} + +resource "random_string" "suffix" { + length = 14 + special = false + upper = false +} + +data "azurerm_storage_account_sas" "diagnostic" { + count = var.is_diagnostic_settings_enabled ? 1 : 0 + connection_string = azurerm_storage_account.diagnostic[0].primary_connection_string + + resource_types { + service = false + container = true + object = true + } + + services { + blob = true + queue = false + table = true + file = false + } + + start = timestamp() + expiry = timeadd(timestamp(), "8766h") + + permissions { + read = false + write = true + delete = false + list = true + add = true + create = true + update = true + process = false + tag = false + filter = false + } +} + +resource "azurerm_log_analytics_workspace" "diagnostic" { + count = var.is_diagnostic_settings_enabled && var.diagnostic_target == "Log_Analytics_Workspace" ? 1 : 0 + name = "${local.prefix}diag${random_string.suffix.result}" + resource_group_name = data.azurerm_resource_group.rg.name + location = data.azurerm_resource_group.rg.location + sku = "PerGB2018" + retention_in_days = 30 + tags = merge(local.tags, var.tags) +} + +data "azurerm_log_analytics_workspace" "diagnostic" { + count = var.is_diagnostic_settings_enabled && var.diagnostic_target == "Log_Analytics_Workspace" ? 1 : 0 + name = "${local.prefix}diag${random_string.suffix.result}" + resource_group_name = data.azurerm_resource_group.rg.name + + depends_on = [azurerm_log_analytics_workspace.diagnostic] +} + +resource "azurerm_eventhub_namespace" "diagnostic" { + count = var.is_diagnostic_settings_enabled && var.diagnostic_target == "Event_Hubs" ? 1 : 0 + name = "${local.prefix}diag${random_string.suffix.result}" + resource_group_name = data.azurerm_resource_group.rg.name + location = data.azurerm_resource_group.rg.location + sku = "Standard" + capacity = 1 + tags = merge(local.tags, var.tags) +} + +resource "azurerm_eventhub_namespace_authorization_rule" "diagnostic" { + count = var.is_diagnostic_settings_enabled && var.diagnostic_target == "Event_Hubs" ? 1 : 0 + name = "${local.prefix}diag${random_string.suffix.result}" + namespace_name = azurerm_eventhub_namespace.diagnostic[0].name + resource_group_name = data.azurerm_resource_group.rg.name + listen = var.eventhub_permission.listen + send = var.eventhub_permission.send + manage = var.eventhub_permission.manage +} + +resource "azurerm_new_relic_monitor" "diagnostic" { + count = var.is_diagnostic_settings_enabled && var.diagnostic_target == "Partner_Solutions" ? 1 : 0 + name = "${local.prefix}diag${random_string.suffix.result}" + resource_group_name = data.azurerm_resource_group.rg.name + location = data.azurerm_resource_group.rg.location + plan { + effective_date = "2023-09-20T00:00:00Z" + } + + user { + email = var.logz_user.email + first_name = var.logz_user.first_name + last_name = var.logz_user.last_name + phone_number = var.logz_user.phone_number + } +} diff --git a/03-Azure/01-03-Infrastructure/10_Oracle_on_Azure/resources/environment_setup/terraform/data_guard/modules/common_infrastructure/monitoring_settings.tf b/03-Azure/01-03-Infrastructure/10_Oracle_on_Azure/resources/environment_setup/terraform/data_guard/modules/common_infrastructure/monitoring_settings.tf new file mode 100644 index 000000000..bfcf4f2da --- /dev/null +++ b/03-Azure/01-03-Infrastructure/10_Oracle_on_Azure/resources/environment_setup/terraform/data_guard/modules/common_infrastructure/monitoring_settings.tf @@ -0,0 +1,127 @@ + +#Data collection rules +resource "azurerm_monitor_data_collection_rule" "collection_rule_linux" { + count = var.is_diagnostic_settings_enabled && var.diagnostic_target == "Log_Analytics_Workspace" ? 1 : 0 + kind = "Linux" + location = var.infrastructure.region + name = "LinuxCollectionRule" + resource_group_name = local.rg_name + tags = var.tags + data_flow { + destinations = [data.azurerm_log_analytics_workspace.diagnostic[0].name] + output_stream = "Microsoft-Perf" + streams = ["Microsoft-Perf"] + transform_kql = "source" + } + data_flow { + destinations = [data.azurerm_log_analytics_workspace.diagnostic[0].name] + output_stream = "Microsoft-Syslog" + streams = ["Microsoft-Syslog"] + transform_kql = "source" + } + data_sources { + performance_counter { + counter_specifiers = ["Processor(*)\\% Processor Time", "Processor(*)\\% Idle Time", "Processor(*)\\% User Time", "Processor(*)\\% Nice Time", "Processor(*)\\% Privileged Time", "Processor(*)\\% IO Wait Time", "Processor(*)\\% Interrupt Time", "Processor(*)\\% DPC Time", "Memory(*)\\Available MBytes Memory", "Memory(*)\\% Available Memory", "Memory(*)\\Used Memory MBytes", "Memory(*)\\% Used Memory", "Memory(*)\\Pages/sec", "Memory(*)\\Page Reads/sec", "Memory(*)\\Page Writes/sec", "Memory(*)\\Available MBytes Swap", "Memory(*)\\% Available Swap Space", "Memory(*)\\Used MBytes Swap Space", "Memory(*)\\% Used Swap Space", "Process(*)\\Pct User Time", "Process(*)\\Pct Privileged Time", "Process(*)\\Used Memory", "Process(*)\\Virtual Shared Memory", "Logical Disk(*)\\% Free Inodes", "Logical Disk(*)\\% Used Inodes", "Logical Disk(*)\\Free Megabytes", "Logical Disk(*)\\% Free Space", "Logical Disk(*)\\% Used Space", "Logical Disk(*)\\Logical Disk Bytes/sec", "Logical Disk(*)\\Disk Read Bytes/sec", "Logical Disk(*)\\Disk Write Bytes/sec", "Logical Disk(*)\\Disk Transfers/sec", "Logical Disk(*)\\Disk Reads/sec", "Logical Disk(*)\\Disk Writes/sec", "Network(*)\\Total Bytes Transmitted", "Network(*)\\Total Bytes Received", "Network(*)\\Total Bytes", "Network(*)\\Total Packets Transmitted", "Network(*)\\Total Packets Received", "Network(*)\\Total Rx Errors", "Network(*)\\Total Tx Errors", "Network(*)\\Total Collisions", "System(*)\\Uptime", "System(*)\\Load1", "System(*)\\Load5", "System(*)\\Load15", "System(*)\\Users", "System(*)\\Unique Users", "System(*)\\CPUs"] + name = "perfCounterDataSource60" + sampling_frequency_in_seconds = 60 + streams = ["Microsoft-Perf"] + } + syslog { + facility_names = ["alert", "audit", "auth", "authpriv", "clock", "cron", "daemon", "ftp", "kern", "local0", "local1", "local2", "local3", "local4", "local5", "local6", "local7", "lpr", "mail", "news", "nopri", "ntp", "syslog", "user", "uucp"] + log_levels = ["Debug", "Info", "Notice", "Warning", "Error", "Critical", "Alert", "Emergency"] + name = "sysLogsDataSource-1688419672" + } + } + + + destinations { + + dynamic "log_analytics" { + for_each = local.law_destination_settings + iterator = dest + + content { + workspace_resource_id = dest.value.resource_id + name = dest.value.name + } + } + + dynamic "event_hub" { + for_each = local.eventhub_destination_settings + + content { + event_hub_id = each.value.resource_id + name = each.value.name + } + } + + dynamic "storage_blob" { + for_each = local.storage_account_destination_settings + + content { + storage_account_id = each.value.resource_id + container_name = each.value.container_name + name = each.value.name + } + } + } + + + depends_on = [data.azurerm_log_analytics_workspace.diagnostic] +} + +# Data collection rule for VM Insights +resource "azurerm_monitor_data_collection_rule" "collection_rule_vm_insights" { + count = var.is_diagnostic_settings_enabled && var.diagnostic_target == "Log_Analytics_Workspace" ? 1 : 0 + description = "Data collection rule for VM Insights." + location = var.infrastructure.region + name = "MSVMI-DataCollectionRuleVMInsights" + resource_group_name = local.rg_name + tags = var.tags + + data_flow { + destinations = ["VMInsightsPerf-Logs-Dest"] + streams = ["Microsoft-InsightsMetrics"] + } + data_flow { + destinations = ["VMInsightsPerf-Logs-Dest"] + streams = ["Microsoft-ServiceMap"] + } + data_sources { + extension { + extension_name = "DependencyAgent" + name = "DependencyAgentDataSource" + streams = ["Microsoft-ServiceMap"] + } + performance_counter { + counter_specifiers = ["\\VmInsights\\DetailedMetrics"] + name = "VMInsightsPerfCounters" + sampling_frequency_in_seconds = 60 + streams = ["Microsoft-InsightsMetrics"] + } + } + destinations { + log_analytics { + name = "VMInsightsPerf-Logs-Dest" + workspace_resource_id = data.azurerm_log_analytics_workspace.diagnostic[0].id + } + } + depends_on = [ + data.azurerm_log_analytics_workspace.diagnostic + ] +} + +data "azurerm_monitor_data_collection_rule" "collection_rule_linux" { + count = var.is_diagnostic_settings_enabled && var.diagnostic_target == "Log_Analytics_Workspace" ? 1 : 0 + + name = azurerm_monitor_data_collection_rule.collection_rule_linux[0].name + resource_group_name = local.rg_name +} + + +data "azurerm_monitor_data_collection_rule" "collection_rule_vm_insights" { + count = var.is_diagnostic_settings_enabled && var.diagnostic_target == "Log_Analytics_Workspace" ? 1 : 0 + + name = azurerm_monitor_data_collection_rule.collection_rule_vm_insights[0].name + resource_group_name = local.rg_name +} diff --git a/03-Azure/01-03-Infrastructure/10_Oracle_on_Azure/resources/environment_setup/terraform/data_guard/modules/common_infrastructure/outputs.tf b/03-Azure/01-03-Infrastructure/10_Oracle_on_Azure/resources/environment_setup/terraform/data_guard/modules/common_infrastructure/outputs.tf new file mode 100644 index 000000000..9686b921e --- /dev/null +++ b/03-Azure/01-03-Infrastructure/10_Oracle_on_Azure/resources/environment_setup/terraform/data_guard/modules/common_infrastructure/outputs.tf @@ -0,0 +1,98 @@ +############################################################################### +# # +# Subscription # +# # +############################################################################### +output "current_subscription" { + value = data.azurerm_subscription.current +} + +############################################################################### +# # +# Resource Group # +# # +############################################################################### +output "resource_group" { + value = data.azurerm_resource_group.rg +} + +output "created_resource_group_id" { + description = "Created resource group ID" + value = data.azurerm_resource_group.rg.id +} + +output "created_resource_group_name" { + description = "Created resource group name" + value = data.azurerm_resource_group.rg.name +} + +output "created_resource_group_subscription_id" { + description = "Created resource group' subscription ID" + value = data.azurerm_resource_group.rg.id +} + +output "is_data_guard" { + description = "Whether the deployment is for Data Guard" + value = var.is_data_guard +} + +output "is_diagnostic_settings_enabled" { + description = "Whether diagnostic settings are enabled" + value = var.is_diagnostic_settings_enabled +} + +output "target_storage_account_id" { + description = "Storage account ID used for diagnostics" + value = var.is_diagnostic_settings_enabled ? data.azurerm_storage_account.diagnostic[0].id : "" +} + +output "target_storage_account_sas" { + description = "Storage account SAS used for diagnostics" + value = var.is_diagnostic_settings_enabled ? data.azurerm_storage_account_sas.diagnostic[0].sas : "" +} + +output "log_analytics_workspace" { + description = "Log Analytics workspace ID" + value = var.is_diagnostic_settings_enabled && var.diagnostic_target == "Log_Analytics_Workspace" ? { + id = data.azurerm_log_analytics_workspace.diagnostic[0].id + name = data.azurerm_log_analytics_workspace.diagnostic[0].name + } : null +} + +output "eventhub_authorization_rule_id" { + description = "ID of an Event Hub authorization rule" + value = var.is_diagnostic_settings_enabled && var.diagnostic_target == "Event_Hubs" ? azurerm_eventhub_namespace_authorization_rule.diagnostic[0].id : null +} + +output "partner_solution_id" { + description = "Partner solution ID" + value = var.is_diagnostic_settings_enabled && var.diagnostic_target == "Partner_Solutions" ? azurerm_new_relic_monitor.diagnostic[0].id : null +} + +output "diagnostic_target" { + description = "The destination type of the diagnostic settings" + value = var.diagnostic_target +} + +output "availability_zone" { + description = "Availability zones" + value = var.availability_zone +} + +output "tags" { + description = "Tags applied to the resources" + value = var.tags +} + +output "data_collection_rules" { + value = (var.is_diagnostic_settings_enabled && var.diagnostic_target == "Log_Analytics_Workspace") ? { + "${data.azurerm_monitor_data_collection_rule.collection_rule_linux[0].name}" = { + id = data.azurerm_monitor_data_collection_rule.collection_rule_linux[0].id + }, + "${data.azurerm_monitor_data_collection_rule.collection_rule_vm_insights[0].name}" = { + id = data.azurerm_monitor_data_collection_rule.collection_rule_vm_insights[0].id + } + + } : {} + +} diff --git a/03-Azure/01-03-Infrastructure/10_Oracle_on_Azure/resources/environment_setup/terraform/data_guard/modules/common_infrastructure/providers.tf b/03-Azure/01-03-Infrastructure/10_Oracle_on_Azure/resources/environment_setup/terraform/data_guard/modules/common_infrastructure/providers.tf new file mode 100644 index 000000000..ae8863f42 --- /dev/null +++ b/03-Azure/01-03-Infrastructure/10_Oracle_on_Azure/resources/environment_setup/terraform/data_guard/modules/common_infrastructure/providers.tf @@ -0,0 +1,24 @@ +terraform { + required_version = ">=1.6.0" + required_providers { + azurerm = { + source = "hashicorp/azurerm" + version = ">=3.11.0, <4.0" + } + azapi = { + source = "Azure/azapi" + version = "=1.8.0" + } + } +} + +provider "azurerm" { + features { + resource_group { + prevent_deletion_if_contains_resources = true + } + virtual_machine { + delete_os_disk_on_deletion = true + } + } +} diff --git a/03-Azure/01-03-Infrastructure/10_Oracle_on_Azure/resources/environment_setup/terraform/data_guard/modules/common_infrastructure/resource_lock.tf b/03-Azure/01-03-Infrastructure/10_Oracle_on_Azure/resources/environment_setup/terraform/data_guard/modules/common_infrastructure/resource_lock.tf new file mode 100644 index 000000000..e15a22bd5 --- /dev/null +++ b/03-Azure/01-03-Infrastructure/10_Oracle_on_Azure/resources/environment_setup/terraform/data_guard/modules/common_infrastructure/resource_lock.tf @@ -0,0 +1,27 @@ +resource "azurerm_management_lock" "subscription" { + count = length(var.subscription_locks) > 1 && length(try(var.subscription_locks.name, "")) > 0 ? 1 : 0 + name = var.subscription_locks.name + scope = data.azurerm_subscription.current.id + lock_level = var.subscription_locks.type +} + +resource "azurerm_management_lock" "resource_group" { + count = length(var.resource_group_locks) > 1 && length(try(var.resource_group_locks.name, "")) > 0 ? 1 : 0 + name = var.resource_group_locks.name + scope = data.azurerm_resource_group.rg.id + lock_level = var.resource_group_locks.type + + depends_on = [azurerm_resource_group.rg] +} + +resource "azurerm_management_lock" "storage_account_diagnostic" { + count = (length(var.resource_group_locks) > 1 && length(try(var.resource_group_locks.name, "")) > 0 && var.is_diagnostic_settings_enabled ) ? 1 : 0 + name = var.resource_group_locks.name + scope = data.azurerm_storage_account.diagnostic[0].id + lock_level = var.resource_group_locks.type + + depends_on = [azurerm_resource_group.rg, data.azurerm_storage_account.diagnostic] +} + +#ToDo: Add more locks for other resources + diff --git a/03-Azure/01-03-Infrastructure/10_Oracle_on_Azure/resources/environment_setup/terraform/data_guard/modules/common_infrastructure/role_assignments.tf b/03-Azure/01-03-Infrastructure/10_Oracle_on_Azure/resources/environment_setup/terraform/data_guard/modules/common_infrastructure/role_assignments.tf new file mode 100644 index 000000000..43603476f --- /dev/null +++ b/03-Azure/01-03-Infrastructure/10_Oracle_on_Azure/resources/environment_setup/terraform/data_guard/modules/common_infrastructure/role_assignments.tf @@ -0,0 +1,17 @@ +data "azurerm_client_config" "current" {} + +data "azurerm_role_definition" "builtin" { + for_each = var.role_assignments + name = each.value.name +} + +resource "azurerm_role_assignment" "assignment" { + for_each = var.role_assignments + role_definition_name = data.azurerm_role_definition.builtin[each.key].name + principal_id = data.azurerm_client_config.current.object_id + scope = try(each.value.scope, data.azurerm_subscription.current.id) + skip_service_principal_aad_check = try(each.value.skip_service_principal_aad_check, null) + description = try(each.value.description, null) + condition = try(each.value.condition, null) + condition_version = try(each.value.condition_version, null) +} diff --git a/03-Azure/01-03-Infrastructure/10_Oracle_on_Azure/resources/environment_setup/terraform/data_guard/modules/common_infrastructure/variables_global.tf b/03-Azure/01-03-Infrastructure/10_Oracle_on_Azure/resources/environment_setup/terraform/data_guard/modules/common_infrastructure/variables_global.tf new file mode 100644 index 000000000..aa85b1c1f --- /dev/null +++ b/03-Azure/01-03-Infrastructure/10_Oracle_on_Azure/resources/environment_setup/terraform/data_guard/modules/common_infrastructure/variables_global.tf @@ -0,0 +1,95 @@ +variable "infrastructure" {} + +variable "is_data_guard" { + description = "Whether Data Guard is enabled" + default = false +} + +variable "is_diagnostic_settings_enabled" { + description = "Whether diagnostic settings are enabled" + default = false +} + +variable "diagnostic_target" { + description = "The destination type of the diagnostic settings" + default = "Log_Analytics_Workspace" + validation { + condition = contains(["Log_Analytics_Workspace", "Storage_Account", "Event_Hubs", "Partner_Solutions"], var.diagnostic_target) + error_message = "Allowed values are Log_Analytics_Workspace, Storage_Account, Event_Hubs, Partner_Solutions" + } +} + +variable "eventhub_permission" { + description = "Authorization rule permissions for Event Hub" + default = { + listen = true + send = true + manage = true + } +} + +variable "log_destinations" { + type = map(object({ + type = string // E.g., "LogAnalytics", "EventHub", "StorageBlob" + resource_id = optional(string) // For Log Analytics, Event Hub, Storage Account + # workspace_id = optional(string) // For Log Analytics + # eventhub_id = optional(string) // For Event Hub + # storage_account_id = optional(string) // For Storage Account + container_name = optional(string) // For Blob container + name = string // Destination name within the DCR + })) + default = {} +} + + + + + +variable "logz_user" { + description = "Logz.io" + default = { + email = "user@example.com" + first_name = "Example" + last_name = "User" + phone_number = "+12313803556" + } +} + +variable "role_assignments" { + description = "Role assignments" + default = {} +} + +variable "subscription_locks" { + type = object({ + name = optional(string, "") + type = optional(string, "CanNotDelete") + }) + default = {} + validation { + condition = contains(["CanNotDelete", "ReadOnly"], var.subscription_locks.type) + error_message = "Lock type must be one of: CanNotDelete, ReadOnly." + } +} + +variable "resource_group_locks" { + type = object({ + name = optional(string, "") + type = optional(string, "CanNotDelete") + }) + default = {} + validation { + condition = contains(["CanNotDelete", "ReadOnly"], var.resource_group_locks.type) + error_message = "Lock type must be one of: CanNotDelete, ReadOnly." + } +} + +variable "availability_zone" { + description = "The availability zones of the resource" + default = null +} + +variable "tags" { + description = "Tags to be added to the resources" + default = {} +} diff --git a/03-Azure/01-03-Infrastructure/10_Oracle_on_Azure/resources/environment_setup/terraform/data_guard/modules/common_infrastructure/variables_local.tf b/03-Azure/01-03-Infrastructure/10_Oracle_on_Azure/resources/environment_setup/terraform/data_guard/modules/common_infrastructure/variables_local.tf new file mode 100644 index 000000000..f8a6cc21b --- /dev/null +++ b/03-Azure/01-03-Infrastructure/10_Oracle_on_Azure/resources/environment_setup/terraform/data_guard/modules/common_infrastructure/variables_local.tf @@ -0,0 +1,43 @@ +locals { + resource_group_exists = length(try(var.infrastructure.resource_group.arm_id, "")) > 0 + // If resource ID is specified extract the resourcegroup name from it otherwise read it either from input of create using the naming convention + rg_name = local.resource_group_exists ? ( + try(split("/", var.infrastructure.resource_group.arm_id))[4]) : ( + length(var.infrastructure.resource_group.name) > 0 ? ( + var.infrastructure.resource_group.name) : ( + format("%s-%s-%s-%s-%s", + "rg", + local.prefix, + "demo", + var.infrastructure.region, + "001" + ) + ) + ) + + // Resource group + prefix = "oracle" + + + law_destination_settings = var.is_diagnostic_settings_enabled && var.diagnostic_target == "Log_Analytics_Workspace" ? { Log_Analytics_Workspace = { + type = "Log_Analytics_Workspace" + resource_id = data.azurerm_log_analytics_workspace.diagnostic[0].id + name = data.azurerm_log_analytics_workspace.diagnostic[0].name + } } : {} + + storage_account_destination_settings = var.is_diagnostic_settings_enabled && var.diagnostic_target == "Storage_Account" ? { Storage_Account = { + type = "Storage_Account" + resource_id = data.azurerm_storage_account.diagnostic[0].id + container_name = data.azurerm_storage_account_sas.diagnostic[0].sas + name = data.azurerm_storage_account.diagnostic[0].name + } } : {} + + eventhub_destination_settings = var.is_diagnostic_settings_enabled && var.diagnostic_target == "Event_Hubs" ? { Event_Hubs = { + type = "Event_Hubs" + resource_id = azurerm_eventhub_namespace_authorization_rule.diagnostic[0].id + name = azurerm_eventhub_namespace_authorization_rule.diagnostic[0].name + } } : {} + + + tags = {} +} diff --git a/03-Azure/01-03-Infrastructure/10_Oracle_on_Azure/resources/environment_setup/terraform/data_guard/modules/compute/availability_set.tf b/03-Azure/01-03-Infrastructure/10_Oracle_on_Azure/resources/environment_setup/terraform/data_guard/modules/compute/availability_set.tf new file mode 100644 index 000000000..816c3fd28 --- /dev/null +++ b/03-Azure/01-03-Infrastructure/10_Oracle_on_Azure/resources/environment_setup/terraform/data_guard/modules/compute/availability_set.tf @@ -0,0 +1,17 @@ +resource "azurerm_availability_set" "oracle_vm" { + count = var.availability_zone == null ? 1 : 0 + name = "as-${count.index}" + location = var.location + resource_group_name = var.resource_group_name + + platform_fault_domain_count = 2 + +} + +data "azurerm_availability_set" "oracle_vm" { + count = var.availability_zone == null ? 1 : 0 + name = "as-${count.index}" + resource_group_name = var.resource_group_name + + depends_on = [azurerm_availability_set.oracle_vm] +} diff --git a/03-Azure/01-03-Infrastructure/10_Oracle_on_Azure/resources/environment_setup/terraform/data_guard/modules/compute/data.tf b/03-Azure/01-03-Infrastructure/10_Oracle_on_Azure/resources/environment_setup/terraform/data_guard/modules/compute/data.tf new file mode 100644 index 000000000..a526daaa6 --- /dev/null +++ b/03-Azure/01-03-Infrastructure/10_Oracle_on_Azure/resources/environment_setup/terraform/data_guard/modules/compute/data.tf @@ -0,0 +1,14 @@ +data "azurerm_virtual_machine" "oracle_vm_primary" { + name = module.avm-res-compute-virtualmachine[keys(local.vm_config_data_parameter)[0]].virtual_machine.name + resource_group_name = var.resource_group_name + + depends_on = [module.avm-res-compute-virtualmachine] +} + +data "azurerm_virtual_machine" "oracle_vms" { + for_each = { for vm in module.avm-res-compute-virtualmachine : vm.name => vm.virtual_machine } + name = each.value.name + resource_group_name = var.resource_group_name + + depends_on = [module.avm-res-compute-virtualmachine] +} diff --git a/03-Azure/01-03-Infrastructure/10_Oracle_on_Azure/resources/environment_setup/terraform/data_guard/modules/compute/monitoring_settings.tf b/03-Azure/01-03-Infrastructure/10_Oracle_on_Azure/resources/environment_setup/terraform/data_guard/modules/compute/monitoring_settings.tf new file mode 100644 index 000000000..44ce990ec --- /dev/null +++ b/03-Azure/01-03-Infrastructure/10_Oracle_on_Azure/resources/environment_setup/terraform/data_guard/modules/compute/monitoring_settings.tf @@ -0,0 +1,10 @@ +# Create Data Collection Rule Association for VM created +resource "azurerm_monitor_data_collection_rule_association" "dcra_vm_insights" { + # Create association for each data collection rule + for_each = { for key, val in var.data_collection_rules : key => val if(var.log_analytics_workspace != null && var.is_diagnostic_settings_enabled) } + + name = each.key + target_resource_id = data.azurerm_virtual_machine.oracle_vm_primary.id + data_collection_rule_id = each.value.id +} + diff --git a/03-Azure/01-03-Infrastructure/10_Oracle_on_Azure/resources/environment_setup/terraform/data_guard/modules/compute/outputs.tf b/03-Azure/01-03-Infrastructure/10_Oracle_on_Azure/resources/environment_setup/terraform/data_guard/modules/compute/outputs.tf new file mode 100644 index 000000000..81eb5373c --- /dev/null +++ b/03-Azure/01-03-Infrastructure/10_Oracle_on_Azure/resources/environment_setup/terraform/data_guard/modules/compute/outputs.tf @@ -0,0 +1,32 @@ +output "vm" { + value = data.azurerm_virtual_machine.oracle_vm_primary +} + +output "database_server_count" { + value = var.database_server_count +} + +output "availability_zone" { + value = var.availability_zone != null ? var.availability_zone : null +} + +output "oracle_vms" { + value = data.azurerm_virtual_machine.oracle_vms + sensitive = true +} + +output "vm_map_collection" { + value = { for vm in module.avm-res-compute-virtualmachine : vm.name => { + name = vm.name + id = vm.resource_id + public_ips = vm.public_ips + + } } + sensitive = false +} + + +output "vm_collection" { + value = flatten([for vm in module.avm-res-compute-virtualmachine : vm.name]) + sensitive = false +} diff --git a/03-Azure/01-03-Infrastructure/10_Oracle_on_Azure/resources/environment_setup/terraform/data_guard/modules/compute/variable_global.tf b/03-Azure/01-03-Infrastructure/10_Oracle_on_Azure/resources/environment_setup/terraform/data_guard/modules/compute/variable_global.tf new file mode 100644 index 000000000..cc53a8fe4 --- /dev/null +++ b/03-Azure/01-03-Infrastructure/10_Oracle_on_Azure/resources/environment_setup/terraform/data_guard/modules/compute/variable_global.tf @@ -0,0 +1,366 @@ +variable "database_server_count" { + description = "The number of database servers" + default = 1 + type = number +} + +variable "vm_name" { + description = "The name of the Oracle VM" + type = string +} + +# variable "resource_group" { +# description = "Details of the resource group" +# default = {} +# } + + +variable "resource_group_name" { + description = "Created resource group name" + type = string +} + +variable "location" { + description = "The location of the resource" + type = string +} + + + +variable "database" { + description = "Details of the database node" + type = object({ + use_DHCP = string + authentication = object({ + type = string + }) + }) + default = { + use_DHCP = true + authentication = { + type = "key" + } + } +} + +variable "nic_locks" { + type = object({ + name = optional(string, "") + type = optional(string, "CanNotDelete") + }) + default = {} + validation { + condition = contains(["CanNotDelete", "ReadOnly"], var.nic_locks.type) + error_message = "Lock type must be one of: CanNotDelete, ReadOnly." + } +} + +variable "aad_system_assigned_identity" { + description = "AAD system assigned identity" + type = bool +} + +variable "skip_service_principal_aad_check" { + type = bool + description = "If the principal_id is a newly provisioned `Service Principal` set this value to true to skip the Azure Active Directory check which may fail due to replication lag." + default = true +} + +variable "storage_account_id" { + description = "Storage account ID used for diagnostics" + type = string + default = null +} + +variable "storage_account_sas_token" { + description = "Storage account SAS token used for diagnostics" + type = string + default = null +} + +variable "log_analytics_workspace" { + type = object({ + id = string + name = string + }) + + description = "Log Analytics workspace" + default = null +} + +variable "eventhub_authorization_rule_id" { + description = "ID of an Event Hub authorization rule" + type = string + default = null +} + +variable "partner_solution_id" { + description = "Value of the partner solution ID" + default = null +} + +variable "is_diagnostic_settings_enabled" { + description = "Whether diagnostic settings are enabled" + default = false +} + +variable "diagnostic_target" { + description = "The destination type of the diagnostic settings" + default = "Log_Analytics_Workspace" + validation { + condition = contains(["Log_Analytics_Workspace", "Storage_Account", "Event_Hubs", "Partner_Solutions"], var.diagnostic_target) + error_message = "Allowed values are Log_Analytics_Workspace, Storage_Account, Event_Hubs, Partner_Solutions" + } +} + +variable "data_collection_rules" { + type = map(object({ + id = string + })) + description = "Data collection rules" + default = {} +} + +# variable "role_assignments" { +# description = "Role assignments" +# default = {} +# } + +variable "role_assignments" { + type = map(object({ + role_definition_id_or_name = string + principal_id = optional(string) + condition = optional(string) + condition_version = optional(string) + description = optional(string) + skip_service_principal_aad_check = optional(bool, true) + delegated_managed_identity_resource_id = optional(string) + } + )) + default = {} +} + +variable "vm_lock" { + type = object({ + name = optional(string, null) + kind = optional(string, "None") + }) + default = {} + description = < { + name = ipconfig.name + private_ip_subnet_resource_id = ipconfig.subnet_id + create_public_ip_address = ipconfig.create_public_ip_address + public_ip_address_resource_id = ipconfig.public_ip_address_resource_id + public_ip_address_name = ipconfig.create_public_ip_address ? "${var.vm_name}-pip" : "" + private_ip_address_allocation = ipconfig.private_ip_address_allocation + is_primary_ipconfiguration = ipconfig.primary + private_ip_address = var.database.use_DHCP ? ipconfig.nic_ips[0] : "" + } + } + + # role_assignments_nic_parameter = {for key, value in var.role_assignments_nic : key => { + # principal_id = value.principal_id + # role_definition_id_or_name = value.role_definition_id_or_name + # assign_to_child_public_ip_addresses = true + # skip_service_principal_aad_check = value.skip_service_principal_aad_check + # } + + + + vm_default_config_data = { + "vm-0" = { + name = var.vm_name + os_type = "Linux" + generate_admin_password_or_ssh_key = false + enable_auth_password = local.enable_auth_password + admin_username = var.sid_username + admin_ssh_keys = { + username = var.sid_username + public_key = var.public_key + } + source_image_reference = var.vm_source_image_reference + virtualmachine_sku_size = var.vm_sku + os_disk = var.vm_os_disk + availability_zone = var.availability_zone + enable_telemetry = var.enable_telemetry + user_assigned_identity_id = var.vm_user_assigned_identity_id + role_assignments = var.role_assignments + skip_service_principal_aad_check = var.skip_service_principal_aad_check + + #Network Interfaces + network_interfaces = { + + network_interface_1 = { + name = "oraclevmnic-${var.vm_name}" + location = var.location + resource_group_name = var.resource_group_name + tags = merge(local.tags, var.tags) + accelerated_networking_enabled = true + + ip_configurations = local.network_interface_ipconfigs + + #ToDo: role_assignments_nic_parameter + # role_assignments = { + # role_assignment_1 = { + # role_definition_id_or_name = "Contributor" + # principal_id = data.azurerm_client_config.current.object_id + # skip_service_principal_aad_check = var.skip_service_principal_aad_check + # } + # } + + + } + } + } + } + + + # Variable with the data to create the Oracle VM + vm_config_data_parameter = merge(var.vm_config_data, local.vm_default_config_data) + + +} diff --git a/03-Azure/01-03-Infrastructure/10_Oracle_on_Azure/resources/environment_setup/terraform/data_guard/modules/compute/vm.tf b/03-Azure/01-03-Infrastructure/10_Oracle_on_Azure/resources/environment_setup/terraform/data_guard/modules/compute/vm.tf new file mode 100644 index 000000000..6596fe074 --- /dev/null +++ b/03-Azure/01-03-Infrastructure/10_Oracle_on_Azure/resources/environment_setup/terraform/data_guard/modules/compute/vm.tf @@ -0,0 +1,45 @@ +######################################################################################### +# # +# Virtual Machine # +# # +######################################################################################### + + +module "avm-res-compute-virtualmachine" { + source = "Azure/avm-res-compute-virtualmachine/azurerm" + version = "0.17.0" + for_each = local.vm_config_data_parameter + + + name = each.value.name + location = var.location + resource_group_name = var.resource_group_name + os_type = each.value.os_type + + generate_admin_password_or_ssh_key = each.value.generate_admin_password_or_ssh_key + disable_password_authentication = !each.value.enable_auth_password #!local.enable_auth_password #should be true + admin_username = each.value.admin_username + admin_ssh_keys = [each.value.admin_ssh_keys] + source_image_reference = each.value.source_image_reference + sku_size = each.value.virtualmachine_sku_size + os_disk = each.value.os_disk + extensions = var.vm_extensions + network_interfaces = each.value.network_interfaces + + + zone = each.value.availability_zone + availability_set_resource_id = var.availability_zone == null ? data.azurerm_availability_set.oracle_vm[0].id : null + tags = merge(local.tags, var.tags) + + + + managed_identities = { + system_assigned = var.aad_system_assigned_identity + user_assigned_resource_ids = [each.value.user_assigned_identity_id] + } + + role_assignments = each.value.role_assignments +} + + + diff --git a/03-Azure/01-03-Infrastructure/10_Oracle_on_Azure/resources/environment_setup/terraform/data_guard/modules/network/diagnostic_settings.tf b/03-Azure/01-03-Infrastructure/10_Oracle_on_Azure/resources/environment_setup/terraform/data_guard/modules/network/diagnostic_settings.tf new file mode 100644 index 000000000..46e6a34d2 --- /dev/null +++ b/03-Azure/01-03-Infrastructure/10_Oracle_on_Azure/resources/environment_setup/terraform/data_guard/modules/network/diagnostic_settings.tf @@ -0,0 +1,145 @@ + +#ToDo: Should be replicated on VM Module +# resource "azurerm_monitor_diagnostic_setting" "nic" { +# count = var.is_diagnostic_settings_enabled ? 1 : 0 +# name = "nic-${count.index}-diag" +# target_resource_id = azurerm_network_interface.oracle_db[count.index].id +# storage_account_id = var.diagnostic_target == "Storage_Account" ? var.storage_account_id : null +# log_analytics_workspace_id = var.diagnostic_target == "Log_Analytics_Workspace" ? var.log_analytics_workspace_id : null +# eventhub_authorization_rule_id = var.diagnostic_target == "Event_Hubs" ? var.eventhub_authorization_rule_id : null +# partner_solution_id = var.diagnostic_target == "Partner_Solutions" ? var.partner_solution_id : null + +# metric { +# category = "AllMetrics" +# retention_policy { +# enabled = false +# } +# } +# } + +resource "azurerm_monitor_diagnostic_setting" "nsg" { + count = var.is_diagnostic_settings_enabled ? 1 : 0 + name = "nsg" + target_resource_id = azurerm_network_security_group.blank.id + storage_account_id = var.diagnostic_target == "Storage_Account" ? var.storage_account_id : null + log_analytics_workspace_id = var.diagnostic_target == "Log_Analytics_Workspace" ? var.log_analytics_workspace_id : null + eventhub_authorization_rule_id = var.diagnostic_target == "Event_Hubs" ? var.eventhub_authorization_rule_id : null + partner_solution_id = var.diagnostic_target == "Partner_Solutions" ? var.partner_solution_id : null + + dynamic "enabled_log" { + for_each = toset(data.azurerm_monitor_diagnostic_categories.nsg[count.index].log_category_types) + content { + category = enabled_log.value + retention_policy { + enabled = false + } + } + } +} + +#ToDo: It does not work +# resource "azurerm_monitor_diagnostic_setting" "pip" { +# count = var.is_diagnostic_settings_enabled ? var.is_data_guard ? 2 : 1 : 0 +# name = "pip" +# target_resource_id = azurerm_public_ip.vm_pip[count.index].id +# storage_account_id = var.diagnostic_target == "Storage_Account" ? var.storage_account_id : null +# log_analytics_workspace_id = var.diagnostic_target == "Log_Analytics_Workspace" ? var.log_analytics_workspace_id : null +# eventhub_authorization_rule_id = var.diagnostic_target == "Event_Hubs" ? var.eventhub_authorization_rule_id : null +# partner_solution_id = var.diagnostic_target == "Partner_Solutions" ? var.partner_solution_id : null + +# dynamic "enabled_log" { +# for_each = toset(data.azurerm_monitor_diagnostic_categories.pip[count.index].log_category_types) +# content { +# category = enabled_log.value +# retention_policy { +# enabled = false +# } +# } +# } + +# metric { +# category = "AllMetrics" +# retention_policy { +# enabled = false +# } +# } +# } + +resource "azurerm_monitor_diagnostic_setting" "vnet" { + count = var.is_diagnostic_settings_enabled ? 1 : 0 + name = "vnet" + target_resource_id = data.azurerm_virtual_network.vnet_oracle[count.index].id + storage_account_id = var.diagnostic_target == "Storage_Account" ? var.storage_account_id : null + log_analytics_workspace_id = var.diagnostic_target == "Log_Analytics_Workspace" ? var.log_analytics_workspace_id : null + eventhub_authorization_rule_id = var.diagnostic_target == "Event_Hubs" ? var.eventhub_authorization_rule_id : null + partner_solution_id = var.diagnostic_target == "Partner_Solutions" ? var.partner_solution_id : null + + dynamic "enabled_log" { + for_each = toset(data.azurerm_monitor_diagnostic_categories.vnet[count.index].log_category_types) + content { + category = enabled_log.value + retention_policy { + enabled = false + } + } + } + + metric { + category = "AllMetrics" + retention_policy { + enabled = false + } + } +} + +# data "azurerm_monitor_diagnostic_categories" "nic" { +# count = var.is_diagnostic_settings_enabled ? 1 : 0 +# resource_id = data.azurerm_network_interface.nic[count.index].id +# } + +data "azurerm_monitor_diagnostic_categories" "nsg" { + count = var.is_diagnostic_settings_enabled ? 1 : 0 + resource_id = data.azurerm_network_security_group.nsg[count.index].id +} + +data "azurerm_monitor_diagnostic_categories" "pip" { + count = var.is_diagnostic_settings_enabled ? 1 : 0 + resource_id = data.azurerm_public_ip.pip[count.index].id +} + +data "azurerm_monitor_diagnostic_categories" "vnet" { + count = var.is_diagnostic_settings_enabled ? 1 : 0 + resource_id = data.azurerm_virtual_network.vnet[count.index].id +} + +# data "azurerm_network_interface" "nic" { +# count = var.is_data_guard ? 2 : 1 +# name = "oraclevmnic-${count.index}" +# resource_group_name = var.resource_group.name + +# depends_on = [azurerm_network_interface.oracle_db] +# } + +data "azurerm_network_security_group" "nsg" { + count = 1 + name = "blank" + resource_group_name = var.resource_group.name + + depends_on = [azurerm_network_security_group.blank] +} + +data "azurerm_public_ip" "pip" { + count = var.is_data_guard ? 2 : 1 + name = "vmpip-${count.index}" + resource_group_name = var.resource_group.name + + depends_on = [azurerm_public_ip.vm_pip] +} + +data "azurerm_virtual_network" "vnet" { + count = 1 + name = local.vnet_oracle_name + resource_group_name = var.resource_group.name + + depends_on = [module.vnet] +} \ No newline at end of file diff --git a/03-Azure/01-03-Infrastructure/10_Oracle_on_Azure/resources/environment_setup/terraform/data_guard/modules/network/nsg.tf b/03-Azure/01-03-Infrastructure/10_Oracle_on_Azure/resources/environment_setup/terraform/data_guard/modules/network/nsg.tf new file mode 100644 index 000000000..d1d7dab5b --- /dev/null +++ b/03-Azure/01-03-Infrastructure/10_Oracle_on_Azure/resources/environment_setup/terraform/data_guard/modules/network/nsg.tf @@ -0,0 +1,26 @@ +######################################################################################### +# # +# Network Security Group # +# # +######################################################################################### +resource "azurerm_network_security_group" "blank" { + name = "blank" + location = var.resource_group.location + resource_group_name = var.resource_group.name + + tags = merge(local.tags, var.tags) +} + +resource "azurerm_subnet_network_security_group_association" "ssh" { + subnet_id = data.azurerm_subnet.subnet_oracle[0].id + network_security_group_id = azurerm_network_security_group.blank.id +} + +data "azurerm_network_security_group" "blank" { + name = "blank" + resource_group_name = var.resource_group.name + + depends_on = [azurerm_network_security_group.blank] +} + + diff --git a/03-Azure/01-03-Infrastructure/10_Oracle_on_Azure/resources/environment_setup/terraform/data_guard/modules/network/outputs.tf b/03-Azure/01-03-Infrastructure/10_Oracle_on_Azure/resources/environment_setup/terraform/data_guard/modules/network/outputs.tf new file mode 100644 index 000000000..49b5ba02a --- /dev/null +++ b/03-Azure/01-03-Infrastructure/10_Oracle_on_Azure/resources/environment_setup/terraform/data_guard/modules/network/outputs.tf @@ -0,0 +1,20 @@ +############################################################################### +# # +# Network # +# # +############################################################################### +output "network_location" { + value = data.azurerm_virtual_network.vnet_oracle[0].location +} + +output "db_subnet" { + value = data.azurerm_subnet.subnet_oracle[0] +} + +output "db_server_puplic_ip" { + value = azurerm_public_ip.vm_pip[0].ip_address +} + +output "db_server_puplic_ip_resources" { + value = azurerm_public_ip.vm_pip +} diff --git a/03-Azure/01-03-Infrastructure/10_Oracle_on_Azure/resources/environment_setup/terraform/data_guard/modules/network/pip.tf b/03-Azure/01-03-Infrastructure/10_Oracle_on_Azure/resources/environment_setup/terraform/data_guard/modules/network/pip.tf new file mode 100644 index 000000000..5c9c31d39 --- /dev/null +++ b/03-Azure/01-03-Infrastructure/10_Oracle_on_Azure/resources/environment_setup/terraform/data_guard/modules/network/pip.tf @@ -0,0 +1,24 @@ +######################################################################################### +# # +# Public IPs # +# # +######################################################################################### + +resource "azurerm_public_ip" "vm_pip" { + count = var.is_data_guard ? 2 : 1 + name = "vmpip-${count.index}" + location = var.resource_group.location + resource_group_name = var.resource_group.name + allocation_method = "Static" + sku = "Standard" + + tags = merge(local.tags, var.tags) +} + +data "azurerm_public_ip" "vm_pip" { + count = var.is_data_guard ? 2 : 1 + name = "vmpip-${count.index}" + resource_group_name = var.resource_group.name + + depends_on = [azurerm_public_ip.vm_pip] +} diff --git a/03-Azure/01-03-Infrastructure/10_Oracle_on_Azure/resources/environment_setup/terraform/data_guard/modules/network/providers.tf b/03-Azure/01-03-Infrastructure/10_Oracle_on_Azure/resources/environment_setup/terraform/data_guard/modules/network/providers.tf new file mode 100644 index 000000000..c9561f7e8 --- /dev/null +++ b/03-Azure/01-03-Infrastructure/10_Oracle_on_Azure/resources/environment_setup/terraform/data_guard/modules/network/providers.tf @@ -0,0 +1,24 @@ +terraform { + required_version = ">=1.2" + required_providers { + azurerm = { + source = "hashicorp/azurerm" + version = ">=3.11.0, <4.0" + } + azapi = { + source = "Azure/azapi" + version = "=1.8.0" + } + } +} + +provider "azurerm" { + features { + resource_group { + prevent_deletion_if_contains_resources = true + } + virtual_machine { + delete_os_disk_on_deletion = true + } + } +} diff --git a/03-Azure/01-03-Infrastructure/10_Oracle_on_Azure/resources/environment_setup/terraform/data_guard/modules/network/resource_lock.tf b/03-Azure/01-03-Infrastructure/10_Oracle_on_Azure/resources/environment_setup/terraform/data_guard/modules/network/resource_lock.tf new file mode 100644 index 000000000..3e83d1603 --- /dev/null +++ b/03-Azure/01-03-Infrastructure/10_Oracle_on_Azure/resources/environment_setup/terraform/data_guard/modules/network/resource_lock.tf @@ -0,0 +1,27 @@ + +resource "azurerm_management_lock" "nsg" { + count = length(var.nsg_locks) > 1 && length(try(var.nsg_locks.name, "")) > 0 ? 1 : 0 + name = var.nsg_locks.name + scope = data.azurerm_network_security_group.blank.id + lock_level = var.nsg_locks.type + + depends_on = [azurerm_network_security_group.blank] +} + +resource "azurerm_management_lock" "vnet" { + count = length(var.vnet_locks) > 1 && length(try(var.vnet_locks.name, "")) > 0 ? 1 : 0 + name = var.vnet_locks.name + scope = data.azurerm_virtual_network.vnet_oracle[0].id + lock_level = var.vnet_locks.type + + depends_on = [data.azurerm_virtual_network.vnet_oracle] +} + +resource "azurerm_management_lock" "subnet" { + count = length(var.subnet_locks) > 1 && length(try(var.subnet_locks.name, "")) > 0 ? 1 : 0 + name = var.subnet_locks.name + scope = data.azurerm_subnet.subnet_oracle[0].id + lock_level = var.subnet_locks.type + + depends_on = [data.azurerm_subnet.subnet_oracle] +} diff --git a/03-Azure/01-03-Infrastructure/10_Oracle_on_Azure/resources/environment_setup/terraform/data_guard/modules/network/role_assignments.tf b/03-Azure/01-03-Infrastructure/10_Oracle_on_Azure/resources/environment_setup/terraform/data_guard/modules/network/role_assignments.tf new file mode 100644 index 000000000..93654a6ee --- /dev/null +++ b/03-Azure/01-03-Infrastructure/10_Oracle_on_Azure/resources/environment_setup/terraform/data_guard/modules/network/role_assignments.tf @@ -0,0 +1,82 @@ +data "azurerm_client_config" "current" {} + +# data "azurerm_role_definition" "nic" { +# for_each = var.role_assignments_nic +# name = each.value.name +# } + +data "azurerm_role_definition" "pip" { + for_each = var.role_assignments_pip + name = each.value.name +} + +data "azurerm_role_definition" "nsg" { + for_each = var.role_assignments_nsg + name = each.value.name +} + +data "azurerm_role_definition" "vnet" { + for_each = var.role_assignments_vnet + name = each.value.name +} + +data "azurerm_role_definition" "subnet" { + for_each = var.role_assignments_subnet + name = each.value.name +} + + +# resource "azurerm_role_assignment" "nic" { +# for_each = var.role_assignments_nic +# role_definition_name = data.azurerm_role_definition.nic[each.key].name +# principal_id = data.azurerm_client_config.current.object_id +# scope = try(each.value.scope, data.azurerm_network_interface.oracle_db[0].id) +# skip_service_principal_aad_check = try(each.value.skip_service_principal_aad_check, false) +# description = try(each.value.description, null) +# condition = try(each.value.condition, null) +# condition_version = try(each.value.condition_version, null) +# } + +resource "azurerm_role_assignment" "pip" { + for_each = var.role_assignments_pip + role_definition_name = data.azurerm_role_definition.pip[each.key].name + principal_id = data.azurerm_client_config.current.object_id + scope = try(each.value.scope, data.azurerm_public_ip.vm_pip[0].id) + skip_service_principal_aad_check = try(each.value.skip_service_principal_aad_check, false) + description = try(each.value.description, null) + condition = try(each.value.condition, null) + condition_version = try(each.value.condition_version, null) +} + +resource "azurerm_role_assignment" "nsg" { + for_each = var.role_assignments_nsg + role_definition_name = data.azurerm_role_definition.nsg[each.key].name + principal_id = data.azurerm_client_config.current.object_id + scope = try(each.value.scope, data.azurerm_network_security_group.blank.id) + skip_service_principal_aad_check = try(each.value.skip_service_principal_aad_check, false) + description = try(each.value.description, null) + condition = try(each.value.condition, null) + condition_version = try(each.value.condition_version, null) +} + +resource "azurerm_role_assignment" "vnet" { + for_each = var.role_assignments_vnet + role_definition_name = data.azurerm_role_definition.vnet[each.key].name + principal_id = data.azurerm_client_config.current.object_id + scope = try(each.value.scope, data.azurerm_virtual_network.vnet_oracle[0].id) + skip_service_principal_aad_check = try(each.value.skip_service_principal_aad_check, false) + description = try(each.value.description, null) + condition = try(each.value.condition, null) + condition_version = try(each.value.condition_version, null) +} + +resource "azurerm_role_assignment" "subnet" { + for_each = var.role_assignments_subnet + role_definition_name = data.azurerm_role_definition.subnet[each.key].name + principal_id = data.azurerm_client_config.current.object_id + scope = try(each.value.scope, data.azurerm_subnet.subnet_oracle[0].id) + skip_service_principal_aad_check = try(each.value.skip_service_principal_aad_check, false) + description = try(each.value.description, null) + condition = try(each.value.condition, null) + condition_version = try(each.value.condition_version, null) +} diff --git a/03-Azure/01-03-Infrastructure/10_Oracle_on_Azure/resources/environment_setup/terraform/data_guard/modules/network/variables_global.tf b/03-Azure/01-03-Infrastructure/10_Oracle_on_Azure/resources/environment_setup/terraform/data_guard/modules/network/variables_global.tf new file mode 100644 index 000000000..12a43dedb --- /dev/null +++ b/03-Azure/01-03-Infrastructure/10_Oracle_on_Azure/resources/environment_setup/terraform/data_guard/modules/network/variables_global.tf @@ -0,0 +1,128 @@ +variable "resource_group" { + type = object({ + name = string + location = string + id = string + }) + description = "Details of the resource group" + default = null +} + +variable "diagnostic_target" { + type = string + description = "The destination type of the diagnostic settings" + default = "Log_Analytics_Workspace" + validation { + condition = contains(["Log_Analytics_Workspace", "Storage_Account", "Event_Hubs", "Partner_Solutions"], var.diagnostic_target) + error_message = "Allowed values are Log_Analytics_Workspace, Storage_Account, Event_Hubs, Partner_Solutions" + } +} + +variable "storage_account_id" { + description = "Storage account ID used for diagnostics" + type = string + default = null +} + +variable "log_analytics_workspace_id" { + description = "Log Analytics workspace ID" + type = string + default = null +} + +variable "eventhub_authorization_rule_id" { + description = "ID of an Event Hub authorization rule" + type = string + default = null +} + +variable "partner_solution_id" { + type = string + description = "Value of the partner solution ID" + default = null +} + +variable "is_diagnostic_settings_enabled" { + type = bool + description = "Whether diagnostic settings are enabled" + default = false +} + +variable "role_assignments_pip" { + type = map(object({ + name = string + })) + description = "Role assignments scoped to the public IP address" +} + +variable "role_assignments_nsg" { + type = map(object({ + name = string + })) + description = "Role assignments scoped to the network security group" + default = {} +} + +variable "role_assignments_vnet" { + type = map(object({ + name = string + })) + description = "Role assignments scoped to the virtual network" + default = {} +} + +variable "role_assignments_subnet" { + type = map(object({ + name = string + })) + description = "Role assignments scoped to the subnet" + default = {} +} + +variable "nsg_locks" { + type = object({ + name = optional(string, "") + type = optional(string, "CanNotDelete") + }) + default = {} + validation { + condition = contains(["CanNotDelete", "ReadOnly"], var.nsg_locks.type) + error_message = "Lock type must be one of: CanNotDelete, ReadOnly." + } +} + +variable "vnet_locks" { + type = object({ + name = optional(string, "") + type = optional(string, "CanNotDelete") + }) + default = {} + validation { + condition = contains(["CanNotDelete", "ReadOnly"], var.vnet_locks.type) + error_message = "Lock type must be one of: CanNotDelete, ReadOnly." + } +} + +variable "subnet_locks" { + type = object({ + name = optional(string, "") + type = optional(string, "CanNotDelete") + }) + default = {} + validation { + condition = contains(["CanNotDelete", "ReadOnly"], var.subnet_locks.type) + error_message = "Lock type must be one of: CanNotDelete, ReadOnly." + } +} + +variable "is_data_guard" { + type = bool + description = "Whether Data Guard is enabled" + default = false +} + +variable "tags" { + type = map(any) + description = "Tags to be added to the resources" + default = {} +} diff --git a/03-Azure/01-03-Infrastructure/10_Oracle_on_Azure/resources/environment_setup/terraform/data_guard/modules/network/variables_local.tf b/03-Azure/01-03-Infrastructure/10_Oracle_on_Azure/resources/environment_setup/terraform/data_guard/modules/network/variables_local.tf new file mode 100644 index 000000000..1d32d1016 --- /dev/null +++ b/03-Azure/01-03-Infrastructure/10_Oracle_on_Azure/resources/environment_setup/terraform/data_guard/modules/network/variables_local.tf @@ -0,0 +1,13 @@ +locals { + vnet_oracle_name = "vnet1" + database_subnet_name = "subnet1" + vnet_oracle_addr = "10.0.0.0/16" + database_subnet_prefix = "10.0.0.0/24" + + vnet_oracle_arm_id = try(local.vnet_oracle_name.arm_id, "") + vnet_oracle_exists = length(local.vnet_oracle_arm_id) > 0 + subnet_oracle_arm_id = try(local.database_subnet_name.arm_id, "") + subnet_oracle_exists = length(local.subnet_oracle_arm_id) > 0 + + tags = {} +} diff --git a/03-Azure/01-03-Infrastructure/10_Oracle_on_Azure/resources/environment_setup/terraform/data_guard/modules/network/vnet_main.tf b/03-Azure/01-03-Infrastructure/10_Oracle_on_Azure/resources/environment_setup/terraform/data_guard/modules/network/vnet_main.tf new file mode 100644 index 000000000..9c7548304 --- /dev/null +++ b/03-Azure/01-03-Infrastructure/10_Oracle_on_Azure/resources/environment_setup/terraform/data_guard/modules/network/vnet_main.tf @@ -0,0 +1,37 @@ +module "vnet" { + source = "Azure/avm-res-network-virtualnetwork/azurerm" + version = "0.1.3" + + resource_group_name = var.resource_group.name + vnet_location = var.resource_group.location + vnet_name = local.vnet_oracle_name + virtual_network_address_space = [local.vnet_oracle_addr] + subnets = { + subnet1 = { + address_prefixes = [local.database_subnet_prefix] + azurerm_network_security_group = { + id = azurerm_network_security_group.blank.id + } + } + } + + tags = merge(local.tags, var.tags) +} + + +data "azurerm_virtual_network" "vnet_oracle" { + count = local.vnet_oracle_exists ? 0 : 1 + name = local.vnet_oracle_name + resource_group_name = var.resource_group.name + + depends_on = [module.vnet] +} + +data "azurerm_subnet" "subnet_oracle" { + count = local.subnet_oracle_exists ? 0 : 1 + name = local.database_subnet_name + resource_group_name = var.resource_group.name + virtual_network_name = data.azurerm_virtual_network.vnet_oracle[count.index].name + + depends_on = [module.vnet] +} diff --git a/03-Azure/01-03-Infrastructure/10_Oracle_on_Azure/resources/environment_setup/terraform/data_guard/modules/storage/data_disk.tf b/03-Azure/01-03-Infrastructure/10_Oracle_on_Azure/resources/environment_setup/terraform/data_guard/modules/storage/data_disk.tf new file mode 100644 index 000000000..18d437046 --- /dev/null +++ b/03-Azure/01-03-Infrastructure/10_Oracle_on_Azure/resources/environment_setup/terraform/data_guard/modules/storage/data_disk.tf @@ -0,0 +1,83 @@ +resource "azurerm_managed_disk" "data_disk" { + count = length(local.data_disks) + name = "${var.naming}-data-${count.index}" + location = var.resource_group.location + resource_group_name = var.resource_group.name + storage_account_type = var.disk_type + create_option = local.data_disks[count.index].create_option + disk_size_gb = local.data_disks[count.index].disk_size_gb + zone = var.availability_zone + + tags = merge(local.tags, var.tags) +} + +resource "azurerm_managed_disk" "asm_disk" { + count = length(local.asm_disks) + name = "${var.naming}-asm-${count.index}" + location = var.resource_group.location + resource_group_name = var.resource_group.name + storage_account_type = var.disk_type + create_option = local.asm_disks[count.index].create_option + disk_size_gb = local.asm_disks[count.index].disk_size_gb + zone = var.availability_zone + + tags = merge(local.tags, var.tags) +} + +resource "azurerm_managed_disk" "redo_disk" { + count = length(local.redo_disks) + name = "${var.naming}-redo-${count.index}" + location = var.resource_group.location + resource_group_name = var.resource_group.name + storage_account_type = var.disk_type + create_option = local.redo_disks[count.index].create_option + disk_size_gb = local.redo_disks[count.index].disk_size_gb + zone = var.availability_zone + + tags = merge(local.tags, var.tags) +} + +resource "azurerm_virtual_machine_data_disk_attachment" "data_disk_attachment" { + count = length(local.data_disks) + managed_disk_id = azurerm_managed_disk.data_disk[count.index].id + virtual_machine_id = var.vm.id + caching = local.data_disks[count.index].caching + write_accelerator_enabled = local.data_disks[count.index].write_accelerator_enabled + lun = local.data_disks[count.index].lun +} + +resource "azurerm_virtual_machine_data_disk_attachment" "asm_disk_attachment" { + count = length(local.asm_disks) + managed_disk_id = azurerm_managed_disk.asm_disk[count.index].id + virtual_machine_id = var.vm.id + caching = local.asm_disks[count.index].caching + write_accelerator_enabled = local.asm_disks[count.index].write_accelerator_enabled + lun = local.asm_disks[count.index].lun +} + +resource "azurerm_virtual_machine_data_disk_attachment" "redo_disk_attachment" { + count = length(local.redo_disks) + managed_disk_id = azurerm_managed_disk.redo_disk[count.index].id + virtual_machine_id = var.vm.id + caching = local.redo_disks[count.index].caching + write_accelerator_enabled = local.redo_disks[count.index].write_accelerator_enabled + lun = local.redo_disks[count.index].lun +} + +data "azurerm_managed_disk" "data_disk" { + count = length(local.data_disks) + name = azurerm_managed_disk.data_disk[count.index].name + resource_group_name = var.resource_group.name +} + +data "azurerm_managed_disk" "asm_disk" { + count = length(local.asm_disks) + name = azurerm_managed_disk.asm_disk[count.index].name + resource_group_name = var.resource_group.name +} + +data "azurerm_managed_disk" "redo_disk" { + count = length(local.redo_disks) + name = azurerm_managed_disk.redo_disk[count.index].name + resource_group_name = var.resource_group.name +} diff --git a/03-Azure/01-03-Infrastructure/10_Oracle_on_Azure/resources/environment_setup/terraform/data_guard/modules/storage/outputs.tf b/03-Azure/01-03-Infrastructure/10_Oracle_on_Azure/resources/environment_setup/terraform/data_guard/modules/storage/outputs.tf new file mode 100644 index 000000000..5a50b7284 --- /dev/null +++ b/03-Azure/01-03-Infrastructure/10_Oracle_on_Azure/resources/environment_setup/terraform/data_guard/modules/storage/outputs.tf @@ -0,0 +1,24 @@ +output "data_disks" { + value = local.data_disks +} + +output "asm_disks" { + value = local.asm_disks +} + +output "redo_disks" { + value = local.redo_disks +} + + +output "data_disks_resource" { + value = data.azurerm_managed_disk.data_disk +} + +output "asm_disks_resource" { + value = data.azurerm_managed_disk.asm_disk +} + +output "redo_disks_resource" { + value = data.azurerm_managed_disk.redo_disk +} \ No newline at end of file diff --git a/03-Azure/01-03-Infrastructure/10_Oracle_on_Azure/resources/environment_setup/terraform/data_guard/modules/storage/providers.tf b/03-Azure/01-03-Infrastructure/10_Oracle_on_Azure/resources/environment_setup/terraform/data_guard/modules/storage/providers.tf new file mode 100644 index 000000000..c9561f7e8 --- /dev/null +++ b/03-Azure/01-03-Infrastructure/10_Oracle_on_Azure/resources/environment_setup/terraform/data_guard/modules/storage/providers.tf @@ -0,0 +1,24 @@ +terraform { + required_version = ">=1.2" + required_providers { + azurerm = { + source = "hashicorp/azurerm" + version = ">=3.11.0, <4.0" + } + azapi = { + source = "Azure/azapi" + version = "=1.8.0" + } + } +} + +provider "azurerm" { + features { + resource_group { + prevent_deletion_if_contains_resources = true + } + virtual_machine { + delete_os_disk_on_deletion = true + } + } +} diff --git a/03-Azure/01-03-Infrastructure/10_Oracle_on_Azure/resources/environment_setup/terraform/data_guard/modules/storage/resource_lock.tf b/03-Azure/01-03-Infrastructure/10_Oracle_on_Azure/resources/environment_setup/terraform/data_guard/modules/storage/resource_lock.tf new file mode 100644 index 000000000..cb4c1be3f --- /dev/null +++ b/03-Azure/01-03-Infrastructure/10_Oracle_on_Azure/resources/environment_setup/terraform/data_guard/modules/storage/resource_lock.tf @@ -0,0 +1,8 @@ +resource "azurerm_management_lock" "data_disk" { + count = length(var.data_disk_locks) > 1 && length(try(var.data_disk_locks.name, "")) > 1 ? 1 : 0 + name = var.data_disk_locks.name + scope = data.azurerm_managed_disk.data_disk[0].id + lock_level = var.data_disk_locks.type + + depends_on = [azurerm_managed_disk.data_disk] +} diff --git a/03-Azure/01-03-Infrastructure/10_Oracle_on_Azure/resources/environment_setup/terraform/data_guard/modules/storage/role_assignments.tf b/03-Azure/01-03-Infrastructure/10_Oracle_on_Azure/resources/environment_setup/terraform/data_guard/modules/storage/role_assignments.tf new file mode 100644 index 000000000..d7aff7956 --- /dev/null +++ b/03-Azure/01-03-Infrastructure/10_Oracle_on_Azure/resources/environment_setup/terraform/data_guard/modules/storage/role_assignments.tf @@ -0,0 +1,17 @@ +data "azurerm_client_config" "current" {} + +data "azurerm_role_definition" "builtin" { + for_each = var.role_assignments + name = each.value.name +} + +resource "azurerm_role_assignment" "assignment" { + for_each = var.role_assignments + role_definition_name = data.azurerm_role_definition.builtin[each.key].name + principal_id = data.azurerm_client_config.current.object_id + scope = try(each.value.scope, data.azurerm_managed_disk.data_disk[0].id) + skip_service_principal_aad_check = try(each.value.skip_service_principal_aad_check, false) + description = try(each.value.description, null) + condition = try(each.value.condition, null) + condition_version = try(each.value.condition_version, null) +} diff --git a/03-Azure/01-03-Infrastructure/10_Oracle_on_Azure/resources/environment_setup/terraform/data_guard/modules/storage/variables_global.tf b/03-Azure/01-03-Infrastructure/10_Oracle_on_Azure/resources/environment_setup/terraform/data_guard/modules/storage/variables_global.tf new file mode 100644 index 000000000..69ee40511 --- /dev/null +++ b/03-Azure/01-03-Infrastructure/10_Oracle_on_Azure/resources/environment_setup/terraform/data_guard/modules/storage/variables_global.tf @@ -0,0 +1,92 @@ +variable "naming" { + description = "Defines the names for the resources" +} + +variable "vm" { + description = "Virtual machine name" +} + +variable "resource_group" { + description = "Details of the resource group" + default = {} +} + +variable "disk_type" { + description = "The type of the storage account" + default = "Premium_LRS" + validation { + condition = contains(["Standard_LRS", "StandardSSD_ZRS", "Premium_LRS", "PremiumV2_LRS", "Premium_ZRS", "StandardSSD_LRS", "UltraSSD_LRS"], var.disk_type) + error_message = "Allowed values are Standard_LRS, StandardSSD_ZRS, Premium_LRS, PremiumV2_LRS, Premium_ZRS, StandardSSD_LRS, UltraSSD_LRS" + } +} + +variable "database_disks_options" { + description = "Details of the database node" + default = { + data_disks = [ + { + count = 1 + caching = "ReadOnly" + create_option = "Empty" + disk_size_gb = 1024 + lun = 20 + disk_type = "Premium_LRS" + write_accelerator_enabled = false + } + ], + asm_disks = [ + { + count = 1 + caching = "ReadOnly" + create_option = "Empty" + disk_size_gb = 1024 + lun = 10 + disk_type = "Premium_LRS" + write_accelerator_enabled = false + } + ] + redo_disks = [ + { + count = 1 + caching = "None" + create_option = "Empty" + disk_size_gb = 1024 + lun = 60 + disk_type = "Premium_LRS" + write_accelerator_enabled = false + } + ] + } +} + +variable "role_assignments" { + description = "Role assignments" + default = {} +} + +variable "data_disk_locks" { + type = object({ + name = optional(string, "") + type = optional(string, "CanNotDelete") + }) + default = {} + validation { + condition = contains(["CanNotDelete", "ReadOnly"], var.data_disk_locks.type) + error_message = "Lock type must be one of: CanNotDelete, ReadOnly." + } +} + +variable "availability_zone" { + description = "The availability zones of the resource" + default = null +} + +variable "is_data_guard" { + description = "Whether Data Guard is enabled" + default = false +} + +variable "tags" { + description = "Tags to be added to the resources" + default = {} +} diff --git a/03-Azure/01-03-Infrastructure/10_Oracle_on_Azure/resources/environment_setup/terraform/data_guard/modules/storage/variables_local.tf b/03-Azure/01-03-Infrastructure/10_Oracle_on_Azure/resources/environment_setup/terraform/data_guard/modules/storage/variables_local.tf new file mode 100644 index 000000000..6a03a5998 --- /dev/null +++ b/03-Azure/01-03-Infrastructure/10_Oracle_on_Azure/resources/environment_setup/terraform/data_guard/modules/storage/variables_local.tf @@ -0,0 +1,51 @@ +locals { + data_disks = flatten( + [ + for disk in var.database_disks_options.data_disks : [ + for i in range(0, disk.count) : { + name = "${var.vm.name}-datadisk${i}" + caching = disk.caching + create_option = disk.create_option + disk_size_gb = disk.disk_size_gb + lun = disk.lun + i + managed_disk_type = disk.disk_type + storage_account_type = disk.disk_type + write_accelerator_enabled = disk.write_accelerator_enabled + } + ] + ] + ) + asm_disks = flatten( + [ + for disk in var.database_disks_options.asm_disks : [ + for i in range(0, disk.count) : { + name = "${var.vm.name}-asmdisk${i}" + caching = disk.caching + create_option = disk.create_option + disk_size_gb = disk.disk_size_gb + lun = disk.lun + i + managed_disk_type = disk.disk_type + storage_account_type = disk.disk_type + write_accelerator_enabled = disk.write_accelerator_enabled + } + ] + ] + ) + redo_disks = flatten( + [ + for disk in var.database_disks_options.redo_disks : [ + for i in range(0, disk.count) : { + name = "${var.vm.name}-redodisk${i}" + caching = disk.caching + create_option = disk.create_option + disk_size_gb = disk.disk_size_gb + lun = disk.lun + i + managed_disk_type = disk.disk_type + storage_account_type = disk.disk_type + write_accelerator_enabled = disk.write_accelerator_enabled + } + ] + ] + ) + tags = {} +} diff --git a/03-Azure/01-03-Infrastructure/10_Oracle_on_Azure/resources/environment_setup/terraform/data_guard/outputs.tf b/03-Azure/01-03-Infrastructure/10_Oracle_on_Azure/resources/environment_setup/terraform/data_guard/outputs.tf new file mode 100644 index 000000000..2c94f297a --- /dev/null +++ b/03-Azure/01-03-Infrastructure/10_Oracle_on_Azure/resources/environment_setup/terraform/data_guard/outputs.tf @@ -0,0 +1,70 @@ +# ############################################################################### +# # # +# # Resource Group # +# # # +# ############################################################################### +output "resource_group" { + value = module.common_infrastructure.resource_group +} + +# output "created_resource_group_id" { +# description = "Created resource group ID" +# value = module.common_infrastructure.resource_group.id +# } + +# output "created_resource_group_name" { +# description = "Created resource group name" +# value = module.common_infrastructure.resource_group.name +# } + +# output "created_resource_group_subscription_id" { +# description = "Created resource group' subscription ID" +# value = module.common_infrastructure.resource_group.id +# } + +# output "created_resource_group_tags" { +# description = "Created resource group tags" +# value = module.common_infrastructure.tags +# } + +# ############################################################################### +# # # +# # Network # +# # # +# ############################################################################### +# output "network_location" { +# value = module.network.network_location +# } + +# output "db_subnet" { +# value = module.network.db_subnet +# } + +# ############################################################################### +# # # +# # Storage # +# # # +# ############################################################################### +# output "database_data_disks_primary" { +# value = module.storage_primary.data_disks +# } + +# output "database_asm_disks_primary" { +# value = module.storage_primary.asm_disks +# } + +# output "database_redo_disks_primary" { +# value = module.storage_primary.redo_disks +# } + +# output "database_data_disks_secondary" { +# value = module.storage_secondary.data_disks +# } + +# output "database_asm_disks_secondary" { +# value = module.storage_secondary.asm_disks +# } + +# output "database_redo_disks_secondary" { +# value = module.storage_secondary.redo_disks +# } diff --git a/03-Azure/01-03-Infrastructure/10_Oracle_on_Azure/resources/environment_setup/terraform/data_guard/providers.tf b/03-Azure/01-03-Infrastructure/10_Oracle_on_Azure/resources/environment_setup/terraform/data_guard/providers.tf new file mode 100644 index 000000000..a6c69adcb --- /dev/null +++ b/03-Azure/01-03-Infrastructure/10_Oracle_on_Azure/resources/environment_setup/terraform/data_guard/providers.tf @@ -0,0 +1,29 @@ +terraform { + required_version = ">=1.7.0" + required_providers { + azurerm = { + source = "hashicorp/azurerm" + version = ">=3.11.0, <4.0" + } + azapi = { + source = "Azure/azapi" + version = ">=1.8.0" + } + } +} + +provider "azurerm" { + skip_provider_registration = true + features { + resource_group { + prevent_deletion_if_contains_resources = true + } + virtual_machine { + delete_os_disk_on_deletion = true + } + } +} + +provider "azapi" { + use_oidc = true +} diff --git a/03-Azure/01-03-Infrastructure/10_Oracle_on_Azure/resources/environment_setup/terraform/data_guard/resources.telemetry.tf b/03-Azure/01-03-Infrastructure/10_Oracle_on_Azure/resources/environment_setup/terraform/data_guard/resources.telemetry.tf new file mode 100644 index 000000000..0a320c3cc --- /dev/null +++ b/03-Azure/01-03-Infrastructure/10_Oracle_on_Azure/resources/environment_setup/terraform/data_guard/resources.telemetry.tf @@ -0,0 +1,15 @@ +# The following random id is created once per module instantiation and is appended to the teleletry deployment name +resource "random_id" "telem" { + count = local.disable_telemetry ? 0 : 1 + byte_length = 4 +} + +# This is the core module telemetry deployment that is only created if telemetry is enabled. +# It is deployed to the default subscription +resource "azurerm_subscription_template_deployment" "telemetry_core" { + count = local.telem_core_deployment_enabled ? 1 : 0 + provider = azurerm + name = local.telem_core_arm_deployment_name + location = var.location + template_content = local.telem_arm_subscription_template_content +} \ No newline at end of file diff --git a/03-Azure/01-03-Infrastructure/10_Oracle_on_Azure/resources/environment_setup/terraform/data_guard/transform.tf b/03-Azure/01-03-Infrastructure/10_Oracle_on_Azure/resources/environment_setup/terraform/data_guard/transform.tf new file mode 100644 index 000000000..17780f880 --- /dev/null +++ b/03-Azure/01-03-Infrastructure/10_Oracle_on_Azure/resources/environment_setup/terraform/data_guard/transform.tf @@ -0,0 +1,39 @@ +locals { + infrastructure = { + region = coalesce(var.location, try(var.infrastructure.region, "")) + resource_group = { + name = try( + coalesce( + var.resourcegroup_name, + try(var.infrastructure.resource_group.name, "") + ), + "" + ) + } + vnet = { + name = try( + coalesce( + local.vnet_oracle_name, + try(var.infrastructure.vnet.name, "") + ), + "" + ) + } + subnet = { + name = try( + coalesce( + local.database_subnet_name, + try(var.infrastructure.subnet.name, "") + ), + "" + ) + } + tags = try( + coalesce( + var.resourcegroup_tags, + try(var.infrastructure.tags, {}) + ), + {} + ) + } +} diff --git a/03-Azure/01-03-Infrastructure/10_Oracle_on_Azure/resources/environment_setup/terraform/data_guard/variables.md b/03-Azure/01-03-Infrastructure/10_Oracle_on_Azure/resources/environment_setup/terraform/data_guard/variables.md new file mode 100644 index 000000000..8bc43b1eb --- /dev/null +++ b/03-Azure/01-03-Infrastructure/10_Oracle_on_Azure/resources/environment_setup/terraform/data_guard/variables.md @@ -0,0 +1,173 @@ +# Terraform Variable Explanations + +1. **[Common Parameters](#common-parameters)** + + - [`location`](#location) + - [`resourcegroup_name`](#resourcegroup_name) + - [`resourcegroup_tags`](#resourcegroup_tags) + - [`is_diagnostic_settings_enabled`](#is_diagnostic_settings_enabled) + - [`diagnostic_target`](#diagnostic_target) + - [`infrastructure`](#infrastructure) + +2. **[Virtual Machine Parameters](#virtual-machine-parameters)** + + - [`ssh_key`](#ssh_key) + - [`vm_sku`](#vm_sku) + - [`vm_source_image_reference`](#vm_source_image_reference) + - [`vm_os_disk`](#vm_os_disk) + +3. **[Database Parameters](#database-parameters)** + - [`database`](#database) + - [`database_disks_options`](#database_disks_options) + - [`database_db_nic_ips`](#database_db_nic_ips) + +### `location` + +- **Description:** Defines the Azure location where the resources will be deployed. +- **Type:** String +- **Default Value:** "eastus" + +### `resourcegroup_name` + +- **Description:** If defined, this variable specifies the name of the resource group into which the resources will be deployed. +- **Default Value:** "" + +### `resourcegroup_tags` + +- **Description:** Tags to be added to the resource group. +- **Default Value:** {} + +### `is_diagnostic_settings_enabled` + +- **Description:** Whether diagnostic settings are enabled. +- **Default Value:** false + +### `diagnostic_target` + +- **Description:** The destination type of the diagnostic settings. Allowed values are "Log_Analytics_Workspace," "Storage_Account," "Event_Hubs," or "Partner_Solutions." +- **Default Value:** "Log_Analytics_Workspace" + +### `infrastructure` + +- **Description:** Details of the Azure infrastructure to deploy the SAP landscape into. +- **Default Value:** {} + +## Virtual Machine Parameters + +### `ssh_key` + +- **Description:** Value of the SSH public key to be used for the virtual machines. + +### `vm_sku` + +- **Description:** The SKU of the virtual machine. +- **Default Value:** "Standard_D4s_v3" + +### `vm_source_image_reference` + +- **Description:** The source image reference of the virtual machine. +- **Default Value:** + ```hcl + { + publisher = "Oracle" + offer = "Oracle-Linux" + sku = "79-gen2" + version = "7.9.36" + } + ``` + +### `vm_os_disk` + +- **Description:** Details of the OS disk, including name, caching, storage account type, disk encryption set, and disk size. +- **Default Value:** + ```hcl + { + name = "osdisk" + caching = "ReadWrite" + storage_account_type = "Premium_LRS" + disk_encryption_set_id = null + disk_size_gb = 128 + } + ``` + +## Database Parameters + +### `database` + +- **Description:** Details of the database node, including options such as DHCP, authentication type, and data disks. +- **Default Value:** + ```hcl + { + use_DHCP = true + authentication = { + type = "key" + } + data_disks = [ + { + count = 1 + caching = "ReadOnly" + create_option = "Empty" + disk_size_gb = 1024 + lun = 0 + disk_type = "Premium_LRS" + write_accelerator_enabled = false + }, + { + count = 1 + caching = "None" + create_option = "Empty" + disk_size_gb = 1024 + lun = 1 + disk_type = "Premium_LRS" + write_accelerator_enabled = false + } + ] + } + ``` + +### `database_disks_options` + +- **Description:** Details of the database node's disk options, including data disks, ASM disks, and redo disks. +- **Default Value:** + ```hcl + { + data_disks = [ + { + count = 1 + caching = "ReadOnly" + create_option = "Empty" + disk_size_gb = 1024 + lun = 20 + disk_type = "Premium_LRS" + write_accelerator_enabled = false + } + ], + asm_disks = [ + { + count = 1 + caching = "ReadOnly" + create_option = "Empty" + disk_size_gb = 1024 + lun = 10 + disk_type = "Premium_LRS" + write_accelerator_enabled = false + } + ] + redo_disks = [ + { + count = 1 + caching = "None" + create_option = "Empty" + disk_size_gb = 1024 + lun = 60 + disk_type = "Premium_LRS" + write_accelerator_enabled = false + } + ] + } + ``` + +### `database_db_nic_ips` + +- **Description:** If provided, the database tier virtual machines will be configured using the specified IPs. +- **Default Value:** [""] diff --git a/03-Azure/01-03-Infrastructure/10_Oracle_on_Azure/resources/environment_setup/terraform/data_guard/variables_global.tf b/03-Azure/01-03-Infrastructure/10_Oracle_on_Azure/resources/environment_setup/terraform/data_guard/variables_global.tf new file mode 100644 index 000000000..0843270a1 --- /dev/null +++ b/03-Azure/01-03-Infrastructure/10_Oracle_on_Azure/resources/environment_setup/terraform/data_guard/variables_global.tf @@ -0,0 +1,184 @@ +######################################################################################### +# Common parameters # +######################################################################################### +variable "location" { + description = "Defines the Azure location where the resources will be deployed" + type = string + default = "germanywestcentral" +} + +variable "resourcegroup_name" { + description = "If defined, the name of the resource group into which the resources will be deployed" + default = "rg-mh-oracle4" +} + +variable "resourcegroup_tags" { + description = "tags to be added to the resource group" + default = {} +} + +variable "is_diagnostic_settings_enabled" { + description = "Whether diagnostic settings are enabled" + default = false +} + +variable "diagnostic_target" { + description = "The destination type of the diagnostic settings" + default = "Log_Analytics_Workspace" + validation { + condition = contains(["Log_Analytics_Workspace", "Storage_Account", "Event_Hubs", "Partner_Solutions"], var.diagnostic_target) + error_message = "Allowed values are Log_Analytics_Workspace, Storage_Account, Event_Hubs, Partner_Solutions" + } +} + +variable "infrastructure" { + description = "Details of the Azure infrastructure to deploy the SAP landscape into" + default = {} +} + +variable "disable_telemetry" { + type = bool + description = "If set to true, will disable telemetry for the module. See https://aka.ms/alz-terraform-module-telemetry." + default = false +} +######################################################################################### +# Virtual Machine parameters # +######################################################################################### +variable "ssh_key" { + description = "value of the ssh public key to be used for the virtual machines" +} + +variable "vm_sku" { + description = "The SKU of the virtual machine" + default = "Standard_D4s_v5" +} + +variable "vm_source_image_reference" { + description = "The source image reference of the virtual machine" + default = { + publisher = "Oracle" + offer = "oracle-database-19-3" + sku = "oracle-database-19-0904" + version = "latest" + } +} + +variable "vm_os_disk" { + description = "Details of the OS disk" + default = { + name = "osdisk" + caching = "ReadWrite" + storage_account_type = "Premium_LRS" + disk_encryption_set_id = null + disk_size_gb = 128 + } +} + +variable "vm_user_assigned_identity_id" { + description = "The ID of the user assigned identity to be used for the virtual machine" +} + +variable "jit_wait_for_vm_creation" { + description = "The duration to wait for the virtual machine to be created before creating the JIT policy" + default = "60s" +} + +variable "vm_extensions" { + description = "The extensions to be added to the virtual machine" + type = map(object({ + name = string + publisher = string + type = string + type_handler_version = string + auto_upgrade_minor_version = optional(bool) + automatic_upgrade_enabled = optional(bool) + failure_suppression_enabled = optional(bool, false) + settings = optional(string) + protected_settings = optional(string) + provision_after_extensions = optional(list(string), []) + tags = optional(map(any)) + protected_settings_from_key_vault = optional(object({ + secret_url = string + source_vault_id = string + })) + })) + default = {} +} + + +######################################################################################### +# Database parameters # +######################################################################################### +variable "database" { + description = "Details of the database node" + default = { + use_DHCP = true + authentication = { + type = "key" + } + data_disks = [ + { + count = 1 + caching = "ReadOnly" + create_option = "Empty" + disk_size_gb = 1024 + lun = 0 + disk_type = "Premium_LRS" + write_accelerator_enabled = false + }, + { + count = 1 + caching = "None" + create_option = "Empty" + disk_size_gb = 1024 + lun = 1 + disk_type = "Premium_LRS" + write_accelerator_enabled = false + } + ] + } +} + +variable "database_disks_options" { + description = "Details of the database node" + default = { + data_disks = [ + { + count = 1 + caching = "ReadOnly" + create_option = "Empty" + disk_size_gb = 1024 + lun = 1 + disk_type = "Premium_LRS" + write_accelerator_enabled = false + } + ], + asm_disks = [ + { + count = 1 + caching = "ReadOnly" + create_option = "Empty" + disk_size_gb = 1024 + lun = 0 + disk_type = "Premium_LRS" + write_accelerator_enabled = false + } + ] + redo_disks = [ + { + count = 1 + caching = "None" + create_option = "Empty" + disk_size_gb = 1024 + lun = 2 + disk_type = "Premium_LRS" + write_accelerator_enabled = false + } + ] + } +} + +variable "database_db_nic_ips" { + description = "If provided, the database tier virtual machines will be configured using the specified IPs" + default = [""] +} diff --git a/03-Azure/01-03-Infrastructure/10_Oracle_on_Azure/resources/environment_setup/terraform/data_guard/variables_local.tf b/03-Azure/01-03-Infrastructure/10_Oracle_on_Azure/resources/environment_setup/terraform/data_guard/variables_local.tf new file mode 100644 index 000000000..124d5e8e0 --- /dev/null +++ b/03-Azure/01-03-Infrastructure/10_Oracle_on_Azure/resources/environment_setup/terraform/data_guard/variables_local.tf @@ -0,0 +1,46 @@ +locals { + vnet_oracle_name = "vnet1" + database_subnet_name = "subnet1" + disable_telemetry = var.disable_telemetry + telem_core_puid = "440d81eb-6657-4a7d-ad93-c7e9cc09e5da" + empty_string = "" + telem_random_hex = can(random_id.telem[0].hex) ? random_id.telem[0].hex : local.empty_string +} + + +# This constructs the ARM deployment name that is used for the telemetry. +# We shouldn't ever hit the 64 character limit but use substr just in case +locals { + telem_core_arm_deployment_name = substr( + format( + "pid-%s_%s", + local.telem_core_puid, + local.telem_random_hex, + ), + 0, + 64 + ) +} + +locals { + telem_arm_subscription_template_content = <