Invoke Terraform Scripts

Use specific commands to invoke the Terraform scripts in Oracle WebLogic Server for OCI.

Note:

You can download a previous version of the terraform script from: https://releases.hashicorp.com/terraform/

Invoke terraform scripts in an infrastructure

Complete the following steps:
  1. Go to the directory where you unpacked the Terraform Configuration File (.zip) file using Download a Terraform Configuration File.
  2. In this directory, create a terraform file: terraform.tfvars
  3. In the terraform.tfvars file, add the variables that are referenced in the provider.tf file.

    These are the variables that you noted in the provider.tf file in Download a Terraform Configuration File.

    For a sample of terraform.tfvars file, see Sample Scripts.

  4. Run the following command to initialize the terraform provider plugin:
    $ terraform init
  5. Add in the variables required for the desired topology to the terraform.tfvars file.

    For the list of variables, see Variables in Terraform Scripts and Sample Scripts.

  6. Run the following command to invoke apply:
    $ terraform apply
  7. Optional: Run the following command to create multiple instances from same solutions:
    $ terraform apply -state=<file_name>

    Where, <file_name> is the unique directory name or state file name for each stack.

Update an infrastructure:

Complete the following steps:
  1. Go to the directory where you unpacked the Terraform Configuration File (.zip) file using Download a Terraform Configuration File.
  2. In this directory, create a terraform file: terraform.tfvars
  3. In the terraform.tfvars file, add the variables that are referenced in the provider.tf file.

    These are the variables that you noted in the provider.tf file in Download a Terraform Configuration File.

    For a sample of terraform.tfvars file, see Sample Scripts.

  4. Update the variables required for the desired topology to the terraform.tfvars file. For the list of variables you can update, see Table 1-1.
  5. Run the following command to invoke apply:
    $ terraform apply

Destroy an infrastructure

Depending on your environment, run the following command to destroy an infrastructure:
$ terraform destroy

Tip:

You can invoke terraform scripts by using the Resource Manager. See Get Started with Oracle WebLogic Server for Oracle Cloud Infrastructure and Managing Stacks and Jobs.