amazon-web-services - 想要通过电子邮件发送云形成输出

标签 amazon-web-services powershell aws-cloudformation devops aws-cloudformation-custom-resource

我正在编写一个云形成模板,其中运行两个 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/

相关文章:

amazon-web-services - 从Internet下载文件到S3存储桶

PowerShell - 运行 bat/cmd 文件后获取环境变量

amazon-web-services - 如何在Cloudformation模板中动态生成键名?

amazon-web-services - 如何通过cloudformation更新我现有的lambda(不是由cloudformation创建的)。通过cloudformation设置管道

amazon-web-services - REST API 的 CloudFormation 堆栈错误不包含任何方法

javascript - NodeJS 从 AWS S3 存储桶下载文件

amazon-web-services - AWS elastic beanstalk nginx 配置不适用于我的 Nodejs Web 应用程序

powershell - 使用 powershell 和 7zip 创建存档的脚本

azure - 如何使用 Powershell 从订阅获取 Cosmos DB 的数据大小

google-chrome - Chrome——AWS Lambda 的 headless ?