Resolving “Unresolved tag: <tag>” for CloudFormation Templates

· 2 min read ·
AWSDevOps

When working with AWS CloudFormation templates in VSCode, issues with unresolved tags such as !ImportValue, !Ref, etc. may encountered. These custom tags are essential for creating CloudFormation templates, and properly configuring VSCode to recognize them can significantly improve template crafting experience.

Custom Tags in YAML

Custom tags in YAML allow architects, developers, and engineers to embed domain-specific data in YAML files. These tags are used to define specific intrinsic functions that AWS CloudFormation can interpret and execute, and are crucial for creating dynamic and flexible infrastructure as code.

Guide to Add Custom Tags

To resolve the “Unresolved tag: !ImportValue” and other similar issues, custom tags need to be added to VSCode settings. Follow these steps:

  1. Open VSCode, cmd + shift + P (or ctrl + shift + P on Windows) and choose “Preferences: Open User Settings (JSON)”.

  2. Add the following lines to the settings.json file:

    "yaml.customTags": [
      "!Equals sequence",
      "!FindInMap sequence",
      "!GetAtt",
      "!GetAZs",
      "!ImportValue",
      "!Join sequence",
      "!Ref",
      "!Select sequence",
      "!Split sequence",
      "!Sub"
    ]
  3. Save the file and restart VSCode (cmd + shift + P, then choose “Developer: Reload Windows”) to apply the changes.

Explanation of Each Custom Tag

Here’s a brief explanation of each custom tag added: