Хотите создать ассоциацию документа команды SSM с выходами в облачные журналы. Как я могу это сделать? - PullRequest
0 голосов
/ 17 октября 2019

Я пытался создать документ команды SSM, который выводит выходные данные команды runm и ошибки в cloudwatch. Я вижу возможность просто загрузить вывод на S3 путем создания ассоциации. Но не смог найти какой-либо вариант, чтобы подтолкнуть журналы в Cloudwatch. Любая помощь будет очень ценится здесь.

            - action: aws:downloadContent
              name: downloadContent
              inputs:
                sourceType: "{{ sourceType }}"
                sourceInfo: "{{ sourceInfo }}"
                destinationPath: "{{ workingDirectory }}"
            - precondition:
                StringEquals:
                - platformType
                - Windows
              action: aws:runPowerShellScript
              name: runPowerShellScript
              inputs:
                runCommand:
                - ''
                - "$directory = Convert-Path ."
                - $env:PATH += ";$directory"
                - " {{ commandLine }}"
                - if ($?) {
                - "    exit $LASTEXITCODE"
                - "} else {"
                - "    exit 255"
                - "}"
                - ''
                workingDirectory: "{{ workingDirectory }}"
                timeoutSeconds: "{{ executionTimeout }}"
            ``` 

This is my association template: 
```SSMAssociation:
    Type: AWS::SSM::Association
    Properties:
      AssociationName: !Ref AssociationName
      Name: !Ref SSMDocumentName
      DocumentVersion: "$LATEST"
      ScheduleExpression: !Sub 'cron${CronExpression}'
      Parameters:
        workingDirectory: [!Ref WorkingDirectory]
        commandLine: [!Ref CommandLine ]

        sourceType: [!Ref SourceType ]
        executionTimeout: [!Ref ExecutionTimeout]
      OutputLocation:
        S3Location:
          OutputS3BucketName: test-ssm-automation
          OutputS3KeyPrefix: test
      Targets:
      - Key: !Sub "tag:${TagKeyName}"
        Values: 
          - !Ref TagValue
                 ``` 

Is there any way i can have the output of these command  pushed to cloudwatch easily. 
...