You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

升级cfn-lint至1.8.2版本后出现E1101错误求助

解决cfn-lint 1.8.2版本的E1101错误

你遇到的E1101 Exception 'a string or stream input is required'错误,是因为cfn-lint 1.8.2在解析SSM Document的Content字段时,对字符串形式的嵌套JSON处理出现异常——模板里的Content用引号包裹了JSON字符串,里面的转义引号和复杂结构导致解析失败。

解决方案

将Content字段的字符串形式JSON改为YAML原生的对象结构,无需用引号包裹,直接编写层级结构:

Type: "AWS::SSM::Document"
    Metadata:
      cfn-lint:
        config:
          ignore_checks:
            - E1029
    Properties:
      DocumentType: Command
      Content:
        schemaVersion: "2.0"
        description: "Backup"
        mainSteps:
          - action: "aws:runPowerShellScript"
            name: "Backup"
            inputs:
              runCommand:
                - "$s3install = aws cloudformation list-exports --query \"Exports[?Name==''s3InstallFiles''].Value\" --output text"
                - "aws s3 cp s3://[BucketName]/Backup.ps1 c:\\Backup.ps1"
                - "c:\\Backup.ps1"
                - "if ($?) {exit $LASTEXITCODE } else { exit 255 }"
                - "Write-Output \"Fertig. Erfolgreich\""

原理说明

cfn-lint 1.8.2加强了对SSM Document内容的校验逻辑,字符串形式的嵌套JSON容易因转义字符、格式细节触发解析异常。改用YAML原生对象结构后,cfn-lint可以直接解析内容结构,避免字符串解析问题,同时保持模板语法正确。

内容的提问来源于stack exchange,提问作者Daria

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.20 17:37:08