Configure CD3 Toolkit with CLI to Create and Export Oracle Cloud Infrastructure Resources
Objectives
-
Launch the CD3 container resource manager stack with a single click and create OCI Networking and OCI Compute resources using CD3 CLI.
-
Export OCI Networking and OCI Compute resources using CD3 CLI.
Prerequisites
-
Oracle Cloud Infrastructure Identity and Access Management (OCI IAM) policy to allow user or instance principal to manage the services that are required to be created or exported using the toolkit.
-
The user deploying the stack should have access to launch OCI Resource Manager stack, OCI Compute instance and OCI Networking resources.
Task 1: Set up the Toolkit Container
-
Click Deploy to Oracle Cloud to launch the OCI Resource Manager stack that provisions the CD3 workVM.
-
Accept the terms and conditions, then provide the required details, including the Network, Compartment, VM Name, and Shape.
Note: For security, specify a restricted source CIDR range to access the VM. Avoid using
0.0.0.0/0. -
Check the Run Apply section and click Create to deploy the stack
-
After the Apply job completes successfully, open the job logs and scroll to the end.
-
Locate the details for the created VM and commands required to log in to the toolkit container. The following image shows a sample output.

-
After logging in to the container using
sudo podman exec -it cd3_toolkit bash, proceed to Task 2 to connect the toolkit to your OCI tenancy.
Task 2: Connect the Container to your OCI Tenancy
-
Inside the container, navigate to
cd3_automation_toolkit folderand open theconnectOCI.propertiesfile . -
Add the required configuration values in the Required parameters and Auth Details Parameters sections.
Note: This tutorial uses API key authentication. Leave the
auth_mechanismparameter at its default value. -
Go to the OCI Console, under User settings, upload public key to APIkeys. Fetch the required config values and update under the corresponding parameters in
connectOCI.propertiesfile.Place the associated private key in the container. -
Leave the default value for the
outdir_structure_fileparameter. This setting organizes the generatedauto.tfvarsfiles into service-specific directories.
Note: Leave the Advanced Parameters for DevOps section unchanged since Jenkins set up is not in the scope of this tutorial. To run the toolkit using Jenkins, checkout Create and Export OCI Resources Using Jenkins
-
Save the file and run
connectCloud.py ocito initialize the environment and start using CD3. -
Verify that the initialization completes successfully.

After the environment is initialized, proceed to Task 3 to create OCI resources or Task 4 to export existing OCI resources.
Task 3: Create Resources
Task 3.1: Prepare the Excel template and Variables File
-
Download the prefilled Excel template and update the Region and Compartment values to match your OCI environment
-
Copy the Excel file inside the container at
/cd3user/tenancies/<prefix>/using below scp command.scp -i <ssh_private_key_path> /Users/xyz/cd3quickstart.xlsx cd3user@<workvm_ip>:/cd3user/mount_path/tenancies/<prefix>/cd3quickstart.xlsxNote: The tenancies folder in the CD3 container is mapped to the
/cd3user/mount_path/tenancies/folder in the compute VM. Log in withcd3userto avoid permission issues. -
Open
/cd3user/tenancies/<prefix>/terraform_files/<region>/compute/variables_<region>.tffrom the container. Under theinstance_ssh_keysvariable, add the SSH public key variable referenced in the Excel template (ssh_public_key) and assign the corresponding key value.
-
Under the
instance_source_ocidsvariable, add the source image variable referenced in the Excel template (myimageocid) and assign the corresponding image OCID.
Task 3.2: Run the setUpCloud.py Script to Generate Resource Terraform Files
-
Open the
/cd3user/tenancies/<prefix>/<prefix>_setUpOCI.propertiesfile and add the CD3 excel file path under thecd3filevariable. Setworkflow_typevariable tocreate_resourcesand save the file.
-
Change the directory to
cd /cd3user/oci_tools/cd3_automation_toolkit/and run thesetUpCloud.pyscript.Note: If you are running the script for the first time, select y for the Execute Script to fetch the compartment OCIDs into variables file prompt .

