cloudformation 将参数传递给 ssm 文档

cloudformation passing parameters to ssm ducument

目标是将多个参数传递给 SSM 文档。 我正在使用以下模板:

AWSTemplateFormatVersion: 2010-09-09
Parameters:
  EnvNames:
    Description: List of parameters
    Type: CommaDelimitedList
Resources:
    Document:
      Type: AWS::SSM::Document
      Properties:
        DocumentType: Command
        Content:
          schemaVersion: '2.2'
          description: Run a PowerShell script
          parameters:
            EnvName1:
              type: String
            EnvName2:
             type: String
        mainSteps:
        - action: aws:runPowerShellScript
          name: devDocument
          precondition:
            StringEquals:
            - platformType
            - Windows
          inputs:
            runCommand:
            - !Sub |
              # Retrieve values from parameters
              $EnvName1 = "{{EnvName1}}"
              $EnvName2 = "{{EnvName2}}"
              New-Item -ItemType directory -Path C:\temp
              $EnvName1 > C:\temp\EnvName1.txt
              $EnvName2 > C:\temp\EnvName2.txt
  SSM:
    Type: AWS::SSM::Association
    Properties: 
      Name: !Ref Document
      Parameters: 
        - Key: EnvName1
          Value: 
          - !Select [0, !Ref EnvNames]
        - Key: EnvName2
          Value: 
          - !Select [1, !Ref EnvNames]
      Targets:
        - Key: tag:id
          Values:
          - !Ref Node1
          - !Ref Node2

出于某种原因,我收到以下错误消息:

模型验证失败(#/参数:预期类型:JSONObject,发现:JSONArray)

找到 solution:

Parameters: 
  EnvName1: [!Select [0, !Ref EnvNames]]
  EnvName2: [!Select [1, !Ref EnvNames]]