Running templates from CLI

You can run templates from CLI, similar to running the Terraform templates from OCI Resource Manager.

To run the templates from CLI:

  1. Download Terraform from the following URL and install Terraform.

    https://www.terraform.io/downloads.html

  2. Download the Terraform stack builder file.

    Note:

    The VCN and SBC folder is a part of the Terraform stack builder tar file (For example - SCZ910_tfStackBuilder.tar.gz).
  3. Extract the Terraform stack builder file.
    tar -xzvf <filename>_tfStackBuilder.tar.gz 
    
  4. Change directory to point to the SBC folder.
    cd oci/SBC

    Note:

    If you are creating a VCN, change directory to VCN folder.
  5. Uncomment these lines in the provider.tf file.
    user_ocid = var.user_ocid  
    fingerprint = var.fingerprint  
    private_key_path = var.oci_api_private_key_path
  6. Save the file.
  7. Export the required environment variables. For example:
    export TF_VAR_region="us-phoenix-1"
    export TF_VAR_tenancy_ocid="ocid1.tenancy.oc1..aaaaaaauhdcynzumstqiwxbx5d2mkmeqflyfnwsta6gn4g7ofmnfkq"
    export TF_VAR_compartment_ocid="ocid1.compartment.oc1..aaaaaaaa6pylpay5csm5xw2e5tzine24vtvqpguepm7g45r4rrr7cla"
    export TF_VAR_oci_api_private_key_path="$HOME/.oci/oci_api_key.pem"
    export TF_VAR_user_ocid="ocid1.user.oc1..aaaaaa7f76hacxruga2hjsgp2vqsypx7ejaqrbv54vgxhymnq"
    export TF_VAR_fingerprint="cb:b6:86:6:6d:9c:8a:88:3b:85:72:f9:47:34:5c:43"
  8. Edit the terraform.tfvars file and change the configuration variables as required.
  9. Save the file.
  10. Edit the entitlements/<product>.yaml file and change the entitlement parameters as required.
  11. Save the file.
  12. Run this command to initiate Terraform.
    terraform init
  13. Run this command to verify the templates and new OCI resource that will be created based on the configuration variables.
    terraform plan
  14. Run this command to create the resources.
    terraform apply
  15. Run this command to destroy the resources.
    terraform destroy
  16. Change directory to point to the VCN folder.
    cd oci/VCN

Repeat steps 5 through 15 to create a VCN stack.