-
Notifications
You must be signed in to change notification settings - Fork 1.2k
/
eks-ssm-content.json
81 lines (81 loc) · 3.04 KB
/
eks-ssm-content.json
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
{
"schemaVersion":"2.2",
"description":"EKS Log Collector",
"parameters":{
"bucketName":{
"type": "String",
"default": "Enabled"
}
},
"mainSteps":[
{
"action": "aws:runShellScript",
"name": "PatchLinux",
"precondition": {
"StringEquals": [
"platformType",
"Linux"
]
},
"inputs": {
"runCommand": [
"curl -O https://raw.githubusercontent.com/awslabs/amazon-eks-ami/master/log-collector-script/linux/eks-log-collector.sh",
"bash ./eks-log-collector.sh >/dev/null 2>&1",
"echo \"EKS logs collected\"",
"if [ -f /usr/local/bin/aws ]; then",
"echo \"AWS_already_installed\"",
"else",
"echo \"Installing AWSCLI\"",
"curl \"https://s3.amazonaws.com/aws-cli/awscli-bundle.zip\" -o \"awscli-bundle.zip\" >/dev/null 2>&1",
"yum install unzip -y >/dev/null 2>&1",
"unzip awscli-bundle.zip >/dev/null 2>&1",
"./awscli-bundle/install -i /usr/local/aws -b /usr/local/bin/aws",
"echo \"AWSCLI version is\"",
"/usr/local/bin/aws --version",
"fi",
"echo \"Pushing to S3\"",
"/usr/local/bin/aws s3 cp --recursive /opt/log-collector/ s3://{{bucketName}}",
"echo \"Logs uploaded to S3\""
]
}
},
{
"precondition": {
"StringEquals": [
"platformType",
"Windows"
]
},
"action": "aws:runPowerShellScript",
"name": "PatchWindows",
"inputs": {
"runCommand": [
"if (!(Get-Module 'AWSPowerShell')) { ",
" Write-Host 'AWSPowerShell does not exist' ",
" Install-Module -Name AWSPowerShell -Force ",
"} ",
"try { ",
" Write-Host 'Downloading EKS Log collector script' ",
" Invoke-WebRequest -UseBasicParsing 'https://raw.githubusercontent.com/awslabs/amazon-eks-ami/master/log-collector-script/windows/eks-log-collector.ps1' -OutFile eks-log-collector.ps1 ",
"} ",
"catch { ",
" Write-Host 'Uploaded to S3 failed' ",
" break ",
"} ",
"powershell .\\eks-log-collector.ps1",
"try { ",
" Write-Host 'Pushing to S3' ",
" Write-S3Object -BucketName {{bucketName}} -Folder C:\\log-collector -KeyPrefix eks-log-collector\\ -SearchPattern *.zip ",
" Write-Host 'Logs uploaded to S3' ",
"} ",
"catch { ",
" Write-Host 'Uploaded to S3 failed' ",
" break ",
"} ",
"",
"Remove-Item -Force .\\eks-log-collector.ps1 -ErrorAction Ignore "
]
}
}
]
}