MicrosoftDocs / azure-docs

Open source documentation of Microsoft Azure
https://docs.microsoft.com/azure
Creative Commons Attribution 4.0 International
10.15k stars 21.25k forks source link

Deploy an Azure Kubernetes Service (AKS) cluster using Terraform. Minor mistakes in the code. #123455

Closed Dan-Zi closed 1 week ago

Dan-Zi commented 1 month ago

Type of issue

Code doesn't work

Feedback

Please fix the following mistakes in the code examples:

Fix/Update the code:

  1. jsondecode should be removed from jsondecode(azapi_resource_action.ssh_public_key_gen.output).publicKey in main.tf and ssh.tf at Implement the Terraform code section (see Problem 1 below), so that the resulting code would be: azapi_resource_action.ssh_public_key_gen.output.publicKey
  2. add -raw parameter at Verify the results section to generate proper kubeconfig without end of stream "EOF" characters, so that the resulting code would be: echo "$(terraform output -raw kube_config)" > ./azurek8s (see Problem 2 below)

Problem 1

The description and the solution: https://stackoverflow.com/questions/78457405/azapi-resource-action-invalid-value-for-str-parameter-string-required ╷ │ Error: Invalid function argument │ │ on main.tf line 41, in resource "azurerm_kubernetes_cluster" "k8s": │ 41: key_data = jsondecode(azapi_resource_action.ssh_public_key_gen.output).publicKey │ ├──────────────── │ │ while calling jsondecode(str) │ │ azapi_resource_action.ssh_public_key_gen.output is object with 2 attributes │ │ Invalid value for "str" parameter: string required. ╵ ╷ │ Error: Invalid function argument │ │ on ssh.tf line 24, in output "key_data": │ 24: value = jsondecode(azapi_resource_action.ssh_public_key_gen.output).publicKey │ ├──────────────── │ │ while calling jsondecode(str) │ │ azapi_resource_action.ssh_public_key_gen.output is object with 2 attributes │ │ Invalid value for "str" parameter: string required.

Problem 2

(there is a workaround in the main instruction; but it should not be done manually in fact; adding -raw parameter solves the problem)

If you see << EOT at the beginning and EOT at the end, remove these characters from the file. Otherwise, you may receive the following error message: error: error loading config file "./azurek8s": yaml: line 2: mapping values are not allowed in this context

Page URL

https://learn.microsoft.com/en-us/azure/aks/learn/quick-kubernetes-deploy-terraform?tabs=bash

Content source URL

https://github.com/MicrosoftDocs/azure-docs/blob/main/articles/aks/learn/quick-kubernetes-deploy-terraform.md

Author

@schaffererin

Document Id

93009f1b-a279-2a19-5c87-6352d8af10c8


Document Details

Do not edit this section. It is required for learn.microsoft.com ➟ GitHub issue linking.

PesalaPavan commented 1 month ago

@Dan-Zi Thanks for your feedback! We will investigate and update as appropriate.

AjayBathini-MSFT commented 1 month ago

@Dan-Zi Thanks for bringing this to our attention. I'm going to assign this to the document author so they can take a look at it accordingly.

rayoef commented 1 week ago

Thank you for your dedication to our documentation. Unfortunately, at this time we have been unable to review your issue in a timely manner, and we sincerely apologize for the delayed response. The requested updates have not been made since the creation of this issue, and the timeline for resolution may vary based on resourcing, so we've created an internal work item to incorporate your suggestions. We are closing this issue for now, but feel free to comment here as necessary.

please-close