AWS System Manager CLI 函数
AWS System Manager CLI function
当 运行 使用 CLI 命令创建 AWS System Manager Association 任务时,我 运行 遇到了麻烦。命令是下面列出的一个:
aws ssm create-association --name AWS-RunRemoteScript --targets Key=instanceids,Values=i-03710c82b70551c32 --parameters '{"sourceType":["S3"],"sourceInfo":["{"path":\"https://s3-eu-west-1.amazonaws.com/xxx/private/xxx.ps1\"}"],"commandLine":["xxx.ps1"]}' --schedule-expression "cron(0 0 2 ? * SUN *)"
每次我收到一个错误,提示参数部分有问题,但我已经尝试了所有引号组合,但找不到任何修复方法。
Error parsing parameter '--parameters': Expected: '=', received: '''
for input:
'{sourceType:[S3],sourceInfo:[{https://s3-eu-west-1.amazonaws.com/xxx/private/xxx.ps1"}],commandLine:[xxx]}'
有人遇到过类似的问题吗?
sourceInfo
需要一个字符串列表。请务必转义字符串中的任何引号。
而不是:
'{"sourceType":["S3"],"sourceInfo":["{"path":\"https://s3-eu-west-1.amazonaws.com/xxx/private/xxx.ps1\"}"],"commandLine":["xxx.ps1"]}'
使用这个:
'{"sourceType":["S3"],"sourceInfo":["{\"path\":\"https://s3-eu-west-1.amazonaws.com/xxx/private/xxx.ps1\"}"],"commandLine":["xxx.ps1"]}'
我在 Mac 上工作得很好:
$ aws ssm create-association --name AWS-RunRemoteScript --targets Key=instanceids,Values=i-03710c82b70551c32 --parameters '{"sourceType":["S3"],"sourceInfo":["{\"path\":\"https://s3-eu-west-1.amazonaws.com/xxx/private/xxx.ps1\"}"],"commandLine":["xxx.ps1"]}' --schedule-expression "cron(0 0 2 ? * SUN *)"
{
"AssociationDescription": {
"Name": "AWS-RunRemoteScript",
"AssociationVersion": "1",
"Date": 1551432508.365,
"LastUpdateAssociationDate": 1551432508.365,
"Overview": {
"Status": "Pending",
"DetailedStatus": "Creating"
},
"DocumentVersion": "$DEFAULT",
"Parameters": {
"commandLine": [
"xxx.ps1"
],
"sourceInfo": [
"{\"path\":\"https://s3-eu-west-1.amazonaws.com/xxx/private/xxx.ps1\"}"
],
"sourceType": [
"S3"
]
},
"AssociationId": "5de73031-a390-4e7f-8b99-8064584e84cb",
"Targets": [
{
"Key": "instanceids",
"Values": [
"i-03710c82b70551c32"
]
}
],
"ScheduleExpression": "cron(0 0 2 ? * SUN *)"
}
}
当 运行 使用 CLI 命令创建 AWS System Manager Association 任务时,我 运行 遇到了麻烦。命令是下面列出的一个:
aws ssm create-association --name AWS-RunRemoteScript --targets Key=instanceids,Values=i-03710c82b70551c32 --parameters '{"sourceType":["S3"],"sourceInfo":["{"path":\"https://s3-eu-west-1.amazonaws.com/xxx/private/xxx.ps1\"}"],"commandLine":["xxx.ps1"]}' --schedule-expression "cron(0 0 2 ? * SUN *)"
每次我收到一个错误,提示参数部分有问题,但我已经尝试了所有引号组合,但找不到任何修复方法。
Error parsing parameter '--parameters': Expected: '=', received: ''' for input: '{sourceType:[S3],sourceInfo:[{https://s3-eu-west-1.amazonaws.com/xxx/private/xxx.ps1"}],commandLine:[xxx]}'
有人遇到过类似的问题吗?
sourceInfo
需要一个字符串列表。请务必转义字符串中的任何引号。
而不是:
'{"sourceType":["S3"],"sourceInfo":["{"path":\"https://s3-eu-west-1.amazonaws.com/xxx/private/xxx.ps1\"}"],"commandLine":["xxx.ps1"]}'
使用这个:
'{"sourceType":["S3"],"sourceInfo":["{\"path\":\"https://s3-eu-west-1.amazonaws.com/xxx/private/xxx.ps1\"}"],"commandLine":["xxx.ps1"]}'
我在 Mac 上工作得很好:
$ aws ssm create-association --name AWS-RunRemoteScript --targets Key=instanceids,Values=i-03710c82b70551c32 --parameters '{"sourceType":["S3"],"sourceInfo":["{\"path\":\"https://s3-eu-west-1.amazonaws.com/xxx/private/xxx.ps1\"}"],"commandLine":["xxx.ps1"]}' --schedule-expression "cron(0 0 2 ? * SUN *)"
{
"AssociationDescription": {
"Name": "AWS-RunRemoteScript",
"AssociationVersion": "1",
"Date": 1551432508.365,
"LastUpdateAssociationDate": 1551432508.365,
"Overview": {
"Status": "Pending",
"DetailedStatus": "Creating"
},
"DocumentVersion": "$DEFAULT",
"Parameters": {
"commandLine": [
"xxx.ps1"
],
"sourceInfo": [
"{\"path\":\"https://s3-eu-west-1.amazonaws.com/xxx/private/xxx.ps1\"}"
],
"sourceType": [
"S3"
]
},
"AssociationId": "5de73031-a390-4e7f-8b99-8064584e84cb",
"Targets": [
{
"Key": "instanceids",
"Values": [
"i-03710c82b70551c32"
]
}
],
"ScheduleExpression": "cron(0 0 2 ? * SUN *)"
}
}