🏷️

Unresolved tagをちゃんと解決するyaml.customTags

2024/01/27に公開

Visual Studio CodeでAWS CloudFormationテンプレートを作成する際の「Unresolved tag」警告をちゃんと解決するyaml.customTagsの設定を紹介します。ネットで見つけられる設定では少し足りない場合があります。

結論

    "yaml.customTags": [
        "!Base64",
        "!Cidr sequence",
        "!And sequence",
        "!Equals sequence",
        "!If sequence",
        "!Not sequence",
        "!Or sequence",
        "!Condition",
        "!FindInMap sequence",
        "!GetAtt",
        "!GetAtt sequence",
        "!GetAZs",
        "!ImportValue",
        "!Join sequence",
        "!Select sequence",
        "!Split sequence",
        "!Sub",
        "!Sub sequence",
        "!Transform mapping",
        "!Ref"
    ]

解説

yaml.customTagsでは"!Ref sequence"のようにして、scalar(文字列と真偽値)、sequence(配列)、mapping(オブジェクト)のいずれかの型を指定する必要があります。単に"!Ref"とした場合はscalarを指定したことになります。

https://github.com/redhat-developer/vscode-yaml

したがって、CloudFormationの組み込み関数に入力される値の型に合わせてyaml.customTagsを記述すればよいことになります。

https://docs.aws.amazon.com/ja_jp/AWSCloudFormation/latest/UserGuide/intrinsic-function-reference.html

あとがき

足りなかったら教えてください……

Discussion