Study guide
8.1 Infrastructure as Code with Terraform and the OCI Provider
OCI 2026 Architect Professional 1Z0-997-26
Track your progress as you read
Finished sections get a check mark.
1 Chapter 1: Exam Overview & Architecture Foundations
1.1 Exam Logistics, the 2026 Blueprint & How to Use This Guide 1.2 The OCI Well-Architected Framework & Architectural Tradeoffs
2 Chapter 2: High Availability & Resilient Design
2.1 Availability Domains, Fault Domains, Instance Pools & Load Balancers 2.2 OCI DNS Traffic Steering, Geolocation & Health Checks 2.3 Block Volume Replication, Volume Groups & Backup Policies 2.4 Object Storage Replication, Versioning & Retention Rules (WORM)
3 Chapter 3: Full Stack Disaster Recovery
3.1 Full Stack Disaster Recovery: Protection Groups, Members & Permissions 3.2 DR Plans: Switchover, Failover, Prechecks & Plan Execution 3.3 DR Drills, Plan Customization & Operational Readiness
4 Chapter 4: Container Instances, OCIR & OCI DevOps
4.1 Containerization, Microservices & OCI Container Instances 4.2 OCI Container Registry: Repositories, Push & Pull, and Image Management 4.3 OCI DevOps: Code Repositories, Build Pipelines & Deployment Strategies
5 Chapter 5: OCI Kubernetes Engine (OKE)
5.1 OKE Cluster Types, Node Options & Cluster Creation 5.2 OKE Networking: VCN-Native Pod Networking vs. Flannel, Subnet Sizing & Load Balancers 5.3 OKE Workload Identity, Secrets & Persistent Storage
6 Chapter 6: Serverless Functions & API Gateway
6.1 OCI Functions: Concepts, Invocation Modes, Integrations & Image Security 6.2 API Gateway: Authentication, JWT Validation, Rate Limiting & Usage Plans
7 Chapter 7: Messaging & Event-Driven Design
7.1 OCI Streaming, OCI Queue & Messaging Patterns for Microservices 7.2 OCI Events, Event Rules & OCI Notifications Fan-Out
8 Chapter 8: Infrastructure as Code with Terraform & Resource Manager
8.1 Infrastructure as Code with Terraform and the OCI Provider 8.2 OCI Resource Manager: Stacks, Jobs, Drift Detection & Private Endpoints
9 Chapter 9: Identity & Multi-Tenancy Governance
9.1 IAM Policy Design: Verbs, Conditions, Dynamic Groups & Principals 9.2 Organizations Management, Governance Rules & Compartment Quotas
10 Chapter 10: Security Posture with Cloud Guard & Security Zones
10.1 Cloud Guard: Detector Recipes, Problems, Scores & Responders 10.2 Security Zones & Vulnerability Scanning
11 Chapter 11: Secure Access & Network Protection
11.1 Layered Network Security: Security Lists, NSGs & Private Access to Services 11.2 OCI Bastion: Managed SSH, Port Forwarding & SOCKS5 Sessions 11.3 Zero Trust Packet Routing (ZPR): Security Attributes & Intent-Based Policy 11.4 OCI Network Firewall: Policies, Inspection Routing, Tunnel Inspection & Private NAT
12 Chapter 12: Application & Data Protection: WAF, Certificates & Vault
12.1 OCI Web Application Firewall: Policies, Modules, Actions & Enforcement Points 12.2 OCI Certificates: Private CAs, TLS Certificates, Renewal & Integrations 12.3 OCI Vault Key Management: Vault Types, Protection Modes, Dedicated KMS & External KMS 12.4 Vault Secrets: Versions, Rotation States, Automatic Generation & Rotation
13 Chapter 13: Base Database Service & Autonomous AI Database
13.1 Base Database Service: DB Systems, RAC, Data Guard, Cloning & Maintenance 13.2 Autonomous AI Database: Workload Types, Deployment Options, Services & Connectivity 13.3 Operating Autonomous AI Database: Scaling, Cloning, Backups, Patching & Self-Tuning 13.4 Autonomous Data Guard & Backup-Based Disaster Recovery for Autonomous AI Database
14 Chapter 14: Recovery Service, Global Distribution & OCI Cache
14.1 Autonomous Recovery Service: Protection Policies, Real-Time Protection & Retention Lock 14.2 Globally Distributed Autonomous AI Database: Sharding, Data Placement & Replication 14.3 OCI Cache: Valkey and Redis Clusters, Sharding, Security & Cross-Region Replication
15 Chapter 15: Monitoring, Alarms & Notifications
15.1 OCI Monitoring: Metrics, Namespaces, Custom Metrics & Monitoring Query Language 15.2 Alarms & Notifications: Trigger Rules, Absence Alarms, Split Messages, Suppression & Delivery
16 Chapter 16: Logging, Audit, Connector Hub & Search
16.1 OCI Logging: Log Groups, Service Logs, Custom Logs & the Unified Monitoring Agent 16.2 Logging Search, the Logging Query Language & OCI Audit 16.3 Connector Hub: Moving Logs, Metrics, Queue Messages & Streams Between Services 16.4 OCI Search with OpenSearch & Resource Search for Observability
8.1 Infrastructure as Code with Terraform and the OCI Provider
Key Takeaways Explain This Topic AI
Terraform describes infrastructure declaratively in HCL (.tf) or JSON (.tf.json) files, and the OCI provider translates those files into OCI API calls.
The core Terraform workflow is terraform init, terraform plan, terraform apply, and terraform destroy.
Terraform records what it created in a state file, so the state must be stored safely and protected from concurrent changes.
Modules package reusable configurations, such as a standard VCN, so teams build environments from tested components.
The OCI provider can authenticate with an API signing key, an instance principal, a resource principal, or a security token.
Last updated: October 2026
Why Infrastructure as Code
Clicking through the Console works for a lab but not for an enterprise. Infrastructure as Code (IaC) describes infrastructure in text files that are versioned, reviewed, and executed by automation. Architects care about IaC because it delivers:
Repeatability : the same configuration builds development, test, production, and disaster recovery environments.
Consistency : fewer configuration differences between regions and environments.
Reviewability : changes go through pull requests, so security and network teams can approve them before they happen.
Speed of recovery : a destroyed environment can be rebuilt from code, which complements backups and replication.
Auditability : the repository history shows who changed what and why.
OCI's IaC tooling is built on Terraform , an open-source tool from HashiCorp, together with the OCI Terraform provider . OCI Resource Manager (next section) runs Terraform as a managed service.
Terraform Building Blocks
Terraform configurations are written in HashiCorp Configuration Language (HCL) files ending in .tf , or in JSON files ending in .tf.json . Terraform reads all files in the working directory together.
- Block Purpose Example
- provider Configures the plugin that talks to a platform's API provider "oci" { region = var.region }
- resource Something Terraform creates and manages resource "oci_core_vcn" "main" { ... }
- data Reads information that already exists data "oci_identity_availability_domains" "ads" { ... }
- variable An input value variable "compartment_ocid" {}
output A value shown after apply or passed to other configurations output "vcn_id" { value = oci_core_vcn.main.id }
- module A reusable package of configuration module "network" { source = "./modules/vcn" }
- Example: A VCN and a Subnet variable "compartment_ocid" {}
- variable "region" { default = "us-ashburn-1" }
- provider "oci" {
- region = var.region
- }
- resource "oci_core_vcn" "main" {
- compartment_id = var.compartment_ocid
- cidr_blocks = ["10.0.0.0/16"]
- display_name = "app-vcn"
- }
- resource "oci_core_subnet" "private_app" {
- compartment_id = var.compartment_ocid
- vcn_id = oci_core_vcn.main.id
- cidr_block = "10.0.1.0/24"
- prohibit_public_ip_on_vnic = true
- display_name = "private-app"
- }
- output "subnet_id" {
- value = oci_core_subnet.private_app.id
- }
The subnet refers to oci_core_vcn.main.id , so Terraform knows to create the VCN first. Terraform builds a dependency graph from these references and creates independent resources in parallel.
Variables
Variables make one configuration usable in several environments. Values can come from defaults, .tfvars files, command-line flags, or environment variables named TF_VAR_<name> . Mark sensitive values, such as passwords, as sensitive = true so Terraform hides them in output, and prefer pulling secrets from OCI Vault at run time.
Modules
A module is any directory of Terraform files. A root configuration calls child modules and passes variables to them. Platform teams publish standard modules, such as a hub VCN with a Network Firewall or a hardened compute instance, so application teams compose environments from approved building blocks. Oracle also publishes OCI landing zone and reference architecture configurations that follow the same idea.
State
Terraform stores a state file ( terraform.tfstate , in JSON) that maps each resource in the configuration to the real resource OCID. Terraform compares the configuration, the state, and the real infrastructure to decide what to change. Important practices:
Store state remotely and securely, because it can contain sensitive values.
Lock state during runs so two people cannot apply changes at the same time.
Never edit state by hand. Use terraform state commands or terraform import to bring existing resources under management.
The Terraform Workflow
- Command What it does
- terraform init Initializes the working directory and downloads providers and modules
- terraform validate Checks the configuration for syntax and internal consistency
- terraform fmt Formats files in the canonical style
- terraform plan Shows the actions Terraform would take, without changing anything
- terraform apply Executes the actions in the plan
- terraform destroy Deletes the resources managed by the configuration
- terraform output Shows output values
- Changing Infrastructure
To change infrastructure, you edit the configuration and run plan again. The plan marks each resource as create , update in place , destroy , or destroy and then create (replace) . Reviewing the plan is critical: some attribute changes, such as a subnet CIDR block, force replacement, which would delete resources that depend on it. Lifecycle settings such as prevent_destroy protect critical resources, and create_before_destroy reduces downtime when a replacement is unavoidable.
Scaling a Configuration: count, for_each, and Environments
Two meta-arguments create several similar resources from one block:
count = 3 creates three copies addressed as resource_type.name[0] , [1] , and [2] . It suits identical resources.
for_each iterates over a map or set, addressing each copy by key, such as oci_core_subnet.tier["web"] . Removing one key deletes only that resource, so for_each is safer when items are added and removed over time.
For separate environments, most teams keep one set of modules and a small root configuration per environment (development, test, production, and DR), each with its own variables and its own state. This keeps a mistake in development from touching production and makes the DR region a second instance of the same code rather than a hand-built copy.
Authenticating the OCI Provider
When you run Terraform yourself, the OCI provider supports several authentication methods:
- Method Typical use
- API signing key (user OCID, fingerprint, private key, tenancy OCID) A developer's workstation
- Instance principal Terraform running on a compute instance in a dynamic group
- Resource principal Terraform running inside an OCI service that has its own identity
- Security token (session authentication) Short-lived interactive sessions created with oci session authenticate
When Terraform runs inside Resource Manager , the service handles authentication for you, and the provider "oci" block only needs the region .