terraform plan -detailed-exitcode is returning 0 when we have changes

  Kiến thức lập trình

I have one chnage in my test infra when I am running terrafrom plan on travis
with command

terraform plan -detailed-exitcode

I am getting follwoing output

Terraform used the selected providers to generate the following execution

plan. Resource actions are indicated with the following symbols:

  + create

Terraform will perform the following actions:

  # ip_collection.planner_test1 will be created

  + resource "ip_collection" "planner_test1" {

      + description = "Planner_test1"

      + environment = "att"

      + id          = (known after apply)

      + ips         = [

          + "1.2.3.4",


        ]

      + name        = "Planner_test1"

    }

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

on capturing return code with:
local plan_output=$(terraform plan -no-color -detailed-exitcode 2>&1) && plan_rc=0 || plan_rc=$?

I am getting 0 insted of 2

I tried diffrent Terraform versions no joy

LEAVE A COMMENT