schemaVersion: "2.2" description: "A composite document for installing and configuring the CloudWatch Agent." parameters: sourceInfoWindows: description: "Amazon S3 bucket used to store CloudWatch configuration files" type: StringMap displayType: "textarea" default: path: Fn::Join: - '' - - 'https://s3.amazonaws.com/' - !Select [5, !Split [":", !Ref CloudWatchConfigBucketARN]] - '/config/standard/windows' sourceInfoLinux: description: "Amazon S3 bucket used to store CloudWatch configuration files" type: StringMap displayType: "textarea" default: path: Fn::Join: - '' - - 'https://s3.amazonaws.com/' - !Select [5, !Split [":", !Ref CloudWatchConfigBucketARN]] - '/config/standard/linux' mainSteps: - precondition: StringEquals: - platformType - Linux action: aws:runShellScript name: first inputs: runCommand: - sleep 300 - precondition: StringEquals: - platformType - Windows action: aws:runPowerShellScript name: second inputs: runCommand: - Start-Sleep -Seconds 300 - action: aws:runDocument name: installCWAgent inputs: documentType: SSMDocument documentPath: AWS-ConfigureAWSPackage documentParameters: action: Install name: AmazonCloudWatchAgent - action: aws:downloadContent precondition: StringEquals: - platformType - Windows name: DownloadStandardCloudWatchConfigWindows inputs: sourceType: S3 sourceInfo: "{{ sourceInfoWindows }}" destinationPath: "C:\\ProgramData\\Amazon\\AmazonCloudWatchAgent\\Configs" - action: aws:runPowerShellScript precondition: StringEquals: - platformType - Windows name: DeleteEtagFilesWindows inputs: timeoutSeconds: '60' runCommand: - cd C:\\ProgramData\\Amazon\\AmazonCloudWatchAgent\\Configs - del /f /s *.etag - action: "aws:runDocument" precondition: StringEquals: - platformType - Windows name: "StopCloudWatchWindows" inputs: documentType: "SSMDocument" documentPath: "AmazonCloudWatch-ManageAgent" documentParameters: action: "stop" mode: "ec2" - action: "aws:runDocument" precondition: StringEquals: - platformType - Windows name: "StartCloudWatchWindows" inputs: documentType: "SSMDocument" documentPath: "AmazonCloudWatch-ManageAgent" documentParameters: action: "start" mode: "ec2" - action: aws:downloadContent precondition: StringEquals: - platformType - Linux name: downloadStandardCloudWatchConfigLinux inputs: sourceType: S3 sourceInfo: "{{ sourceInfoLinux }}" destinationPath: "/opt/aws/amazon-cloudwatch-agent/etc/amazon-cloudwatch-agent.d" - action: aws:runShellScript precondition: StringEquals: - platformType - Linux name: DeleteEtagFilesLinux inputs: timeoutSeconds: '60' runCommand: - cd /opt/aws/amazon-cloudwatch-agent/etc/amazon-cloudwatch-agent.d - find . -name \*.etag -type f -delete - action: "aws:runDocument" precondition: StringEquals: - platformType - Linux name: "StopCloudWatchLinux" inputs: documentType: "SSMDocument" documentPath: "AmazonCloudWatch-ManageAgent" documentParameters: action: "stop" mode: "ec2" - action: "aws:runDocument" precondition: StringEquals: - platformType - Linux name: "StartCloudWatchLinux" inputs: documentType: "SSMDocument" documentPath: "AmazonCloudWatch-ManageAgent" documentParameters: action: "start" mode: "ec2"