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

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

Open
Dan-Zi opened this issue Jun 20, 2024 · 2 comments

Comments

@Dan-Zi
Copy link

Dan-Zi commented Jun 20, 2024

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
Copy link
Contributor

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

@AjayBathini-MSFT
Copy link
Contributor

@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.

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

No branches or pull requests

4 participants