![](/img/trans.png)
[英]How to create an 'AWS::SSM::Document' with DocumentType of Package using CloudFormation
[英]AWS Cloudformation SSM automation document | use with aws cloudformation package
在 AWS Cloudformation 中,我可以通过 CLI 使用cloudformation package
命令。 例如,这适用于 Lambda:
lambda:
Type: AWS::Lambda::Function
Properties:
Handler: helloWorld.lambda_handler
Role: !GetAtt lambda.Arn
Code: lambda/helloWorld.py
现在,我想在 Systems Manager 自动化文件中添加类似Code: lambda/helloWorld.py
的内容。
例如,而不是命令下的Restart-Computer -Force
行commands:
我想使用如下外部脚本( commands: scripts/restart.ps1
):
#---Original
[...]
- name: restartEC2Instance
action: aws:runCommand
maxAttempts: 3
timeoutSeconds: 600
inputs:
DocumentName: AWS-RunPowerShellScript
InstanceIds:
- "{{ InstanceId }}"
Parameters:
commands: |
Restart-Computer -Force
executionTimeout: "600"
[...]
#---Desired
[...]
- name: restartEC2Instance
action: aws:runCommand
maxAttempts: 3
timeoutSeconds: 600
inputs:
DocumentName: AWS-RunPowerShellScript
InstanceIds:
- "{{ InstanceId }}"
Parameters:
commands: scripts/restart.ps1
executionTimeout: "600"
[...]
您知道实现这一点的任何可能性吗? 提前致谢!
有一个名为AWS-RunRemoteScript的命令文档:
您可以使用 AWS-RunDocument 预定义的 SSM 文档从远程位置运行 SSM 文档。 本文档当前支持以下远程位置:GitHub 存储库(公共和私有)、 Amazon S3 、保存在 Systems Manager 中的文档
但是,如果您希望 CLI 自动将本地文件上传到 S3,就像 lambda 一样,那么遗憾的是,SSM 文档不支持此功能。 仅以下CFN 资源类型支持自动上传本地工件:
BodyS3Location property for the AWS::ApiGateway::RestApi resource
Code property for the AWS::Lambda::Function resource
CodeUri property for the AWS::Serverless::Function resource
DefinitionS3Location property for the AWS::AppSync::GraphQLSchema resource
RequestMappingTemplateS3Location property for the AWS::AppSync::Resolver resource
ResponseMappingTemplateS3Location property for the AWS::AppSync::Resolver resource
DefinitionUri property for the AWS::Serverless::Api resource
Location parameter for the AWS::Include transform
SourceBundle property for the AWS::ElasticBeanstalk::ApplicationVersion resource
TemplateURL property for the AWS::CloudFormation::Stack resource
Command.ScriptLocation property for the AWS::Glue::Job resource
DefinitionS3Location property for the AWS::StepFunctions::StateMachine resource
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.