Skip to main content

Terraform Diary - Desired State and Current State scenarios with OCI

 


Desired state of a resource can be simply defined as the state that is mentioned in your resource block of tf file.

Current state of a resource is the actual configuration state for the resource. This may be different from desired state mentioned in .tf file.

 

Terraform will only synchronize current state(changes done manually in console) to desired state(changes mentioned in your tf file) for attributes that are explicitly mentioned in your tf file.

Case 1 –

Please consider below example, note that object bucket ‘test_bucket is already present on OCI –

resource "oci_objectstorage_bucket" "test_bucket" {

    #Required

    compartment_id = "${var.compartment_ocid}"

    name = "test_bucket"

    namespace = "${var.namespace}"

    versioning = "Enabled"

        }

  

We added versioning attribute in our tf file and current state for is bucket is as follows –



 Now we know desired state and current state (console) are different. Let us run terraform plan and observe –


      ~ versioning            = "Suspended" -> "Enabled"

    }

 

Plan: 0 to add, 1 to change, 0 to destroy.

 

 

Case 2 –

Simply remove versioning from .tf file as follows, (commented it) –

resource "oci_objectstorage_bucket" "test_bucket" {

    #Required

    compartment_id = "${var.compartment_ocid}"

    name = "test_bucket"

    namespace = "${var.namespace}"

    #versioning = "Enabled"




This proves that terraform will only check and try to modify current state à desired state for attributes that are explicitly mentioned in you .tf file


Now what will happen if there is no explicit mention for an attribute that is modified manually in your OCI console?

In this scenario, terraform will not perform any action mentioning below -


Hence, it is important to mention attributes in your tf file to make sure terraform identifies discrepancies between desired state and current state.



Comments

  1. Your explanation of “only what’s in the .tf file counts” really resonates. I’ve had debates with teammates who expected Terraform to enforce every console setting automatically. Posts like this remind me why staying explicit in Terraform configs is the safer long-term habit. Would love to see more real-world drift scenarios in future entries.

    ReplyDelete

Post a Comment

Popular posts from this blog

Logfile locations in EBS r12.1 and EBS r12.2

Startup/shutdown Apps tier services are started and stopped frequently and we must know logfiles when troubleshooting startup/shutdown issues. $INST_TOP/logs/appl/admin/log $INST_TOP/logs/appl/admin/log Apache OHS being part of opmn in r12.1 has continued in r12.2. Logfile locations for troubleshooting have been changed $INST_TOP/logs/ora/10.1.3/Apache/error_log[timestamp] $INST_TOP/logs/ora/10.1.3/opmn/HTTP_Server~1.log $IAS_ORACLE_HOME/instances/*/diagnostics/logs/OHS/*/*log*   OPMN Logfile locations for r12.1 and r12.2 have been changed $INST_TOP/logs/ora/10.1.3/opmn/opmn* $IAS_ORACLE_HOME/instances/*/diagnostics/logs/OPMN/opmn/* Oacore oacore in r12.1 is oc4j component and part of 10gAS. However, in r12.2, oacore is now a managed server for weblogic server $LOG_HOME/ora/10.1.3/j2ee/oacore/oacore*/ $LOG_HOME/ora/10.1.3/j2ee/oacore/oacore*/ $LOG_HOME/ora/10.1.3/opmn/oacore*/oacor...

Oracle EBS r12 migration to Solaris SPARC ** issues and solutions

Let me share a list of issues I faced when migrating a single node Oracle ebs r12.1.3 environment from Linux x86_64 to multinode Solaris SPARC machines. I have already shared ppt that was point of discussion before migration. Oracle ebs db platform migration Please note that below is set of issues and respective solutions while migration. I have not covered steps for migration in this post. I would also like to share list of references from metalink that were very handy during complete migration process. ·          Export/import process for 12.0 or 12.1 using 11gR1 or 11gR2 (Doc ID 741818.1) -           This document will be primarily used for database migration. ·          Application Tier Platform Migration with Oracle E-Business Suite Release 12 (Doc ID 438086.1) -           Apps tier will b...

Query to Check AD and TXK code levels in your EBS environment

Below query can be very handy in finding out current AD and TXK code levels. col ABBREVIATION for a10 set lines 1000 col NAME for a50 col CODELEVEL for a20 SELECT ABBREVIATION,NAME,codelevel FROM AD_TRACKABLE_ENTITIES WHERE abbreviation in ('txk','ad'); ABBREVIATI NAME                                                CODELEVEL ---------- -------------------------------------------------- ------------ ad           Oracle Applications DBA                             C.11 txk         Oracle Applications Technology Stack    ...