Need help in the terraform code for validation of naming convention

Swathi Reddy 186 Reputation points
2023-11-20T09:59:23.0933333+00:00

keyvault_terraform.txt

Need help in terraforming the code (azure keyvault )with the specific naming conventions

Attached the code in the text file.

I have below terraform code, need help in identifying which value to be given for a specific solution_settings variable and the code should work as I am new to Terraform.

Azure Key Vault
Azure Key Vault
An Azure service that is used to manage and protect cryptographic keys and other secrets used by cloud apps and services.
1,448 questions
0 comments No comments
{count} votes

Accepted answer
  1. JamesTran-MSFT 36,906 Reputation points Microsoft Employee Moderator
    2023-11-21T21:53:17.7733333+00:00

    @Swathi Reddy

    Thank you for your post and I apologize for the delayed response! To hopefully help point you in the right direction, I'll share my findings based off your Terraform script and error messages below.

    Error Message 1:

    Error: Unsupported attribute on main.tf line 2, in locals: 2: key_vault_name = coalesce(var.key_vault_name, module.solution_settings.key_vault_name) module.solution_settings is a object. This object does not have an attribute named "key_vault_name".

    This error message indicates that the object module.solution_settings doesn't have an attribute named "key_vault_name". This suggests that the key_vault_name variable is not defined in the solution_settings module.

    • When looking into your variables.tf file of the solution_settings module, it looks like you set the default key_vault_name variable as an empty string. Can you make sure that the key_vault_name variable within the Module Solutionsettings was correctly set?
    • I notice you're trying to set it to key_vault_name = "${local.name_prefix}akv"

    Error Message 2:

    Error: Invalid value for input variable on solutionsettings.tf line 4, in module "solution_settings": 4: solution_name = "testmm" The given value is not suitable for module.solution_settings.var.solution_name declared at solutionsettings\variables.tf:1,1-25: map of any single type required.

    The second error indicates that the solution_name variable is not the correct type. The solution_name variable is defined as a map of any single type, but the value provided (testmm) is a string.

    • Can you make sure you used the correct value or type when it comes to the solution_name variable?

    User's image


    Error Message 3:

    Error: Invalid value for variable │ │ on solutionsettings.tf line 10, in module "solution_settings": │ 10: tags....

    The last error message is regarding issues with the tags variable. When referencing our Microsoft.KeyVault vaults Terraform script, I noticed that each tag is written with an "equals =" sign but within your Terraform script you're using a "colon :".

      tags = {
        tagName1 = "tagValue1"
        tagName2 = "tagValue2"
      }
    
    • Can you ensure that the tag values are correct and see if updating the sign value helps to resolve this error?

    User's image


    Additional Links:

    I hope this helps!

    If you have any other questions, please let me know. Thank you for your time and patience throughout this issue.


    If the information helped address your question, please Accept the answer. This will help us and also improve searchability for others in the community who might be researching similar information.

    0 comments No comments

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.