如何解决cloudformation 将参数传递给 ssm 文件
目标是将多个参数传递给 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
出于某种原因,我收到以下错误消息:
模型验证失败(#/Parameters:预期类型:JSONObject,找到:JSONArray)
解决方法
找到solution:
Parameters:
EnvName1: [!Select [0,!Ref EnvNames]]
EnvName2: [!Select [1,!Ref EnvNames]]
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。