我正在编写一个云形成模板,其中运行两个 powershell 脚本。现在我想获取两个脚本的输出,并将其发送到云形成参数中已提到的电子邮件。
这是代码:-
AWSTemplateFormatVersion: '2010-09-09'
Description: Test Document
Resources:
Type: AWS::SSM::Document
Properties:
DocumentType: Command
Name: "Test Upgrade"
Content:
schemaVersion: '2.2'
description: "Test Upgrade"
parameters:
Emails:
type: String
description: |-
enter the email address to send the overall output
mainSteps:
- action: "aws:runPowerShellScript"
name: "DriverUpgrade"
precondition:
StringEquals: ["platformType", "Windows"]
inputs:
runCommand:
[]
timeoutSeconds: 3600
onFailure: Continue
maxAttempts: 1
isCritical: False
nextStep: Second Driver
- action: "aws:runPowerShellScript"
name: "SecondDriverUpgrade"
precondition:
StringEquals: ["platformType", "Windows"]
inputs:
runCommand:
[]
timeoutSeconds: 3600
onFailure: Continue
isCritical: False
最佳答案
您可以在 Powershell 脚本内使用 AWS CLI 命令“ses send-email”或将其作为运行命令参数的一部分吗? 当然,您必须事先在cfn模板或控制台中配置SES服务。
您可以使用 AWS CLI 命令 ssm get-parameters 从参数存储中检索电子邮件地址。
要存储脚本的输出,您可以使用本地文件、参数存储,或者例如 dynamodb 表等。
https://awscli.amazonaws.com/v2/documentation/api/latest/reference/ses/send-email.html https://awscli.amazonaws.com/v2/documentation/api/latest/reference/ssm/get-parameters.html
关于amazon-web-services - 想要通过电子邮件发送云形成输出,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/75191932/