Skip to content

Only call PUT if any changes are needed? #312

@chris-richmond-wellsky

Description

@chris-richmond-wellsky

If I'm using a resource like this:


resource "restapi_object" "put_request" {
  path         = "/api/v1/resources/BBBBB"
  id_attribute = "resourceID"
  object_id    = "BBBBB"
  data         = "{\"resourceID\": \"BBBBB\", \"resourceTypeID\": 1, \"resourceName\": \"my-dead-tf-app\"}"
}

that PUT endpoint is a createorupdate type of operation so it will create if it does not exist, or update if the resource ID does exist.

I was able to get that resource created just fine. But I am unclear but it will call this method on any TF plan/apply cluttering up the tf plans and needlessly calling this every time at TF apply takes place.
I am unclear as to the best approach to only have the plan show a change for this if the object doesn't exist or if any values change. I

Essentially I'm thinking this should rely on a GET first to verify existence/existing data somehow, but now sure the best way to accomplish this with the module? Can this be done all in one with a configuration?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions