├── .gitignore ├── LICENSE ├── README.md ├── existing-environment ├── README.md ├── datasource.tf ├── expressroute.tf ├── networkgateway.tf ├── output.tf ├── providor.tf ├── terraform.tfvars.template └── variables.tf └── new-environment ├── README.md ├── compute.tf ├── datasource.tf ├── expressroute.tf ├── images └── arch.png ├── network-azure.tf ├── network-oci.tf ├── networkgateway.tf ├── output.tf ├── providor.tf ├── terraform.tfvars.template └── variables.tf /.gitignore: -------------------------------------------------------------------------------- 1 | # Local .terraform directories 2 | **/.terraform/* 3 | 4 | # .tfstate files 5 | *.tfstate 6 | *.tfstate.* 7 | 8 | # .tfvars files 9 | *.tfvars 10 | 11 | # Secret File 12 | secret_env_vars.* 13 | secret_env_vars 14 | 15 | # Test 16 | 17 | # OS generated files # 18 | ###################### 19 | .DS_Store 20 | .DS_Store? -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) Microsoft Corporation. All rights reserved. 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # oci-azure-interconnect 2 | 3 | This repository allows you to setup an Interconnect between Oracle Cloud Infrastrcture and Microsoft Azure. 4 | 5 | ## Use Cases 6 | 7 | You can follow individual use-cases to know more about their pre-requsities and installation instruction. 8 | 9 | - Setup OCI/Azure interconnect on a new VNET and VCN setup: [New Environment Setup](new-environment) 10 | - Setup OCI/Azure Interconnect on an existing VNET and VCN enviornment: [Existing Environment Setup](existing-environment) 11 | 12 | ## Feedback 13 | 14 | Feedbacks are welcome to this repository, you can open an issue and/or PR accordingly. -------------------------------------------------------------------------------- /existing-environment/README.md: -------------------------------------------------------------------------------- 1 | # oci-azure-interconnect 2 | 3 | In this repository you will be utilizing existing OCI/Azure enviornment where you would like to setup an interconnect circuit. 4 | 5 | ## Prerequisites 6 | 7 | You should complete below pre-requisites before proceeding to next section: 8 | - You have an active Oracle Cloud Infrastructure Account. 9 | - You have an active subscription to Microsoft Azure 10 | - You have a working OCI enviornment which you want to connect to Azure: `drg` OCID is required to connect and setup this circuit,VCN and required subnets, VMs, routes and security policies are present. 11 | - You have a working Azure enviornment which you want to connect to OCI: `resource-group`, `virtual-network`, `gateway-subnet`, `gateway-subnet-public-ip` are required manadatory parameters which you need add in your variable file. 12 | - Permission to `manage` the following types of resources in your Oracle Cloud Infrastructure tenancy and Microsoft Azure: `virtual-circuits`, `expressroutes`, `vnet gateways`. 13 | 14 | Tested enviornment: 15 | ``` 16 | ➜ oci-azure-interconnect git:(main) terraform -v 17 | 18 | Your version of Terraform is out of date! The latest version 19 | is 0.14.7. You can update by downloading from https://www.terraform.io/downloads.html 20 | Terraform v0.13.0 21 | + provider registry.terraform.io/hashicorp/azurerm v2.20.0 22 | + provider registry.terraform.io/hashicorp/http v2.1.0 23 | + provider registry.terraform.io/hashicorp/oci v4.15.0 24 | ``` 25 | 26 | ## Deployment 27 | 28 | You can follow below setps to deploy this setup in your account: 29 | 30 | 1. Create a local copy of this repo using below command on your terminal: 31 | 32 | ``` 33 | https://github.com/oracle-quickstart/oci-azure-interconnect.git 34 | cd oci-azure-interconnect 35 | ls 36 | ``` 37 | 38 | 2. Complete the prerequisites described [here] which are associated to install **Terraform** locally:(https://github.com/oracle-quickstart/oci-prerequisites#install-terraform). 39 | Make sure you have terraform v0.13+ cli installed and accessible from your terminal. 40 | 41 | ```bash 42 | ➜ oci-azure-interconnect git:(main) terraform -v 43 | 44 | Your version of Terraform is out of date! The latest version 45 | is 0.14.7. You can update by downloading from https://www.terraform.io/downloads.html 46 | Terraform v0.13.0 47 | + provider registry.terraform.io/hashicorp/azurerm v2.20.0 48 | + provider registry.terraform.io/hashicorp/http v2.1.0 49 | + provider registry.terraform.io/hashicorp/oci v4.15.0 50 | ``` 51 | 52 | 3. Create a `terraform.tfvars` file in your **oci-azure-interconnect** directory, and specify the following variables: 53 | 54 | ``` 55 | # Authentication 56 | tenancy_ocid = "" 57 | user_ocid = "" 58 | fingerprint = "" 59 | private_key_path = "" 60 | 61 | # SSH Keys 62 | ssh_public_key = "" 63 | 64 | # Region 65 | region = "" 66 | 67 | # DRG 68 | drg_ocid = "" 69 | 70 | # Compartment 71 | compartment_ocid = "" 72 | availability_domain_number = " 73 | 74 | ## Azure Variables 75 | bandwidth="" 76 | azure_region="" 77 | peering_location="" 78 | resource_group_name="" 79 | azure_virtual_network_name="" 80 | gateway_subnet_name="" 81 | gateway_public_ip_name="" 82 | ```` 83 | 84 | 4. Login to Microsoft Azure from CLI using **az login**. If you don't have Azure CLI utility installed locally you will have to do that first. This will allow Azure terraform providor to manage resources on Azure enviornment. Verify you have `az account set --subscription` if you have multiple subscriptions, etc. as described here: https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/guides/azure_cli.html 85 | 86 | 5. Create the Resources using the following commands: 87 | 88 | ```bash 89 | terraform init 90 | terraform plan 91 | terraform apply 92 | ``` 93 | 94 | 6. At this point your circuit should be up and you can connect to test VMs on both end and validate connectivity using ping/ssh and check latency. 95 | 96 | 7. If you no longer require your infrastructure, you can run this command to destroy the resources in following orders: 97 | 98 | ```bash 99 | terraform destroy -target azurerm_virtual_network_gateway_connection.virtual_network_gateway_connection 100 | ``` 101 | > Note: End user noticed virtual circuit goes in failed state during deletion. So you should delete the circuit connection first and then continue with destroy command. 102 | 103 | ```bash 104 | terraform destroy 105 | ``` 106 | 107 | ## Feedback 108 | 109 | Feedbacks are welcome to this repo, please open a PR if you have any. 110 | -------------------------------------------------------------------------------- /existing-environment/datasource.tf: -------------------------------------------------------------------------------- 1 | # ------ Get the OCI Tenancy Details 2 | data "oci_identity_tenancy" "tenancy" { 3 | provider = oci.oci 4 | tenancy_id = var.tenancy_ocid 5 | } 6 | 7 | # ------ Get the OCI Fast Connect Providors Details 8 | data "oci_core_fast_connect_provider_services" "test_fast_connect_provider_services" { 9 | provider = oci.oci 10 | compartment_id = var.compartment_ocid 11 | } 12 | 13 | # ------ Get the Microsoft Azure Providor Details 14 | data "oci_core_fast_connect_provider_service" "test_fast_connect_provider_service" { 15 | provider = oci.oci 16 | provider_service_id = "${lookup(element(data.oci_core_fast_connect_provider_services.test_fast_connect_provider_services.fast_connect_provider_services, index(data.oci_core_fast_connect_provider_services.test_fast_connect_provider_services.fast_connect_provider_services.*.provider_name, "Microsoft Azure")), "id")}" 17 | } 18 | 19 | # ------ Define a Variable for Shape 20 | variable "shape" { 21 | type = map 22 | default = { 23 | 10000 = "10 Gbps" 24 | 5000 = "5 Gbps" 25 | 2000 = "2 Gbps" 26 | 1000 = "1 Gbps" 27 | 50 = "1 Gbps" #Test bandwidth 28 | } 29 | } 30 | 31 | # ------ Get the Azure Resource Group Details 32 | data "azurerm_resource_group" "resource_group_name" { 33 | provider = azurerm.azure 34 | name = var.resource_group_name 35 | } 36 | 37 | # ------ Get the Azure Gateway Subnet Details 38 | data "azurerm_subnet" "gateway_subnet" { 39 | provider = azurerm.azure 40 | name = var.gateway_subnet_name 41 | virtual_network_name = var.azure_virtual_network_name 42 | resource_group_name = var.resource_group_name 43 | } 44 | 45 | # ------ Get the Azure Gateway Public IP Details 46 | data "azurerm_public_ip" "gateway_public_ip" { 47 | provider = azurerm.azure 48 | name = var.gateway_public_ip_name 49 | resource_group_name = var.resource_group_name 50 | } 51 | -------------------------------------------------------------------------------- /existing-environment/expressroute.tf: -------------------------------------------------------------------------------- 1 | # ------ Create Virtual Circuit 2 | resource "oci_core_virtual_circuit" "virtual_circuit" { 3 | provider = oci.oci 4 | compartment_id = var.compartment_ocid 5 | type = "PRIVATE" 6 | 7 | bandwidth_shape_name = var.shape[var.bandwidth] 8 | cross_connect_mappings { 9 | customer_bgp_peering_ip = "192.168.240.2/30" 10 | oracle_bgp_peering_ip = "192.168.240.1/30" 11 | } 12 | cross_connect_mappings { 13 | customer_bgp_peering_ip = "192.168.240.26/30" 14 | oracle_bgp_peering_ip = "192.168.240.25/30" 15 | } 16 | gateway_id = var.drg_ocid 17 | provider_service_id = data.oci_core_fast_connect_provider_service.test_fast_connect_provider_service.id 18 | provider_service_key_name = azurerm_express_route_circuit.express_route_circuit.service_key 19 | region = var.region 20 | } 21 | 22 | 23 | # ------ Create ExpressRoute Circuit 24 | resource "azurerm_express_route_circuit" "express_route_circuit" { 25 | provider = azurerm.azure 26 | name = var.azure_express_circuit_name 27 | resource_group_name = var.resource_group_name 28 | location = data.azurerm_resource_group.resource_group_name.location 29 | service_provider_name = "Oracle Cloud FastConnect" 30 | peering_location = var.peering_location 31 | bandwidth_in_mbps = var.bandwidth 32 | 33 | sku { 34 | tier = "Premium" 35 | family = "MeteredData" 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /existing-environment/networkgateway.tf: -------------------------------------------------------------------------------- 1 | # ------ Create Virtual Network Gateway on Azure 2 | resource "azurerm_virtual_network_gateway" "virtual_network_gateway" { 3 | provider = azurerm.azure 4 | name = var.virtual_network_gateway_name 5 | location = data.azurerm_resource_group.resource_group_name.location 6 | resource_group_name = var.resource_group_name 7 | 8 | type = "ExpressRoute" 9 | sku = "UltraPerformance" 10 | 11 | ip_configuration { 12 | name = "vnetGatewayConfig" 13 | public_ip_address_id = data.azurerm_public_ip.gateway_public_ip.id 14 | private_ip_address_allocation = "Dynamic" 15 | subnet_id = data.azurerm_subnet.gateway_subnet.id 16 | } 17 | } 18 | 19 | # ------ Create Virtual Network Gateway ExpressRoute Connection 20 | resource "azurerm_virtual_network_gateway_connection" "virtual_network_gateway_connection" { 21 | provider = azurerm.azure 22 | name = var.virtual_network_gateway_connection_name 23 | location = data.azurerm_resource_group.resource_group_name.location 24 | resource_group_name = var.resource_group_name 25 | // Below commented line enables Fast Path on ExpressRoute, uncomment it if you need Fast Path (Additional Cost associated with this) 26 | //express_route_gateway_bypass = "true" 27 | type = "ExpressRoute" 28 | virtual_network_gateway_id = azurerm_virtual_network_gateway.virtual_network_gateway.id 29 | express_route_circuit_id = azurerm_express_route_circuit.express_route_circuit.id 30 | } 31 | -------------------------------------------------------------------------------- /existing-environment/output.tf: -------------------------------------------------------------------------------- 1 | # ------ Initial Instructions 2 | output "initial_instruction" { 3 | value = <" 75 | azure_region="" 76 | peering_location="" 77 | ```` 78 | 79 | 4. Login to Microsoft Azure from CLI using **az login**. If you don't have Azure CLI utility installed locally you will have to do that first. Verify you have `az account set --subscription` if you have multiple subscriptions, etc. as described here: https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/guides/azure_cli.html 80 | 81 | 5. Create the Resources using the following commands: 82 | 83 | ```bash 84 | terraform init 85 | terraform plan 86 | terraform apply 87 | ``` 88 | 89 | 6. At this point your circuits should be up and you can connect to test VMs on both end and validate connectivity using ping/ssh and check latency. 90 | 91 | 7. If you no longer require your infrastructure, you can run this command to destroy the resources: 92 | 93 | ```bash 94 | terraform destroy -target azurerm_virtual_network_gateway_connection.virtual_network_gateway_connection 95 | ``` 96 | > Note: End user noticed virtual circuit goes in failed state during deletion. So you should delete the circuit connection first and then continue with destroy command. 97 | 98 | ```bash 99 | terraform destroy 100 | ``` 101 | 102 | ## Feedback 103 | 104 | Feedbacks are welcome to this repo, please open a PR if you have any. 105 | -------------------------------------------------------------------------------- /new-environment/compute.tf: -------------------------------------------------------------------------------- 1 | # ------ Create Compute VM Network Interface Card 2 | resource "azurerm_network_interface" "compute_vm_vnic" { 3 | provider = azurerm.azure 4 | name = var.azure_compute_vnic_name 5 | location = azurerm_resource_group.resource_group.location 6 | resource_group_name = azurerm_resource_group.resource_group.name 7 | 8 | ip_configuration { 9 | name = "internal" 10 | subnet_id = azurerm_subnet.compute_subnet.id 11 | private_ip_address_allocation = "Dynamic" 12 | public_ip_address_id = azurerm_public_ip.machine_public_ip.id 13 | } 14 | } 15 | 16 | # ------ Create Compute VM on Azure 17 | resource "azurerm_linux_virtual_machine" "azure_compute_vm" { 18 | provider = azurerm.azure 19 | name = var.azure_compute_machine_name 20 | resource_group_name = azurerm_resource_group.resource_group.name 21 | location = azurerm_resource_group.resource_group.location 22 | size = "Standard_F2" 23 | disable_password_authentication = "true" 24 | admin_username = "adminuser" 25 | admin_ssh_key { 26 | username = "adminuser" 27 | public_key = var.ssh_public_key 28 | } 29 | 30 | 31 | network_interface_ids = [ 32 | azurerm_network_interface.compute_vm_vnic.id, 33 | ] 34 | 35 | os_disk { 36 | caching = "ReadWrite" 37 | storage_account_type = "Standard_LRS" 38 | } 39 | source_image_reference { 40 | publisher = "Oracle" 41 | offer = "Oracle-Linux" 42 | sku = "77" 43 | version = "latest" 44 | } 45 | } 46 | 47 | # ------ Create Compute VM on OCI 48 | resource "oci_core_instance" "oci_compute_instance" { 49 | provider = oci.oci 50 | availability_domain = data.oci_identity_availability_domain.AD.name 51 | compartment_id = var.compartment_ocid 52 | display_name = var.oci_compute_instance_name 53 | shape = var.InstanceShape 54 | 55 | create_vnic_details { 56 | subnet_id = oci_core_subnet.compute_subnet.id 57 | assign_public_ip = true 58 | } 59 | 60 | metadata = { 61 | ssh_authorized_keys = var.ssh_public_key 62 | } 63 | 64 | shape_config { 65 | memory_in_gbs = var.instance_shape_config_memory_in_gbs 66 | ocpus = var.instance_shape_config_ocpus 67 | } 68 | 69 | source_details { 70 | source_type = "image" 71 | source_id = data.oci_core_images.InstanceImageOCID.images[0].id 72 | boot_volume_size_in_gbs = "50" 73 | } 74 | 75 | timeouts { 76 | create = "10m" 77 | } 78 | } 79 | -------------------------------------------------------------------------------- /new-environment/datasource.tf: -------------------------------------------------------------------------------- 1 | # ------ Get a List of Availability Domain 2 | data "oci_identity_availability_domain" "AD" { 3 | provider = oci.oci 4 | compartment_id = var.tenancy_ocid 5 | ad_number = "1" 6 | } 7 | 8 | # ------ Get the OCI Tenancy Details 9 | data "oci_identity_tenancy" "tenancy" { 10 | provider = oci.oci 11 | tenancy_id = var.tenancy_ocid 12 | } 13 | 14 | # ------ Get the OCI Fast Connect Providors Details 15 | data "oci_core_fast_connect_provider_services" "test_fast_connect_provider_services" { 16 | provider = oci.oci 17 | compartment_id = var.compartment_ocid 18 | } 19 | 20 | # ------ Get the Microsoft Azure Providor Details 21 | data "oci_core_fast_connect_provider_service" "test_fast_connect_provider_service" { 22 | provider = oci.oci 23 | provider_service_id = "${lookup(element(data.oci_core_fast_connect_provider_services.test_fast_connect_provider_services.fast_connect_provider_services, index(data.oci_core_fast_connect_provider_services.test_fast_connect_provider_services.fast_connect_provider_services.*.provider_name, "Microsoft Azure")), "id")}" 24 | } 25 | 26 | # ------ Memory in gbs 27 | variable "instance_shape_config_memory_in_gbs" { 28 | default = "50" 29 | } 30 | 31 | # ------ Cpu's 32 | variable "instance_shape_config_ocpus" { 33 | default = "1" 34 | } 35 | 36 | # ------ Define a Variable for Shape 37 | variable "shape" { 38 | type = map 39 | default = { 40 | 10000 = "10 Gbps" 41 | 5000 = "5 Gbps" 42 | 2000 = "2 Gbps" 43 | 1000 = "1 Gbps" 44 | 50 = "1 Gbps" #Test bandwidth 45 | } 46 | } 47 | 48 | data "http" "myip" { 49 | url = "http://ipv4.icanhazip.com/" 50 | } 51 | 52 | # ------ Get the latest Oracle Linux image 53 | data "oci_core_images" "InstanceImageOCID" { 54 | provider = oci.oci 55 | compartment_id = var.compartment_ocid 56 | # operating_system = var.instance_os 57 | # operating_system_version = var.linux_os_version 58 | 59 | filter { 60 | name = "display_name" 61 | values = ["^.*Oracle[^G]*$"] 62 | regex = true 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /new-environment/expressroute.tf: -------------------------------------------------------------------------------- 1 | # ------ Create Virtual Circuit 2 | resource "oci_core_virtual_circuit" "virtual_circuit" { 3 | provider = oci.oci 4 | compartment_id = var.compartment_ocid 5 | type = "PRIVATE" 6 | 7 | bandwidth_shape_name = var.shape[var.bandwidth] 8 | cross_connect_mappings { 9 | customer_bgp_peering_ip = "192.168.240.2/30" 10 | oracle_bgp_peering_ip = "192.168.240.1/30" 11 | } 12 | cross_connect_mappings { 13 | customer_bgp_peering_ip = "192.168.240.26/30" 14 | oracle_bgp_peering_ip = "192.168.240.25/30" 15 | } 16 | gateway_id = oci_core_drg.drg_azure.id 17 | provider_service_id = data.oci_core_fast_connect_provider_service.test_fast_connect_provider_service.id 18 | provider_service_key_name = azurerm_express_route_circuit.express_route_circuit.service_key 19 | region = var.region 20 | } 21 | 22 | # ------ Create ExpressRoute Circuit 23 | resource "azurerm_express_route_circuit" "express_route_circuit" { 24 | provider = azurerm.azure 25 | name = var.azure_express_circuit_name 26 | resource_group_name = azurerm_resource_group.resource_group.name 27 | location = azurerm_resource_group.resource_group.location 28 | service_provider_name = "Oracle Cloud FastConnect" 29 | peering_location = var.peering_location 30 | bandwidth_in_mbps = var.bandwidth 31 | 32 | sku { 33 | tier = "Premium" 34 | family = "MeteredData" 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /new-environment/images/arch.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oracle-quickstart/oci-azure-interconnect/4fb64a5361d25c51c3aab2bcec77618fdb12d493/new-environment/images/arch.png -------------------------------------------------------------------------------- /new-environment/network-azure.tf: -------------------------------------------------------------------------------- 1 | # ------ Create Azure Resource Group 2 | resource "azurerm_resource_group" "resource_group" { 3 | provider = azurerm.azure 4 | name = var.azure_resource_group_name 5 | location = var.azure_region 6 | } 7 | 8 | # ------ Create Azure Virtual Network 9 | resource "azurerm_virtual_network" "virtual_network" { 10 | provider = azurerm.azure 11 | name = var.azure_virtual_network_name 12 | resource_group_name = azurerm_resource_group.resource_group.name 13 | location = azurerm_resource_group.resource_group.location 14 | address_space = [var.azure_vnet_address] 15 | } 16 | 17 | # ------ Create Azure Gateway Subnet 18 | resource "azurerm_subnet" "gateway_subnet" { 19 | provider = azurerm.azure 20 | name = var.gateway_subnet_name 21 | resource_group_name = azurerm_resource_group.resource_group.name 22 | virtual_network_name = azurerm_virtual_network.virtual_network.name 23 | address_prefixes = [var.azure_gateway_subnet] 24 | } 25 | 26 | # ------ Create Azure Compute Subnet 27 | resource "azurerm_subnet" "compute_subnet" { 28 | provider = azurerm.azure 29 | name = var.compute_subnet_name 30 | resource_group_name = azurerm_resource_group.resource_group.name 31 | virtual_network_name = azurerm_virtual_network.virtual_network.name 32 | address_prefixes = [var.azure_compute_subnet] 33 | } 34 | 35 | # ------ Create Azure Gateway Public IP 36 | resource "azurerm_public_ip" "gateway_public_ip" { 37 | provider = azurerm.azure 38 | name = var.gateway_public_ip_name 39 | location = azurerm_resource_group.resource_group.location 40 | resource_group_name = azurerm_resource_group.resource_group.name 41 | 42 | allocation_method = "Dynamic" 43 | } 44 | 45 | # ------ Create Azure Compute VM Public IP 46 | resource "azurerm_public_ip" "machine_public_ip" { 47 | provider = azurerm.azure 48 | name = var.azure_vm_public_ip_name 49 | location = azurerm_resource_group.resource_group.location 50 | resource_group_name = azurerm_resource_group.resource_group.name 51 | 52 | allocation_method = "Dynamic" 53 | } 54 | 55 | # ------ Create Azure Route Table 56 | resource "azurerm_route_table" "azure_route_table" { 57 | provider = azurerm.azure 58 | name = var.azure_route_table_name 59 | location = azurerm_resource_group.resource_group.location 60 | resource_group_name = azurerm_resource_group.resource_group.name 61 | disable_bgp_route_propagation = false 62 | } 63 | 64 | # ------ Create Azure Network Security Group 65 | resource "azurerm_network_security_group" "azure_nsg" { 66 | provider = azurerm.azure 67 | name = var.azure_nsg_name 68 | location = azurerm_resource_group.resource_group.location 69 | resource_group_name = azurerm_resource_group.resource_group.name 70 | 71 | security_rule { 72 | name = "ocicomputein" 73 | priority = 100 74 | direction = "Inbound" 75 | access = "Allow" 76 | protocol = "*" 77 | source_port_range = "*" 78 | destination_port_range = "*" 79 | source_address_prefix = oci_core_subnet.compute_subnet.cidr_block 80 | destination_address_prefix = "*" 81 | } 82 | 83 | security_rule { 84 | name = "admin-in" 85 | priority = 102 86 | direction = "Inbound" 87 | access = "Allow" 88 | protocol = "*" 89 | source_port_range = "*" 90 | destination_port_range = "*" 91 | source_address_prefix = "${trimsuffix(chomp(trimprefix(data.http.myip.body, "Current IP CheckCurrent IP Address: ")), "")}/32" 92 | destination_address_prefix = "*" 93 | } 94 | 95 | security_rule { 96 | name = "all" 97 | priority = 100 98 | direction = "Outbound" 99 | access = "Allow" 100 | protocol = "*" 101 | source_port_range = "*" 102 | destination_port_range = "*" 103 | source_address_prefix = "*" 104 | destination_address_prefix = "0.0.0.0/0" 105 | } 106 | 107 | } 108 | 109 | # ------ Associate Network Security Group to Compute Subnet 110 | resource "azurerm_subnet_network_security_group_association" "compute_subnet_network_security_group" { 111 | provider = azurerm.azure 112 | subnet_id = azurerm_subnet.compute_subnet.id 113 | network_security_group_id = azurerm_network_security_group.azure_nsg.id 114 | } 115 | 116 | # ------ Associate Network Security Group to Compute VM NIC 117 | resource "azurerm_network_interface_security_group_association" "compute_nic_network_security_group" { 118 | provider = azurerm.azure 119 | network_interface_id = azurerm_network_interface.compute_vm_vnic.id 120 | network_security_group_id = azurerm_network_security_group.azure_nsg.id 121 | } 122 | 123 | # ------ Associate Route Table to Compute Subnet 124 | resource "azurerm_subnet_route_table_association" "compute_subnet_route_table_associate" { 125 | provider = azurerm.azure 126 | subnet_id = azurerm_subnet.compute_subnet.id 127 | route_table_id = azurerm_route_table.azure_route_table.id 128 | } 129 | 130 | # ------ Associate Route Table to Gateway Subnet 131 | resource "azurerm_subnet_route_table_association" "gateway_subnet_route_table_associate" { 132 | provider = azurerm.azure 133 | subnet_id = azurerm_subnet.gateway_subnet.id 134 | route_table_id = azurerm_route_table.azure_route_table.id 135 | } 136 | -------------------------------------------------------------------------------- /new-environment/network-oci.tf: -------------------------------------------------------------------------------- 1 | # ------ Create OCI VCN 2 | resource "oci_core_vcn" "interconnect_vcn" { 3 | provider = oci.oci 4 | cidr_block = var.interconnect_vcn_cidr_block 5 | compartment_id = var.compartment_ocid 6 | display_name = "InterConnect VCN" 7 | dns_label = "interconnectvcn" 8 | } 9 | 10 | # ------ Create Public Compute Subnet 11 | resource "oci_core_subnet" "compute_subnet" { 12 | provider = oci.oci 13 | availability_domain = data.oci_identity_availability_domain.AD.name 14 | cidr_block = var.oci_compute_subnet 15 | display_name = var.oci_compute_subnet_display_name 16 | dns_label = var.oci_compute_subnet_dns_label 17 | security_list_ids = [oci_core_security_list.security_policies_azure.id] 18 | compartment_id = var.compartment_ocid 19 | vcn_id = oci_core_vcn.interconnect_vcn.id 20 | route_table_id = oci_core_route_table.compute_route_table.id 21 | dhcp_options_id = oci_core_vcn.interconnect_vcn.default_dhcp_options_id 22 | } 23 | 24 | # ------ Create OCI VCN Internet Gateway 25 | resource "oci_core_internet_gateway" "internet_gateway" { 26 | provider = oci.oci 27 | compartment_id = var.compartment_ocid 28 | display_name = var.internet_gateway_name 29 | vcn_id = oci_core_vcn.interconnect_vcn.id 30 | } 31 | 32 | # ------ Create OCI Compute Route Table 33 | resource "oci_core_route_table" "compute_route_table" { 34 | provider = oci.oci 35 | compartment_id = var.compartment_ocid 36 | vcn_id = oci_core_vcn.interconnect_vcn.id 37 | display_name = var.compute_route_table_display_name 38 | 39 | route_rules { 40 | destination = "0.0.0.0/0" 41 | destination_type = "CIDR_BLOCK" 42 | network_entity_id = oci_core_internet_gateway.internet_gateway.id 43 | } 44 | route_rules { 45 | destination = azurerm_virtual_network.virtual_network.address_space[0] 46 | destination_type = "CIDR_BLOCK" 47 | network_entity_id = oci_core_drg.drg_azure.id 48 | } 49 | } 50 | 51 | # ------ Create DRG on OCI 52 | resource "oci_core_drg" "drg_azure" { 53 | provider = oci.oci 54 | compartment_id = var.compartment_ocid 55 | } 56 | 57 | # ------ Create Security Policies on Azure 58 | resource "oci_core_security_list" "security_policies_azure" { 59 | provider = oci.oci 60 | compartment_id = var.compartment_ocid 61 | display_name = var.security_policy_name 62 | vcn_id = oci_core_vcn.interconnect_vcn.id 63 | 64 | egress_security_rules { 65 | protocol = "all" 66 | destination = "0.0.0.0/0" 67 | } 68 | 69 | ingress_security_rules { 70 | protocol = "all" 71 | source = azurerm_virtual_network.virtual_network.address_space[0] 72 | } 73 | 74 | ingress_security_rules { 75 | protocol = "all" 76 | source = "0.0.0.0/0" 77 | } 78 | 79 | } 80 | 81 | # ------ Create DRG Attachment on Azure 82 | resource "oci_core_drg_attachment" "drg_attachment" { 83 | provider = oci.oci 84 | drg_id = oci_core_drg.drg_azure.id 85 | vcn_id = oci_core_vcn.interconnect_vcn.id 86 | } 87 | -------------------------------------------------------------------------------- /new-environment/networkgateway.tf: -------------------------------------------------------------------------------- 1 | # ------ Create Virtual Network Gateway on Azure 2 | resource "azurerm_virtual_network_gateway" "virtual_network_gateway" { 3 | provider = azurerm.azure 4 | name = var.virtual_network_gateway_name 5 | location = azurerm_resource_group.resource_group.location 6 | resource_group_name = azurerm_resource_group.resource_group.name 7 | 8 | type = "ExpressRoute" 9 | sku = "UltraPerformance" 10 | 11 | ip_configuration { 12 | name = "vnetGatewayConfig" 13 | public_ip_address_id = azurerm_public_ip.gateway_public_ip.id 14 | private_ip_address_allocation = "Dynamic" 15 | subnet_id = azurerm_subnet.gateway_subnet.id 16 | } 17 | } 18 | 19 | # ------ Create Virtual Network Gateway ExpressRoute Connection 20 | resource "azurerm_virtual_network_gateway_connection" "virtual_network_gateway_connection" { 21 | provider = azurerm.azure 22 | name = var.virtual_network_gateway_connection_name 23 | location = azurerm_resource_group.resource_group.location 24 | resource_group_name = azurerm_resource_group.resource_group.name 25 | // Below commented line enables Fast Path on ExpressRoute, uncomment it if you need Fast Path (Additional Cost associated with this) 26 | //express_route_gateway_bypass = "true" 27 | type = "ExpressRoute" 28 | virtual_network_gateway_id = azurerm_virtual_network_gateway.virtual_network_gateway.id 29 | express_route_circuit_id = azurerm_express_route_circuit.express_route_circuit.id 30 | } 31 | -------------------------------------------------------------------------------- /new-environment/output.tf: -------------------------------------------------------------------------------- 1 | # ------ Output Azure VM Public IP 2 | output "azure_server_public_ip" { 3 | value = azurerm_linux_virtual_machine.azure_compute_vm.public_ip_address 4 | } 5 | 6 | # ------ Output Oracle Server Public IP 7 | output "oracle_server_public_ip" { 8 | value = oci_core_instance.oci_compute_instance.public_ip 9 | } 10 | 11 | # ------ Initial Instructions 12 | output "initial_instruction" { 13 | value = <