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

Support different types for outputs/inputs #678

Closed
Smana opened this issue Jun 18, 2023 · 4 comments
Closed

Support different types for outputs/inputs #678

Smana opened this issue Jun 18, 2023 · 4 comments
Labels
kind/bug Something isn't working

Comments

@Smana
Copy link

Smana commented Jun 18, 2023

Hi there,

I'm trying to pass a list of string from a module to another.
From my understanding this change should have fixed the issue, however in my case I get this error:

Error: Invalid value for input variable

  on generated.auto.tfvars.json line 1:
   1: {"cluster_name":"dev-0","env":"dev","github_owner":"Smana","github_repository":"demo-tf-controller","github_token":"xxx","private_subnets":"[\n      \"subnet-xxx\",\n      \"subnet-xxx\",\n      \"subnet-xxx\"\n    ]","vpc_id":"vpc-xxx"}

The given value is not suitable for var.private_subnets declared at
variables.tf:19,1-27: list of string required.

Did I miss something? Is there a parameter to add to specify the expected type?

Helm chart version: 0.12.0
tf-controller version: v0.15.0-rc.1

Regards,

@Nitin0072
Copy link

Nitin0072 commented Jun 19, 2023

Hi Team,

I am also facing the same issue. Faced this issue while Output from another module need to be consumed in current module. If the output is string then there is no issue , but when the output is a complex data structure like list or map , then output secret is storing those in string format and also when consumed it acts as string because of which terraform gives error "Invalid Value of Input Variable"

I am using TF Controller : 0.14.0

Parent Module
Terraform Object

writeOutputsToSecret:
    name: base-infra-output

output.tf

.....
....
output "dummy" {
  value = ["a","b","c"]
}

Current/Child/Consumer Module
Terraform Object

varsFrom:
  - kind: Secret
    name: base-infra-output

main.tf

terraform {
  required_version = ">= 1.1.0"
  required_providers {
    aws = {
      source  = "hashicorp/aws"
      version = "~> 3.0"
    }
  }
}

variable "dummy" {
  type = list(string)
}

variable "access_key" {
  type = string
}
variable "secret_key" {
  type = string
}

provider "aws" {
  region = "eu-west-3"
  access_key = var.access_key
  secret_key = var.secret_key
}

output "consumer-output" {
  value = var.dummy
}

Error
"error":"error running Plan: rpc error: code = Internal desc = exit status 1\n\nError: Invalid value for input variable\n\n on generated.auto.tfvars.json line 1:\n 1: {\"access_key\":\"<****>\",\"dummy\":\"[\\n \\\"a\\\",\\n \\\"b\\\",\\n \\\"c\\\"\\n ]\",\"dummy.type\":\"[\\n \\\"tuple\\\",\\n [\\n \\\"string\\\",\\n \\\"string\\\",\\n \\\"string\\\"\\n ]\\n ]\",\"secret_key\":\"<*****>\"}\n\nThe given value is not suitable for var.dummy declared at\nvariables.tf:1,1-17: list of string required.\n"}

@Smana
Copy link
Author

Smana commented Jul 2, 2023

Now that this issue is fixed, the output changed a bit.

flux-system     eks-dev-0                       False   error running Plan: rpc error: code = Internal desc = exit status 1                                                                                     false           1 hour
                                                                                                                                                                                                                                      
                                                        Error: Invalid value for input variable                                                                                                                                       
                                                                                                                                                                                                                                      
                                                          on generated.auto.tfvars.json line 1:                                                                                                                                       
                                                           1: {"cluster_name":"***","env":"***","github_owner":"***","github_repository":"***","github_token":"***","private_subnets":"***","vpc_id":"***"}                           
                                                                                                                                                                                                                                      
                                                        The given value is not suitable for var.private_subnets declared at                                                                                                           
                                                        variables.tf:19,1-27: list of string required.

@chanwit
Copy link
Collaborator

chanwit commented Jul 2, 2023

Exactly. We had to cope with sensitive information first. The the top priority.

From my tests as well as your logs, the error message is still relevant and understandable, for example:

The given value is not suitable for var.private_subnets declared at                                                                                                           
variables.tf:19,1-27: list of string required.

I'll address this output/input issue ASAP after the Flux v2 GA is launched.

@lasomethingsomething
Copy link
Contributor

Resolved.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants