|
| 1 | +# Networking Scenarios |
| 2 | + |
| 3 | +## Greenfield Tenancies |
| 4 | + |
| 5 | +**NOTE-** |
| 6 | +Before you start with Network Creation, make sure you have run 'Fetch Compartments OCIDs to variables file'. |
| 7 | + |
| 8 | +### 1. Create Network |
| 9 | +Creation of Networking components using Automation Toolkit involes four simple steps. |
| 10 | + - Add the networking resource details to appropriate Excel Sheets. |
| 11 | + - Running the toolkit to generate auto.tfvars. |
| 12 | + - Executing Terraform commands to provision the resources in OCI. |
| 13 | + - Exporting the details of Security Rules and Route Rules to CD3 Excel Sheet as they are generated automatically by the toolkit and needs to be updated in CD3 Excel sheet, |
| 14 | + |
| 15 | +Below are the steps in detail to create Network that includes VCNs, Subnets, DHCP, DRG, Security List, Route Tables, DRG Route Tables, NSGs, etc. |
| 16 | + |
| 17 | +1. Choose appropriate excel sheet from [Excel Templates](/cd3_automation_toolkit/documentation/user_guide/RunningAutomationToolkit.md#excel-sheet-templates) and fill the required Network details in the Networking Tabs - VCNs, DRGs, VCN Info, DHCP, Subnets, NSGs tabs. |
| 18 | + |
| 19 | +2. Execute the _setupOCI.py_ file with _non_gf_tenancy_ parameter value to _false_: |
| 20 | + |
| 21 | + ```python setUpOCI.py /cd3user/tenancies/<customer_name>/<customer_name>_setUpOCI.properties``` |
| 22 | + |
| 23 | +3. Choose option _'Validate CD3'_ and then _'Validate Network(VCNs, Subnets, DHCP, DRGs)'_ to check for syntax errors in Excel sheet. Examine the log file generated at _/cd3user/tenancies/<customer\_name>/<customer\_name>\_cd3validator.log_. If there are errors, please rectify them accordingly and proceed to the next step. |
| 24 | + |
| 25 | +4. Choose option to _'Create Network'_ under _'Network'_ from the displayed menu. Once the execution is successful, multiple .tfvars related to networking like _<customer\_name>\_major-objects.auto.tfvars_ and more will be generated under the folder _/cd3user/tenancies/<customer\_name>/terraform_files/<region_dir>_ |
| 26 | + |
| 27 | +5. Navigate to the above path and execute the terraform commands:<br> |
| 28 | + <br>_terraform init_ |
| 29 | + <br>_terraform plan_ |
| 30 | + <br>_terraform apply_ |
| 31 | + |
| 32 | + This completes the creation of Networking components in OCI. Verify the components in console. However the details of the default security lists and default route tables may not be available in the CD3 Excel sheet yet. Inorder to export that data please follow the below steps: |
| 33 | + |
| 34 | +6. Execute the _setupOCI.py_ file with _non_gf_tenancy_ parameter value to _false_: |
| 35 | + |
| 36 | + ```python setUpOCI.py /cd3user/tenancies/<customer_name>/<customer_name>_setUpOCI.properties``` |
| 37 | + |
| 38 | +7. Choose _'Network'_ from the displayed menu. Choose below sub-options: (Make sure to choose all the three optionsfor the first time) |
| 39 | + - Security Rules |
| 40 | + - Export Security Rules (From OCI into SecRulesinOCI sheet) |
| 41 | + - Route Rules |
| 42 | + - Export Route Rules (From OCI into RouteRulesinOCI sheet) |
| 43 | + - DRG Route Rules |
| 44 | + - Export DRG Route Rules (From OCI into DRGRouteRulesinOCI sheet) |
| 45 | + |
| 46 | +This completes the steps for Creating the Network in OCI and exporting the default rules to the CD3 Excel Sheet using the Automation Toolkit. |
| 47 | + |
| 48 | +### 1a. Use an existing DRG in OCI while creating the network |
| 49 | +In some scenarios, a DRG has already been created in the tenancy and rest of the Network components still need to be created. In such cases, generate the networking related tfvars using same process mentioned above till Step 4. |
| 50 | + |
| 51 | + - For Step 5, Navigate to the outdir path and execute the terraform commands:<br> |
| 52 | + <br>_terraform init_ |
| 53 | + <br>_terraform import "module.drgs[\"<<drgs terraform variable name>>\"].oci_core_drg.drg" <<drg-ocid>>_ |
| 54 | + <br> → This will Import the DRG into your state file. |
| 55 | + _terraform plan_ |
| 56 | + <br> → Terraform Plan will indicate to add all the other components except DRG. |
| 57 | + <br>_terraform apply_ |
| 58 | + |
| 59 | + Continue executing the remaining steps of [Create Network](#1-create-network). |
| 60 | + |
| 61 | +### 2. Modify Network |
| 62 | +Modifying the Networking components using Automation Toolkit involves three simple steps. |
| 63 | + - Add/modify the details of networking components like the VCNs, Subnets, DHCP and DRG in Excel Sheet. |
| 64 | + - Running the toolkit to generate auto.tfvars. |
| 65 | + - Executing Terraform commands to provision/modify the resources in OCI. |
| 66 | + |
| 67 | +_Steps in detail_: |
| 68 | +1. Modify your excel sheet to update required data in the Tabs - VCNs, DRGs, VCN Info, DHCP and Subnets. |
| 69 | + |
| 70 | +2. Execute the _setupOCI.py_ file with _non_gf_tenancy_ parameter value to _false_: |
| 71 | + |
| 72 | + ```python setUpOCI.py /cd3user/tenancies/<customer_name>/<customer_name>_setUpOCI.properties``` |
| 73 | + |
| 74 | +3. To Validate the CD3 excel Tabs - Choose option _'Validate CD3'_ and _'Validate Network(VCNs, Subnets, DHCP, DRGs)'_ from sub-menu to check for syntax errors in Excel sheet. Examine the log file generated at _/cd3user/tenancies/<customer\_name>/<customer\_name>\_cd3validator.logs_. If there are errors, please rectify them accordingly and proceed to the next step. |
| 75 | + |
| 76 | +4. Choose option to _'Modify Network'_ under _'Network'_ from the displayed menu. Once the execution is successful, multiple .tfvars related to networking like _<customer\_name>\_major-objects.auto.tfvars_ and more will be generated under the folder _/cd3user/tenancies/<customer\_name>/terraform_files/<region_dir>_. Existing files will move into respective backup folders. |
| 77 | + |
| 78 | + **Note-**: Make sure to export Sec Rules, Route Rules, DRG Route Rules to CD3 Excel Sheet before executing this option. |
| 79 | + |
| 80 | +5. Navigate to the above path and execute the terraform commands:<br> |
| 81 | + <br>_terraform init_ |
| 82 | + <br>_terraform plan_ |
| 83 | + <br>_terraform apply_ |
| 84 | + |
| 85 | +This completes the modification of Networking components in OCI. Verify the components in console. |
| 86 | + |
| 87 | +### 3. Modify Security Rules, Route Rules and DRG Route Rules |
| 88 | + |
| 89 | +Follow the below steps to add, update or delete the following components: |
| 90 | +- Security Lists and Security Rules |
| 91 | +- Route Table and Route Rules |
| 92 | +- DRG Route Table and DRG Route Rules |
| 93 | + |
| 94 | +1. Modify your excel sheet to update required data in the Tabs - RouteRulesInOCI, SecRulesInOCI, DRGRouteRulesInOCI tabs. |
| 95 | + |
| 96 | +2. Execute the _setupOCI.py_ file with _non_gf_tenancy_ parameter value to _false_: |
| 97 | + |
| 98 | + ```python setUpOCI.py /cd3user/tenancies/<customer_name>/<customer_name>_setUpOCI.properties``` |
| 99 | + |
| 100 | +4. Choose _'Network'_ from the displayed menu. Choose below sub-options: |
| 101 | + - Security Rules |
| 102 | + - Add/Modify/Delete Security Rules (Reads SecRulesinOCI sheet) |
| 103 | + - Route Rules |
| 104 | + - Add/Modify/Delete Route Rules (Reads RouteRulesinOCI sheet) |
| 105 | + - DRG Route Rules |
| 106 | + - Add/Modify/Delete DRG Route Rules (Reads DRGRouteRulesinOCI sheet) |
| 107 | + |
| 108 | + Once the execution is successful, _<customer\_name>\_seclists.auto.tfvars_, _<customer\_name>\_routetables.auto.tfvars_ and _<customer\_name>\_drg-routetables.auto.tfvars_ file will be generated under the folder _/cd3user/tenancies/<customer\_name>/terraform_files/<region_dir>_. Existing files will move into respective backup folders. |
| 109 | + |
| 110 | + **NOTE**: This will create TF for only those Security Lists and Route Tables in VCNs which are part of cd3 and skip any VCNs that have been created outside of cd3 execution. |
| 111 | + |
| 112 | + Navigate to the above path and execute the terraform commands:<br> |
| 113 | + <br>_terraform init_ |
| 114 | + <br>_terraform plan_ |
| 115 | + <br>_terraform apply_ |
| 116 | + |
| 117 | + This completes the modification of Security Rules, Route Rules and DRG Route Rules in OCI. Verify the components in console. |
| 118 | + |
| 119 | + |
| 120 | +### 4. Export the Security Rules, Route Rules and DRG Route Rules to sync the manual changes in OCI with CD3 Excel Sheet and Terraform |
| 121 | +Follow the below process to export the rules to the same CD3 Excel Sheet as the one used to Create Network, and to sync the Terraform files with OCI whenever an user adds, modifies or deletes rules in OCI Console manually. |
| 122 | + |
| 123 | +**NOTE**: Make sure to close your Excel sheet during the export process. |
| 124 | + |
| 125 | +1. Execute the _setupOCI.py_ file with _non_gf_tenancy_ parameter value to _false_: |
| 126 | + |
| 127 | + ```python setUpOCI.py /cd3user/tenancies/<customer_name>/<customer_name>_setUpOCI.properties``` |
| 128 | + |
| 129 | +2. Choose _'Network'_ from the displayed menu. Choose below sub-options: |
| 130 | + - Security Rules |
| 131 | + - Export Security Rules (From OCI into SecRulesinOCI sheet) |
| 132 | + - Route Rules |
| 133 | + - Export Route Rules (From OCI into RouteRulesinOCI sheet) |
| 134 | + - DRG Route Rules |
| 135 | + - Export DRG Route Rules (From OCI into DRGRouteRulesinOCI sheet) |
| 136 | + |
| 137 | + Once the execution is successful, 'RouteRulesInOCI', 'SecRulesInOCI', 'DRGRouteRulesInOCI' tabs of the excel sheet will be updated with the rules exported from OCI. At this point, we only have our Excel sheet Tabs updated, proceed to the next step to create the Terraform Files for the same. |
| 138 | + |
| 139 | +3. Choose _'Network'_ from the displayed menu. Choose below sub-options: |
| 140 | + - Security Rules |
| 141 | + - Add/Modify/Delete Security Rules (Reads SecRulesinOCI sheet) |
| 142 | + - Route Rules |
| 143 | + - Add/Modify/Delete Route Rules (Reads RouteRulesinOCI sheet) |
| 144 | + - DRG Route Rules |
| 145 | + - Add/Modify/Delete DRG Route Rules (Reads DRGRouteRulesinOCI sheet) |
| 146 | + |
| 147 | + Once the execution is successful, _<customer\_name>\_seclists.auto.tfvars_, _<customer\_name>\routetables.auto.tfvars_ and _<customer\_name>\drg-routetables.auto.tfvars_ file will be generated under the folder _/cd3user/tenancies/<customer\_name>/terraform_files/<region_dir>_ |
| 148 | + |
| 149 | + Navigate to the above path and execute the terraform commands:<br> |
| 150 | + <br>_terraform init_ |
| 151 | + <br>_terraform plan_ |
| 152 | + <br>_terraform apply_ |
| 153 | + |
| 154 | + This completes the export of Security Rules, Route Rules and DRG Route Rules from OCI. Terraform plan/apply should be in sync with OCI. |
| 155 | + |
| 156 | + |
| 157 | +### 5. Add/Modify/Delete NSGs |
| 158 | +Follow the below steps to update NSGs. |
| 159 | + |
| 160 | +1. Modify your excel sheet to update required data in the Tabs - NSGs. |
| 161 | + |
| 162 | +2. Execute the _setupOCI.py_ file with _non_gf_tenancy_ parameter value to _false_: |
| 163 | + |
| 164 | + ```python setUpOCI.py /cd3user/tenancies/<customer_name>/<customer_name>_setUpOCI.properties``` |
| 165 | + |
| 166 | +3. Choose _'Network'_ from the displayed menu. Choose below sub-option: |
| 167 | + - Network Security Groups |
| 168 | + - Add/Modify/Delete NSGs (Reads NSGs sheet) |
| 169 | + |
| 170 | + Once the execution is successful, _<customer\_name>\_nsgs.auto.tfvars_ will be generated under the folder _/cd3user/tenancies/<customer\_name>/terraform_files/<region_dir>_. Existing files will move into respective backup folders. |
| 171 | + |
| 172 | +4. Navigate to the above path and execute the terraform commands:<br> |
| 173 | + <br>_terraform init_ |
| 174 | + <br>_terraform plan_ |
| 175 | + <br>_terraform apply_ |
| 176 | + |
| 177 | +This completes the modification of NSGs in OCI. Verify the components in console. |
| 178 | + |
| 179 | + |
| 180 | +<br><br> |
| 181 | +<div align='center'> |
| 182 | + |
| 183 | +| <a href="/cd3_automation_toolkit/documentation/user_guide/Workflows.md">:arrow_backward: Prev</a> | <a href="/cd3_automation_toolkit/documentation/user_guide/QuickstartNGF.md">Next :arrow_forward:</a> | |
| 184 | +| :---- | -------: | |
| 185 | + |
| 186 | +</div> |
0 commit comments