[英]AWS Cloudformation SSM automation document | use with aws cloudformation package
in AWS Cloudformation I could use the cloudformation package
command via CLI.在 AWS Cloudformation 中,我可以通过 CLI 使用
cloudformation package
命令。 This works for example with Lambdas:例如,这适用于 Lambda:
lambda:
Type: AWS::Lambda::Function
Properties:
Handler: helloWorld.lambda_handler
Role: !GetAtt lambda.Arn
Code: lambda/helloWorld.py
Now, I would like to to the same like Code: lambda/helloWorld.py
within Systems Manager automation documents.现在,我想在 Systems Manager 自动化文件中添加类似
Code: lambda/helloWorld.py
的内容。
For example instead of the line Restart-Computer -Force
under commands:
I would like to use external skripts like this below ( commands: scripts/restart.ps1
):例如,而不是命令下的
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"
[...]
Do you know any possibility to realize this?您知道实现这一点的任何可能性吗? Thanks in advance!
提前致谢!
There is command documment called AWS-RunRemoteScript :有一个名为AWS-RunRemoteScript的命令文档:
You can run SSM documents from remote locations by using the AWS-RunDocument pre-defined SSM document.
您可以使用 AWS-RunDocument 预定义的 SSM 文档从远程位置运行 SSM 文档。 This document currently supports the following remote locations: GitHub repositories (public and private), Amazon S3 , Documents saved in Systems Manager
本文档当前支持以下远程位置:GitHub 存储库(公共和私有)、 Amazon S3 、保存在 Systems Manager 中的文档
However, if you want the CLI to automatically upload your local file to S3, like it does for lambda, then this functionality is sadly not supported for SSM documents.但是,如果您希望 CLI 自动将本地文件上传到 S3,就像 lambda 一样,那么遗憾的是,SSM 文档不支持此功能。 The automatic upload of local artifacts is only supported for the following CFN resource types:
仅以下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.