Skip to content

Environment Variables or Values based on resources yet to be created will cause an error #58

Description

@aaronthebaron

This may be a case of me using the tool incorrectly, but I'm receiving this error when I include something like a reference to an AWS ARN that has yet to be created in the values or environment variables for helmfile_release_set:

Error: diffing release set: running helmfile diff: running command: /bin/helmfile: exit status 1
in helmfile.d/30.cluster-autoscaler.yaml: error during 30.cluster-autoscaler.yaml.part.0 parsing: template: stringTemplate:20:24: executing "stringTemplate" at <requiredEnv "CLUSTER_NAME">: error calling requiredEnv: required env var `CLUSTER_NAME` is not set

My TF:

resource "helmfile_release_set" "eks_required" {
  aws_region  = var.region
  aws_profile = var.profile

  kubeconfig        = data.external.tempfile.result["path"]
  working_directory = "config"

  environment_variables = {
    CLUSTER_NAME                = var.cluster_name,
    AWS_DEFAULT_REGION          = var.region,
    CLUSTER_AUTOSCALER_IAM_ROLE = aws_iam_role.cluster_autoscaler.arn,
    NODE_TERMINATION_IAM_ROLE   = aws_iam_role.node_termination_handler.arn,
  }
}

The new, not yet created element here is aws_iam_role.node_termination_handler.arn

In the debug output I see the following:

2021-03-01T19:09:49.877Z [DEBUG] plugin.terraform-provider-helmfile_v0.13.3: 2021/03/01 19:09:49
[DEBUG] helmfile-provider(pid=10659,ppid=10443): Running helmfile --file  --no-color --helm-binary helm build on {Bin:helmfile Values:[] ValuesFiles:[] HelmBin:helm Path: Content: DiffOutput: ApplyOutput: Environment: Selector:map[] Selectors:[]
EnvironmentVariables:map[AWS_DEFAULT_REGION:us-west-2 CLUSTER_AUTOSCALER_IAM_ROLE:arn:aws:iam::[account-removed]:role/cluster-autoscaler-operations-0 CLUSTER_NAME:operations-0] WorkingDirectory:config ReleasesValues:map[] Kubeconfig:/tmp/tmp.MNHFoP Concurrency:0 Version: HelmVersion: HelmDiffVersion: SkipDiffOnMissingFiles:[]}

I've also tried an explicit depends on block in the helmfile_release_set.

If I remove the reference to the NODE_TERMINATION_IAM_ROLE which does not exist yet, I can run a plan. If the iam role exists, I can run a plan.

Is this a bug or is there another method for making the helmfile dependent on the results from other parts of Terraform? Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions