Verifying Terraform Configuration on a Local Machine

If you’re publishing your Terraform configuration to the Oracle Cloud Marketplace for the first time, we recommend that you test your Terraform configuration on your local machine.

This step is optional. To skip it, you can directly test your Terraform configuration files in Oracle Resource Manager. See Terraform Configurations for Resource Manager.

To test your Terraform configuration on your local machine, follow these steps:

  1. Set the following attributes to point to your Oracle Cloud Infrastructure tenancy in which you have created the custom image.
    provider "oci" {
      region           = var.region
      tenancy_ocid     = var.tenancy_ocid
      user_ocid        = var.user_ocid
      fingerprint      = var.fingerprint
      private_key_path = var.private_key_path
    }

    Where, region is the Oracle Cloud Infrastructure region in which you have created the custom image.

    tenancy_ocid is the OCID of the tenancy in which you have created the custom image.

    For information about defining providers, see Configuration File Requirements in Oracle Cloud Infrastructure documentation.

  2. Run the following commands to test your terraform configuration file on your local machine.
    $ terraform init
    $ terraform plan
    $ terraform apply
  3. After running these commands, check for the following:
    • All the Oracle Cloud Infrastructure resources that you defined in the terraform configuration were created in your Oracle Cloud Infrastructure tenancy.
    • Your application is working correctly without involving any other service.
    • An instance is created in Oracle Cloud Infrastructure by using the custom image OCID that you have specified. In Oracle Cloud Infrastructure console, validate that a new instance has been created using the custom image that you have created.

If you get the expected results, then proceed to the next step. If any changes are required, make the required changes to the terraform configuration file, test the updated file on your local machine before you proceed with the next step.