Skip to content

Terraform validations fail when using a terraform.tfvars file #87

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

Open
kajiya3141 opened this issue Dec 3, 2024 · 1 comment
Open

Comments

@kajiya3141
Copy link

Hey there!

I get the following error when using a custom (CLI deployment) Terraform module in a .zip file:

{
  "taskReports": [
    {
      "taskType": "EXECUTE_TERRAFORM_PLAN",
      "createTime": "2024-12-02T13:50:48.023Z",
      "taskExecutionStatus": "ISSUES_FOUND",
      "digest": "Terraform validations failed",
      "errorMessage": "Step #2 - \"Replace image variables\": Already have image (with digest): gcr.io/cloud-marketplace-tools/mpdev:v0.4.0\nStep #2 - \"Replace image variables\": Replacing the default values of the variables: [source_image]\nStep #2 - \"Replace image variables\": Mapping of values to replace: map[projects/canonical-public/global/images/ubuntu-pro-2004-focal-v20241115:projects/mpi-canonical-public/global/images/ubuntu-pro-2004-focal-v20241115]\nStep #2 - \"Replace image variables\": Error: default value: projects/canonical-public/global/images/ubuntu-pro-2204-focal-v20240910 of variable: source_image not found in replacements\n"
    },
...
}

and I'm struggling to make sense of that error. With the same Terraform module, locally running terraform plan terraform apply, etc. works as expected, so I'm not sure what the issue is? Running the marketplace Terrafom validations on the same module without the terraform.tfvars file also works fine, so I've narrowed the issue down to that file. However we need this file as the source_image will change every time we release a new Ubuntu Pro image.

For reference, the .zip files contains the following:

  • main.tf
  • marketplace_test.tfvars
  • README.md
  • terraform.tfvars
  • variables.tf

If you need any more information do let me know :)

@manupanand
Copy link

It seems that the issue is with mpdev not correctly replacing the source_image value from terraform.tfvars. While the module works locally, mpdev may not be loading the .tfvars file properly or missing the expected mapping. Manually setting source_image in mpdev or verifying the replacement mappings could help resolve this.

try running

terraform validate -var-file=terraform.tfvars ```

or can you write a debug -> variable.tf
```variable "source_image" {
  description = "Source image to use"
  type        = string
  default     = "projects/canonical-public/global/images/ubuntu-pro-2204-focal-v20240910"
}
output "source_image_debug" {
  value = var.source_image
}```

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

No branches or pull requests

2 participants