powershell 想要通过电子邮件发送云形成输出

tjvv9vkg  于 2023-02-08  发布在  Shell
关注(0)|答案(1)|浏览(152)

我正在写一个云形成模板,在那里我运行了两个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
h6my8fg2

h6my8fg21#

您可以在Powershell脚本中使用AWS CLI命令'sesend-email'或将其作为运行命令参数的一部分吗?当然,您必须事先在cfn模板或控制台中配置SES服务。
您可以使用AWS CLI命令ssm get-parameters从参数存储中检索电子邮件地址。
要存储脚本的输出,可以使用本地文件、参数存储,或者dynamodb表等。
https://awscli.amazonaws.com/v2/documentation/api/latest/reference/ses/send-email.htmlhttps://awscli.amazonaws.com/v2/documentation/api/latest/reference/ssm/get-parameters.html

相关问题