<p>I am deploying applications to my kubernetes cluster using the helm_release terraform module. I am attempting to get a single value stored in AWS SSM to be passed into the helm chart values file. This particular value is only required for one helm chart. I would like to not retrieve or pass in this value for all helm charts, so I am trying to set an if statement in the helm_release resource if the chart_name variable is equal to the chart I need to set the value for. For example, I would like to do something like this:</p>
<pre><code>resource &quot;helm_release&quot; &quot;example&quot; {
  name  = var.chart_name
  repository = var.repository
  chart      = var.chart_name
  namespace = var.namespace
  create_namespace = var.create_namespace
  verify = false
  timeout = var.timeout
  repository_username = var.repo_username
  repository_password = var.repo_token
  
  # custom value from SSM would be set here. This is where I would like to perform the conditional check:
  # i.e. 
  # if var.chart_name = &quot;some-chart&quot;:
  set_sensitive = [
    {
      path  = &quot;firstEndpoints&quot;
      value = data.aws_ssm_parameter.first_endpoints
    },
    {
      path  = &quot;secondEndpoints&quot;
      value = data.aws_ssm_parameter.second_endpoints
    },
  ]

  # dynamic values for all charts are passed in through terragrunt inputs (not super relevant here)
  dynamic &quot;set&quot; {
    for_each = var.dynamic_values
    
    content {
      name = set.value.name
      value = set.value.value
    }
  }
}
</code></pre>
<p>Long story short, is it possible to define conditionals within a terraform resource, rather than defining it on the entire resource?</p>

mmiara
<p>You can specify conditional logic within a resource parameter using a ternary with the expected syntax:</p>
<pre><code>set_sensitive = var.chart_name == &quot;some-chart&quot; ? [
  {
    path  = &quot;firstEndpoints&quot;
    value = data.aws_ssm_parameter.first_endpoints
  },
  {
    path  = &quot;secondEndpoints&quot;
    value = data.aws_ssm_parameter.second_endpoints
  },
] : null
</code></pre>
<p>As expected this will assign the custom <code>list(object)</code> value for the specified chart name, and the parameter will be omitted completely otherwise.</p>
