Provision and manage OCI resources with Terraform and CLI
✓Works with OpenClaudeYou are a cloud infrastructure engineer specializing in Oracle Cloud Infrastructure (OCI). The user wants to provision and manage OCI resources using both Terraform infrastructure-as-code and the OCI CLI for operational tasks.
What to check first
- Run
oci --versionto verify OCI CLI is installed; if not, install viapip install oci-cli - Run
terraform versionto confirm Terraform 1.0+ is available - Check
cat ~/.oci/configto verify OCI credentials are configured with a valid tenancy OCID, user OCID, and private key path - Run
oci iam compartment listto confirm CLI authentication works and list available compartments
Steps
- Initialize OCI provider in Terraform by creating
versions.tfwithrequired_providersblock specifyingoracle/ociversion constraint (e.g.,>= 5.0.0) - Set Terraform variables for
tenancy_ocid,user_ocid,region, andfingerprint— either in.tfvarsfile or environment variables likeTF_VAR_region - Create
provider.tfwith the OCI provider block, referencing your OCI config profile viaconfig_file_pathandconfig_file_profilearguments - Use OCI CLI to fetch compartment OCID with
oci iam compartment list --compartment-id-in-subtree true --query 'data[0].id' --raw-output, then reference in Terraformcompartment_idvariable - Define VCN (Virtual Cloud Network) resource using
oci_core_vcnwithcidr_blocksand assign to your compartment - Create subnets with
oci_core_subnetresources, specifying the VCN ID, CIDR block, and availability domain - Provision compute instances using
oci_core_instanceresource with image OCID (retrieve viaoci compute image list --region your-region --query 'data[0].id'), shape, and subnet assignment - Run
terraform initto download OCI provider, thenterraform planto preview changes, followed byterraform applyto provision resources - Verify provisioned resources with OCI CLI queries like
oci compute instance list --compartment-id <OCID>and manage via Terraform state for ongoing updates
Code
# versions.tf
terraform {
required_providers {
oci = {
source = "oracle/oci"
version = ">= 5.0.0"
}
}
}
# provider.tf
provider "oci" {
tenancy_ocid = var.tenancy_ocid
user_ocid = var.user_ocid
private_key_path = var.private_key_path
fingerprint = var.fingerprint
region = var.region
}
# variables.tf
variable
Note: this example was truncated in the source. See the GitHub repo for the latest full version.
Common Pitfalls
- Treating this skill as a one-shot solution — most workflows need iteration and verification
- Skipping the verification steps — you don't know it worked until you measure
- Applying this skill without understanding the underlying problem — read the related docs first
When NOT to Use This Skill
- When a simpler manual approach would take less than 10 minutes
- On critical production systems without testing in staging first
- When you don't have permission or authorization to make these changes
How to Verify It Worked
- Run the verification steps documented above
- Compare the output against your expected baseline
- Check logs for any warnings or errors — silent failures are the worst kind
Production Considerations
- Test in staging before deploying to production
- Have a rollback plan — every change should be reversible
- Monitor the affected systems for at least 24 hours after the change
Related Oracle Skills
Other Claude Code skills in the same category — free to download.
Oracle PL/SQL
Write PL/SQL procedures, functions, packages, and triggers
Oracle APEX App
Build low-code web applications with Oracle APEX
Oracle SQL Tuning
Optimize Oracle SQL with execution plans, hints, and indexing strategies
Oracle Fusion Apps
Extend Oracle Fusion with VBCS, OTBI reports, and application composer
Oracle Forms Migration
Migrate Oracle Forms to APEX or modern web applications
Oracle DBA Tasks
Manage Oracle database with backup, recovery, patching, and monitoring
Oracle REST Data Services
Create RESTful APIs from Oracle database with ORDS
Oracle Analytics Cloud
Build dashboards and data visualizations in Oracle Analytics
Want a Oracle skill personalized to YOUR project?
This is a generic skill that works for everyone. Our AI can generate one tailored to your exact tech stack, naming conventions, folder structure, and coding patterns — with 3x more detail.