Migrate Terraform Scripts v0.12.31 to v1.5.x
This appendix describes the steps required to manually upgrade your existing WLS for OCI ORM stack from Terraform version v0.12.31 to v1.5.x.
Note:
-
Oracle recommends that you migrate your Terraform v0.12.31 scripts to v1.5.x using the clone and move procedures described in Clone a Stack. If you are unable to clone your instance, then you can use the steps in this appendix.
-
Terraform versions earlier than 1.5.x will be deprecated and no longer supported after December 31, 2025.
-
You can access the Terraform Scripts of an Oracle WebLogic Server for OCI and modify them as needed. See Terraform Scripts in Oracle WebLogic Server for OCI.
The steps required to manually upgrade your existing WLS for OCI ORM stack from Terraform version v0.12.31 to v1.5.x include the following:
- Prerequisites
- Upgrade Path(s)
- Upgrade from Terraform version 0.12.31 to 0.13.7
- Upgrade from Terraform version 0.13.7 to 0.14.11
- Upgrade from Terraform version 0.14.11 to 1.5.7
Prerequisites
To successfully upgrade your stack, you must have the following requirements:
-
A MacOS, Linux, or Windows computer for running command line tools
-
Software to create and unpack
.ziparchives, such as 7-ZIP
Upgrade Path(s)
The process of upgrading from v0.12.31 to v1.5.7 involves three separate steps - a direct upgrade from v0.12.31 to v1.5.7 is not supported.
The supported upgrade path for v0.12.31 to v1.5.7 involves the following:
- Upgrade v0.12.x to target version 0.13.x.
- Upgrade v0.13.x to target version 0.14.x.
- Upgrade 0.14.x, 1.0.x, 1.1.x, or 1.2.x to target version 1.5.x.
Upgrade from Terraform version 0.12.31 to 0.13.7
Step 1: Ensure your infrastructure is up-to-date.
Note:
This step can be skipped if the existing Terraform version is not supported by ORM. For example, if ORM does not allow execute commands on the stack like Plan or Apply, then you can skip this step.
- On the Stacks list page, select the stack that you want to work with. If you need help finding the list page or the stack, see Listing Stacks.
-
Confirm that the details page for the stack shows the expected version (Terraform version).
To obtain stack details using CLI or API, see Getting a Stack's Details.
- Check for pending changes to infrastructure:
-
Select Plan.
When the action finishes, the details page for the related job opens. For CLI and API instructions, see Creating a Plan Job.
-
To review the log for the completed plan action, select Logs.
The log contents indicate whether the stack is up-to-date or has pending changes.
-
- If the log contents indicate pending changes, then apply pending changes:
-
Select Stack details to go back to the details page for the stack.
-
Select Apply.
For CLI and API instructions, see Creating an Apply Job. When the action finishes, the details page for the related job opens.
-
Confirm that the apply action was successful: Select Logs to review the log for the completed plan action. For CLI and API instructions, see Getting Logs for a Job.
-
When the stack infrastructure is updated, you can proceed to the next task.
Step 2: Download the Terraform configuration and state files of existing stack.
- On a computer that can run command line tools, create a folder to store
the downloaded Terraform configuration and state.
Example folder name:
/Users/<GUID>/Downloads/stack_terraform_config/ - From the Console: On the Stacks list page, select the stack that you want to work with. If you need help finding the list page or the stack, see Listing Stacks.
- Next to Terraform configuration, select Download.
For CLI and API instructions, see Getting a Stack's Terraform Configuration.
- Download the Terraform state file:
- On the stack's details page, select View state.
- To download the stack's state file, go to More actions and select Download Terraform state.
For CLI and API instructions, see Getting a Stack's State File.
When the Terraform configuration and state are downloaded, you can proceed to the next task for upgrading the Terraform configuration.
- Extract the downloaded Terraform
configuration zip. - Create a file named
versions.tfto update the provider configuration. The required target version for Terraform should be 0.13.7.# Copyright (c) 2023, 2025, Oracle and/or its affiliates. # Licensed under the Universal Permissive License v1.0 as shown at https://oss.oracle.com/licenses/upl. terraform { required_version ="~> 0.13.7" required_providers { oci = { source = "oracle/oci" version = "~> 7.17.0" } random = { version = "~> 3.7.2" } template = { version = "~> 2.2.0" } tls = { version = "~> 4.1.0" } time = { version = "~> 0.13.7" } null = { version = "~> 3.2.4" } } } - Due to structural and syntax changes between the version v0.12.31 and v0.13.7,
the following configuration changes are required before starting the upgrade:
- Delete the
terraform.tffile. This file is no longer required by Terraform version 0.13.7 or later. - Create a
versions.tffile under each module folder to configure which OCI provider should be used by each module.Note:
The following example shows the file in one folder under compute module. This needs to be replicated in all directories under each module folder.# Copyright (c) 2022, Oracle and/or its affiliates. # Licensed under the Universal Permissive License v1.0 as shown at https://oss.oracle.com/licenses/upl. terraform { required_providers { oci = { source = "oracle/oci" } } } - If a load balancer is present in the stack, then you will
need to fix the load balancer backend certificat error shown below.You
can skip this step if load balancer is not present.
Remove
key_algorithm = "RSA"from filemodules/lb/backends/certificate.tf.Error: Invalid Configuration for Read-Only Attribute on modules/lb/backends/certificate.tf line 14, in resource "tls_self_signed_cert" "demo_cert": 14: key_algorithm = "RSA" Cannot set value for this attribute as the provider has marked it as read-only. Remove the configuration line setting the value. - Fix issues found in "autoscaling" module:
Errors:
Error: Invalid count argument on modules/observability/autoscaling/logging.tf line 6, in resource "oci_logging_log" "wlsc_autoscaling_log": 6: count = var.use_autoscaling != "None" && length(oci_functions_application.wlsc_autoscaling_function_application) > 0 ? 1 : 0 The "count" value depends on resource attributes that cannot be determined until apply, so Terraform cannot predict how many instances will be created. To work around this, use the -target argument to first apply only the resources that the count depends on. Error: Invalid count argument on modules/observability/autoscaling/monitoring_alarms.tf line 5, in resource "oci_monitoring_alarm" "wlsc_scaleout_monitoring_alarm": 5: count = var.use_autoscaling == "Metric" && length(oci_ons_notification_topic.wlsc_scaleout_notification_topic) > 0 ? 1 : 0 The "count" value depends on resource attributes that cannot be determined until apply, so Terraform cannot predict how many instances will be created. To work around this, use the -target argument to first apply only the resources that the count depends on. Error: Invalid count argument on modules/observability/autoscaling/monitoring_alarms.tf line 32, in resource "oci_monitoring_alarm" "wlsc_scalein_monitoring_alarm": 32: count = var.use_autoscaling == "Metric" && length(oci_ons_notification_topic.wlsc_scalein_notification_topic) > 0 ? 1 : 0 The "count" value depends on resource attributes that cannot be determined until apply, so Terraform cannot predict how many instances will be created. To work around this, use the -target argument to first apply only the resources that the count depends on. Error: Invalid count argument on modules/observability/autoscaling/subscriptions.tf line 5, in resource "oci_ons_subscription" "wlsc_email_topic_email_subscription": 5: count = var.use_autoscaling != "None" && var.subscription_endpoint != "" && length(oci_ons_notification_topic.wlsc_email_notification_topic) > 0 ? 1 : 0 The "count" value depends on resource attributes that cannot be determined until apply, so Terraform cannot predict how many instances will be created. To work around this, use the -target argument to first apply only the resources that the count depends on.Fixes:
cd /scratch/orm-temp-upgrade $ cat modules/observability/autoscaling/logging.tf resource "oci_logging_log" "wlsc_autoscaling_log" { count = var.use_oci_logging ? 1 : 0 [Modify the count variable to replace existing variable "use_autoscaling"] $ cat modules/observability/autoscaling/inputs.tf [Add "use_oci_logging" variable] variable "use_oci_logging" { type = bool description = "Enable logging service integration for WebLogic instances" default = false } $ cat modules/observability/autoscaling/monitoring_alarms.tf resource "oci_monitoring_alarm" "wlsc_scaleout_monitoring_alarm" { count = var.use_oci_logging ? 1 : 0 resource "oci_monitoring_alarm" "wlsc_scalein_monitoring_alarm" { count = var.use_oci_logging ? 1 : 0 $ cat modules/observability/autoscaling/subscriptions.tf resource "oci_ons_subscription" "wlsc_email_topic_email_subscription" { count = var.subscription_endpoint != "" ? 1 : 0
- Delete the
- Using the upgrade command provided with Terraform v0.13.7, upgrade
the current configuration
files.
$ cd /scratch/orm-temp-upgrade $ /scratch/jenkins/install/terraform_0.13.7 init $ /scratch/jenkins/install/terraform_0.13.7 0.13upgrade This command will update the configuration files in the given directory to use the new provider source features from Terraform v0.13. It will also highlight any providers for which the source cannot be detected, and advise how to proceed. We recommend using this command in a clean version control work tree, so that you can easily see the proposed changes as a diff against the latest commit. If you have uncommited changes already present, we recommend aborting this command and dealing with them before running this command again. Would you like to upgrade the module in the current directory? Only 'yes' will be accepted to confirm. Enter a value: yes ----------------------------------------------------------------------------- Upgrade complete! Use your version control system to review the proposed changes, make any necessary adjustments, and then commit.The Terraform configuration is successfully upgraded to the target Terraform version v0.13.7, then you can proceed to the next task for upgrading the stack.
Step 4: Upgrade the stack.
- In the Console, reopen the details page for the stack that you're upgrading: On the Stacks list page, select the stack that you want to work with. If you need help finding the list page or the stack, see Listing Stacks.
- From the Edit dropdown menu for the stack, select Edit Stack.
- Upload the upgraded Terraform configuration to the
stack.
You can either drag the file onto the dialog's control or select Browse and navigate to the location of the file or folder.
The dialog box is populated with information contained in the Terraform configuration.
- Specify the target Terraform version: Change the Terraform version.
- Select Next twice, then select Save changes.
The stack is now synchronized with the upgraded Terraform configuration and specified Terraform version. You can now proceed to the next task for importing the state file.
Step 5: Import the state file
- In the Console, reopen the details page for the stack that you're upgrading: On the Stacks list page, select the stack that you want to work with. If you need help finding the list page or the stack, see Listing Stacks.
- Go to More actions and select Import state.
- In the Import panel, add the downloaded Terraform state file.
You can either drag the file onto the dialog's control or select Browse and navigate to the location of the file or folder.
- Click on Import.
The import job is created. The new job is listed under Jobs. When the job finishes, the Job details page opens.
- Confirm successful import: Select Logs.
After a successful import of the state file, the stack is now updated to Terraform v0.13.7
Step 6: Run Terraform plan and apply to validate that there are no issues.
- On the Stacks list page, select the stack that you want to work with. If you need help finding the list page or the stack, see Listing Stacks.
- Check for pending changes to infrastructure:
-
Select Plan.
When the action finishes, the details page for the related job opens.
-
To review the log for the completed plan action, select Logs.
-
In the log contents, check for issues described at Troubleshooting Logs During an Upgrade.
- Resolve any listed issues by manually updating the Terraform configuration, as described at Troubleshooting Logs During an Upgrade.
-
- Once plan is successful, apply the stack to apply the changes to the
infrastructure.
-
To review the log for the completed plan action, select Logs.
-
In the log contents, check for issues described at Troubleshooting Logs During an Upgrade.
- Resolve any listed issues by manually updating the Terraform configuration, as described at Troubleshooting Logs During an Upgrade.
-
Upgrade from Terraform version 0.13.7 to 0.14.11
Step 1: Upgrade the configuration.
- Use the Terraform v0.13.7 configuration that you upgraded to in the previous step as a starting point for your upgrade to Terraform v0.14.11.
- From the stack, download the latest Terraform state file.
- From https://releases.hashicorp.com/terraform, download the
.zipfile for your target Terraform version 0.14.11 and operating system. Extract the Terraform.zipand add the path to the existing PATH environment variable. - Update the
versions.tffile to add Terraform version to 0.14.11. Add a list of required provider configuration with the Terraform version and the WLS for OCI code. See the sampleversions.tfoutput for details - There are no structural or syntax changes between the version v0.13.7 and v0.14.11. Proceed to next step.
The Terraform configuration is successfully upgraded to the target Terraform version v0.14.11, then you can proceed to the next task for upgrading the stack.
Step 2: Upgrade the stack
- In the Console, reopen the details page for the stack that you're upgrading: On the Stacks list page, select the stack that you want to work with. If you need help finding the list page or the stack, see Listing Stacks.
- From the Edit dropdown menu for the stack, select Edit Stack.
- Upload the upgraded Terraform configuration file as described in Upgrading Terraform Configurations to the
stack.
You can either drag the file onto the dialog's control or select Browse and navigate to the location of the file or folder.
The dialog box is populated with information contained in the Terraform configuration.
- Specify the target Terraform version: Change the Terraform version.
- Select Next twice, then select Save changes.
The stack is now synchronized with the upgraded Terraform configuration and specified Terraform version. You can now proceed to the next task for importing the state file.
Step 3: Import the state file
- In the Console, reopen the details page for the stack that you're upgrading: On the Stacks list page, select the stack that you want to work with. If you need help finding the list page or the stack, see Listing Stacks.
- Go to More actions and select Import state.
- In the Import panel, add the downloaded Terraform state file.
You can either drag the file onto the dialog's control or select Browse and navigate to the location of the file or folder.
- Click on Import.
The import job is created. The new job is listed under Jobs. When the job finishes, the Job details page opens.
- Confirm successful import: Select Logs.
After a successful import of the state file, the stack is now updated to Terraform v0.14.11
Step 4: Run Terraform Plan and Apply actions to validate the stack for any issues.
- On the Stacks list page, select the stack that you want to work with. If you need help finding the list page or the stack, see Listing Stacks.
- Check for pending changes to infrastructure:
-
Select Plan.
When the action finishes, the details page for the related job opens.
-
To review the log for the completed plan action, select Logs.
-
In the log contents, check for issues described at Troubleshooting Logs During an Upgrade.
- Resolve any listed issues by manually updating the Terraform configuration, as described at Troubleshooting Logs During an Upgrade.
-
- Once plan is successful, apply the stack to apply the changes to the
infrastructure.
-
To review the log for the completed plan action, select Logs.
-
In the log contents, check for issues described at Troubleshooting Logs During an Upgrade.
- Resolve any listed issues by manually updating the Terraform configuration, as described at Troubleshooting Logs During an Upgrade.
-
Upgrade from Terraform version 0.14.11 to 1.5.7
Step 1: Upgrade the configuration.
- Use the Terraform v0.14.11 configuration that you upgraded to in previous steps as a starting point for your upgrade to Terraform v1.5.7.
- From the stack, download the latest Terraform state file.
- From https://releases.hashicorp.com/terraform, download the .zip file for your target Terraform version v1.5.7 and operating system. Extract the terraform zip and add the path to the existing PATH environment variable.
Step 2: Upgrade the stack
- In the Console, reopen the details page for the stack that you're upgrading: On the Stacks list page, select the stack that you want to work with. If you need help finding the list page or the stack, see Listing Stacks.
- From the Edit dropdown menu for the stack, select Edit Stack.
- Upload the upgraded Terraform configuration to the
stack.
You can either drag the file onto the dialog's control or select Browse and navigate to the location of the file or folder.
The dialog box is populated with information contained in the Terraform configuration.
- Specify the target Terraform version: Change the Terraform version.
- Select Next twice, then select Save changes.
The stack is now synchronized with the upgraded Terraform configuration and Terraform version v1.5.7. You can now proceed to the next task for importing the state file.
Step 3: Import the state file.
- In the Console, reopen the details page for the stack that you're upgrading: On the Stacks list page, select the stack that you want to work with. If you need help finding the list page or the stack, see Listing Stacks.
- Go to More actions and select Import state.
- In the Import panel, add the downloaded Terraform state file.
You can either drag the file onto the dialog's control or select Browse and navigate to the location of the file or folder.
- Select the checkbox for "Upgrade provider versions" and Click on
Import.
The import job is created. The new job is listed under Jobs. When the job finishes, the Job details page opens.
- Confirm successful import: Select Logs.
After a successful import of the state file, the stack is now updated to terraform v1.5.7
Step 4: Run Terraform Plan and Apply actions to validate the stack for any issues.
- On the Stacks list page, select the stack that you want to work with. If you
need help finding the list page or the stack, see Listing Stacks.
-
Select Plan.
When the action finishes, the details page for the related job opens.
-
To review the log for the completed plan action, select Logs.
-
In the log contents, check for issues described at Troubleshooting Logs During an Upgrade.
- Resolve any listed issues by manually updating the Terraform configuration, as described at Troubleshooting Logs During an Upgrade.
-
- Check for pending changes to infrastructure:
- Once plan is successful, apply the stack to apply the changes to the
infrastructure.
-
To review the log for the completed plan action, select Logs.
-
In the log contents, check for issues described at Troubleshooting Logs During an Upgrade.
- Resolve any listed issues by manually updating the Terraform configuration, as described at Troubleshooting Logs During an Upgrade.
-