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

patch empty zone list return from command. #40

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

rajsinghtech
Copy link

Due to the az command being ran here, an empty set of data retruns as an empty string "" instead of [].

│ Error: Error in function call
│ 
│   on .terraform/modules/aks/main.tf line 37, in module "main":
│   37:   agents_availability_zones         = sort(flatten(jsondecode(module.availability_zones_data_source.stdout)))
│     ├────────────────
│     │ while calling jsondecode(str)
│     │ module.availability_zones_data_source.stdout is ""
│ 
│ Call to function "jsondecode" failed: EOF.

@rajsinghtech rajsinghtech added the bug Something isn't working label Sep 3, 2024
@rajsinghtech rajsinghtech self-assigned this Sep 3, 2024
@PhilipSchmid
Copy link
Contributor

Have you tried manually running the az command from here? I don't see how this should return "". I get the following for example:

$ az vm list-skus --location westeurope --zone --resource-type virtualMachines --size Standard_D2s_v3 --query '[].locationInfo[0].zones' --output jsonc
[
  [
    "3",
    "2",
    "1"
  ]
]

How does your var.instance_type and var.region look like? What did you configure?

@rajsinghtech
Copy link
Author

Hmmm, looks like im setting region useast and setting Standard_D2s_v3 for var.worker_instance_type per template repo. Not setting var.instance_type specifically.

@PhilipSchmid
Copy link
Contributor

By not setting var.instance_type, it should take its default value, Standard_D2s_v3.

@PhilipSchmid
Copy link
Contributor

The template repo maps var.worker_instance_type to instance_type. Hence, you're setting it.

See https://github.com/isovalent/cute-template-repo/blob/099c1bc874f912b71076acee219922b3603a059f/azure-aks-byocni/aks.tf#L11C3-L11C49

@PhilipSchmid
Copy link
Contributor

It seems like there are no Standard_D2s_v3 VMs available in useast:

az vm list-skus --location useast --zone --resource-type virtualMachines --size Standard_D2s_v3 --query '[].locationInfo[0].zones' --output jsonc
[]

Still, STDOUT shows a proper [] and no "" 🤔. Maybe matti/resource/shell sees [] as an "empty string"? 🤷
Anyhow, I just also saw https://github.com/matti/terraform-shell-resource shouldn't be used anymore. Perhaps we should anyway rework this module part.

@rajsinghtech
Copy link
Author

 az vm list-skus --location useast --zone --resource-type virtualMachines --size Standard_D2s_v3 --query '[].locationInfo[0].zones' --output jsonc   

JSON is invalid: Unterminated string starting at: line 1 column 44885501 (char 44885500)

@rajsinghtech
Copy link
Author

My az cli must be broken locally?

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

Successfully merging this pull request may close these issues.

2 participants