Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

kubernetes_manifest applies null resources #2427

Closed
rwe-dtroup opened this issue Feb 20, 2024 · 3 comments
Closed

kubernetes_manifest applies null resources #2427

rwe-dtroup opened this issue Feb 20, 2024 · 3 comments
Labels

Comments

@rwe-dtroup
Copy link

Terraform version, Kubernetes provider version and Kubernetes version

Terraform version:  v1.7.3
Kubernetes Provider version: v2.26.0
Kubernetes version: v1.28

Terraform configuration

...
"blockDeviceMappings" = [
        for mapping in local.final_block_device_mappings : {
          "deviceName" = mapping.device_name
          "ebs" = {
            "volumeSize"          = mapping.ebs.volume_size
            "volumeType"          = mapping.ebs.volume_type
            "iops"                = tonumber(mapping.ebs.iops)
            "encrypted"           = true
            "kmsKeyID"            = mapping.ebs.kms_key_id
            "deleteOnTermination" = tobool(mapping.ebs.delete_on_termination)
            "throughput"          = tonumber(mapping.ebs.throughput)
            "snapshotID"          = try(mapping.ebs.snapshot_id, null)
          }
        }
      ]
...

Question

When using the kubernetes_manifest resource, the snapshotID is always passed as a null resource, this is not recorded in the manifest in the cluster and is not stored in the statefile so this is seen as a change every time terraform runs. Is it possible to not pass this option at all if it's null?

~ blockDeviceMappings        = [
                  ~ {
                      ~ ebs        = {
                          + snapshotID          = null
                            # (7 unchanged attributes hidden)
                        }
@wombat
Copy link

wombat commented Feb 20, 2024

I am having the same problem when provisioning Openshift Subscriptions.

My Terraform object variable looks like this:

env = optional(list(object({
  name  = string
  value = optional(string)
  valueFrom = optional(object({
    configMapKeyRef = object({
      key      = string
      name     = optional(string)
      optional = optional(bool)
    })
  }))
  })))

Terraform apply shows:

+ env       = [
                      + {
                          + name      = "WATCH_NAMESPACE"
                          + value     = "*"
                          + valueFrom = null
                        },
                    ]

After applying the Subscription it looks like this, which results in an error from the operator:

  config:
    env:
      - name: WATCH_NAMESPACE
        value: '*'
        valueFrom: {}
    resources: {}

@sheneska
Copy link
Contributor

sheneska commented Feb 22, 2024

Hi @rwe-dtroup, what is the intended behavior of the snapshot ID attribute with the try expression? Should a null value be passed with each apply ?

@rwe-dtroup
Copy link
Author

Hi @rwe-dtroup, what is the intended behavior of the snapshot ID attribute with the try expression? Should a null value be passed with each apply ?

No, if the value is null it should not be applying that attribute. TBH, I've moved away from this resource as not being able to use this when the cluster is not already built makes life more problematic than it needs to be.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants