Creating an Apply Job
Create an apply job in Resource Manager.
When you create (run) an apply job for a stack, Terraform provisions the resources and executes the actions defined in your Terraform configuration, applying the execution plan to the associated stack to create (or modify) your Oracle Cloud Infrastructure resources. We recommend running a plan job (generating an execution plan) before running an apply job.
For a walk-through using CLI for cloud provisioning in a CI/CD pipeline, see IaC in the Cloud: Integrating Terraform and Resource Manager into your CI/CD Pipeline - Building With the OCI CLI.
For configurations stored in a source code control system, such as GitHub or GitLab, the job uses the most recent commit. The time required to complete an apply job depends on the number and type of cloud resources to be created.
The apply job is created. The new job is listed under Jobs.
Use the
oci resource-manager job create-apply-job
command and required parameters to run an apply job.oci resource-manager job create-apply-job [OPTIONS]
For a complete list of parameters and values for CLI commands, see the Command Line Reference for Resource Manager.
ExamplesExample 1: Reference a plan job.
oci resource-manager job create-apply-job --execution-plan-strategy <plan_job_ocid> --stack-id <stack_ocid>
Example 2: Automatically approve (don't reference a plan job).
oci resource-manager job create-apply-job --execution-plan-strategy AUTO_APPROVED --stack-id <stack_ocid>
Use the CreateJob operation to create an apply job.
For an example of the
operation
part of the request, see CreateApplyJobOperationDetails.
What's Next
Depending on the number and type of resources specified, a given apply job can take some time.
After running an apply job, get the job's details to check its status. You can optionally view the Terraform state file, view the logs, and confirm existence of provisioned resources.
Monitor the job status (lifecycle state) by getting the job's details. Succeeded (SUCCEEDED
) indicates that the job has completed. Depending on the complexity of the job, the operation can take some time. While the job runs, or after it finishes, you can get the job logs content.
To view the Terraform state file (shows the state of your resources after running the job), select the name of the job to display the Job details page, then select View state under Resources. Optionally select Show changes in this version.
To view the logs for the job, select the job to open its details page, then select Logs under Resources.
To confirm existence of newly provisioned resources, inspect resources in the compartment.