提问人:Sree Teja 提问时间:9/13/2023 最后编辑:Ermiya EskandarySree Teja 更新时间:9/13/2023 访问量:78
为什么在尝试创建 SSM 文档时会收到 InvalidDocumentContent?
Why do I get InvalidDocumentContent when trying to create a SSM document?
问:
我想在 EC2 实例上运行一些 shell 命令,因此我遇到了使用 SSM 文档的 AWS Systems Manager Run Command。
我正在尝试创建命令文档,但在步骤名称中出现错误。InvalidDocumentContent
文档如下:
{
"schemaVersion": "2.2",
"description": "Run svc-db-proxy Container",
"parameters": {
"AccessKeyID": {
"type": "String",
"description": "AWS Access Key ID"
},
"SecretAccessKey": {
"type": "String",
"description": "AWS Secret Access Key"
},
"AWSRegion": {
"type": "String",
"description": "AWS Region",
"default": "ca-central-1"
},
"Registry": {
"type": "String",
"description": "AWS ECR Registry URL"
},
"Repo": {
"type": "String",
"description": "AWS ECR Repository"
},
"Tag": {
"type": "String",
"description": "GitHub SHA used for Image tag"
}
},
"mainSteps": [
{
"action": "aws:runShellScript",
"name": "Deploy svc db proxy container",
"inputs": {
"timeoutSeconds": "3600",
"runCommand": [
"#!/bin/bash",
"export AWS_ACCESS_KEY_ID=\"{{AccessKeyID}}\"",
"export AWS_SECRET_ACCESS_KEY=\"{{SecretAccessKey}}\"",
"docker login -u AWS -p $(aws ecr get-login-password --region \"{{AWSRegion}}\") {{Registry}}",
"docker kill {{Repo}} || true",
"docker container prune -f || true",
"docker image prune -af || true",
"docker pull {{Registry}}/{{Repo}}:{{Tag}}",
"docker run --name {{Repo}} -p 8001:8000 -d {{Registry}}/{{Repo}}:{{Tag}}",
"docker logout {{Registry}}",
"unset \"AWS_ACCESS_KEY_ID\"",
"unset \"AWS_SECRET_ACCESS_KEY\""
]
}
}
]
}
答:
1赞
Ermiya Eskandary
9/13/2023
#1
步骤名称不能包含空格。
根据文档,允许的正则表达式模式是 。此模式不包括空格。name
[a-zA-Z0-9_]+$
删除空格,它将通过验证,例如
"name": "deploySvcContainer",
评论
1赞
Sree Teja
9/13/2023
啊,是的,谢谢!!它真的奏效了,我永远不会猜到。:)
1赞
Ermiya Eskandary
9/14/2023
@SreeTeja 不客气,享受使用 AWS :)
评论