-
From the menu, select:
- Network → Create Network to generate Terraform files for VCNs and subnets.
- Compute → Add/Modify/Delete Instances/Boot Backup Policy to generate Terraform files for compute instances.
-
Navigate to the network Terraform directory and provision the networking resources.
-
Create Network generates Security/Route rules in the VCN that are not initially present in the CD3 Excel template (as these details are initially taken from the subnets tab).
To synchronize them to the Security Rules and Route Rules sheets in Excel file, run thesetUpCloud.pyscript again using the same Excel sheet as above. Ensure thatworkflow_typeremains set tocreate_resourcesin the<prefix>_setUpOCI.propertiesfile. Select Network under main options and then the below sub-options.Security Rules ---> Export Security Rules (From OCI into SecRulesinOCI sheet), Add/Modify/Delete Security Rules (Reads SecRulesinOCI sheet) Route Rules ---> Export Route Rules (From OCI into RouteRulesinOCI sheet), Add/Modify/Delete Route Rules (Reads RouteRulesinOCI sheet) DRG Route Rules ---> Export DRG Route Rules (From OCI into DRGRouteRulesinOCI sheet), Add/Modify/Delete DRG Route Rules (Reads DRGRouteRulesinOCI sheet) -
Once exported, The
SecRulesinOCI,RouteRulesinOCI, andDRGRouteRulesinOCIsheets are populated in the Excel template.The following Terraform variable files are generated:
<prefix>_seclists.auto.tfvars
<prefix>_routetables.auto.tfvars
<prefix>_drg-routetables.auto.tfvarsThese files are located under:
/cd3user/tenancies/<prefix>/terraform_files/<region>/network/ -
Verify
terraform planandterraform apply. Running terraform apply completes the export of security rules, route rules and DRG route rules from OCI. The terraform state is now synchronized with OCI. -
To provision compute resources, change the directory to
/cd3user/tenancies/<prefix>/terraform_files/<region>/compute/and run the Terraform commands.
Verify that the networking and compute resources have been successfully provisioned in the OCI Console.
Task 4: Export Resources
Task 4.1: Add Excel Template to the Container
-
Download CD3-Blank-template and add it to the container at
/cd3user/tenancies/<prefix>/.scp -i <ssh_private_key_path> /Users/xyz/CD3-Blank-template.xlsx cd3user@<workvm_ip>:/cd3user/mount_path/tenancies/<prefix>/CD3-Blank-template.xlsxNote: The tenancies folder in cd3 container is mapped to the
/cd3user/mount_path/tenancies/folder in the CD3 work VM. Log in withcd3userto avoid permission issues. -
Navigate to the
/cd3user/tenancies/<prefix>/folder and open the<prefix>_setUpOCI.propertiesfile. -
Add the CD3 Excel file path under the variable
cd3file. -
Set the
workflow_typeparameter toexport_resourcesand save the file.
Task 4.2: Run the setUpCloud.py Script
-
Navigate to
cd /cd3user/oci_tools/cd3_automation_toolkit/and run thesetUpCloud.pyscript.Note: If you are running the script for the first time, select y for the Execute Script to fetch the compartment OCIDs into variables file prompt.

-
Provide comma separated
regionvalues if you have to export resources from multiple regions. If no region value is provided, the toolkit will export resources from all subscribed regions. -
Select the resource types to be exported (Network and Compute). You can choose to export the resources only from specific compartments or all compartments. If the compartment name is not unique, it should be specified in the following format based on the hierarchy.
-
To export only specific resources, provide the requested filter values when prompted.
Note: For additional information, see:
- Export OCI Networking Resources
- Export OCI Compute Resources -
After successful completion, the exported resource data is populated in the input Excel file. The updated Excel file is present under the
/cd3user/tenancies/<prefix>folder inside the container and needs to be copied manually to the local system using scp command. -
CD3 generates service-specific
.tfvarsfiles and terraform import shell scripts in the corresponding service directories. These files are used to sync the resources into Terraform state. -
/cd3user/tenancies/<prefix>/terraform_files/<region_dir>/network/ -
/cd3user/tenancies/<prefix>/terraform_files/<region_dir>/compute/
Task 4.3: Import Resources into Terraform State
-
From the network and compute service folders, execute each of the generated
.shfiles containing Terraform import commands.Note: For OCI Networking, ensure to run the
sh import_commands_network_major-objects.shfirst -
After all import scripts have run successfully, the Terraform state is populated with the exported OCI resources and the Terraform configuration is synchronized with the current OCI environment.
The generated Terraform code can be deployed using OCI Resource Manager or integrated into your organization's CI/CD workflows for ongoing infrastructure management.