結果的に README 記載の通りでしたが備忘録です。
CloudFormation Linter
AWS謹製 CloudFormation テンプレートの検証ツールです。
オプションは実行時引数で渡すか、 config file .cfnlintrc で指定ができます。
直接実行しても良いのですが、cfn-lint を実行する GitHub Action がいくつか公開されていたので、今回は以下の2つを使わせてもらって確認します。
ディレクトリ構成
. ├── .cfnlintrc ├── .github │ └── workflows │ ├── cfn-lint.yml
aws-cloudformation/cfn-lint: CloudFormation Linter を参考に .cfnlintrc にパラメータを書きます。
templates:
- "**/*.yaml"
- "**/*.yml"
ignore_templates:
- "etc/**"
Workflow
cfn-lint-action の場合
Usage を参考にワークフローを書きます。
cfn-lint コマンドを実行しているだけなので、所定の場所に config file を格納しておけば読み込んでくれます。
jobs:
cloudformation-linter:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Testing with CFN Lint Command
uses: scottbrenner/cfn-lint-action@v2
with:
command: cfn-lint --debug
actions-cfn-lint の場合
README には記載が無いですが、参考例が Template file not found due to use of quotes around multiple template file paths · Issue #187 · shogo82148/actions-cfn-lint にあります。 複数ファイルを対象にする場合に使います。
args に --config-file を指定することでconfig fileを読み込ませます。
(config file を読み込ませるだけであればargsの変更は不要で、同様に所定の場所に config file を格納しておけば読み込んでくれます。)
jobs:
cloudformation-linter:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Testing with CFN Lint Command
uses: shogo82148/actions-cfn-lint@v1
with:
args: --debug --config-file .cfnlintrc