Skip to content

Commit

Permalink
Merge pull request #202 from lorengordon/cwa-install
Browse files Browse the repository at this point in the history
Updates CloudWatch Agent install to account for changes to upstream package
  • Loading branch information
lorengordon authored Apr 10, 2019
2 parents 8dfbc31 + 1ff8ef3 commit a1c00a0
Show file tree
Hide file tree
Showing 3 changed files with 78 additions and 49 deletions.
25 changes: 12 additions & 13 deletions templates/ra_rdcb_fileserver_standalone.template.cfn.json
Original file line number Diff line number Diff line change
Expand Up @@ -187,9 +187,9 @@
"Type": "String"
},
"CloudWatchAgentUrl": {
"AllowedPattern": "^$|^s3://.*$",
"AllowedPattern": "^$|^s3://.*\\.msi$",
"Default": "",
"Description": "(Optional) S3 URL to CloudWatch Agent installer. Example: s3://amazoncloudwatch-agent/windows/amd64/latest/AmazonCloudWatchAgent.zip",
"Description": "(Optional) S3 URL to CloudWatch Agent MSI. Example: s3://amazoncloudwatch-agent/windows/amd64/latest/amazon-cloudwatch-agent.msi",
"Type": "String"
},
"DataVolumeSize": {
Expand Down Expand Up @@ -1069,32 +1069,31 @@
"command"
]
},
" \"& { ",
" -Command \"Invoke-Command -ScriptBlock { ",
"$ErrorActionPreference = 'Stop'; ",
"$CloudWatchAgentUri = [System.Uri]'",
{
"Ref": "CloudWatchAgentUrl"
},
"'; ",
"$CloudWatchAgentScriptDir = 'c:\\cfn\\scripts\\AmazonCloudWatchAgent'; ",
"$CloudWatchAgentZipFile = Join-Path $CloudWatchAgentScriptDir $CloudWatchAgentUri.Segments[($CloudWatchAgentUri.Segments.Length-1)]; ",
"$CloudWatchAgentInstaller = Join-Path $CloudWatchAgentScriptDir $CloudWatchAgentUri.Segments[($CloudWatchAgentUri.Segments.Length-1)]; ",
"$Null = New-Item $CloudWatchAgentScriptDir -Type Directory -Force; ",
"Read-S3Object",
" -BucketName $CloudWatchAgentUri.Host",
" -Key ($CloudWatchAgentUri.Segments[1..($CloudWatchAgentUri.Segments.Length-1)] -Join '')",
" -File $CloudWatchAgentZipFile",
" -File $CloudWatchAgentInstaller",
" -Region ",
{
"Ref": "AWS::Region"
},
"; ",
"$CloudWatchAgentInstallScript = \"$CloudWatchAgentScriptDir\"+'\\install.ps1';",
"$CloudWatchAgentConfig = \"$CloudWatchAgentScriptDir\"+'\\aws-cloudwatch-agent-config.json';",
" Expand-Archive -Path $CloudWatchAgentZipFile -DestinationPath $CloudWatchAgentScriptDir;",
"Push-Location -Path $CloudWatchAgentScriptDir;",
"iex $CloudWatchAgentInstallScript;",
".\\amazon-cloudwatch-agent-ctl.ps1 -a fetch-config -m ec2 -c file:$CloudWatchAgentConfig -s;",
"Pop-Location",
"}\""
"$CloudWatchAgentConfig = $CloudWatchAgentScriptDir + '\\aws-cloudwatch-agent-config.json'; ",
"Start-Process msiexec.exe -Wait -ArgumentList \\\"/i $CloudWatchAgentInstaller\\\"; ",
"$CloudWatchAgentCtl = \\\"${Env:ProgramFiles}\\Amazon\\AmazonCloudWatchAgent\\amazon-cloudwatch-agent-ctl.ps1\\\"; ",
"& $CloudWatchAgentCtl -Action cond-restart; ",
"& $CloudWatchAgentCtl -a fetch-config -m ec2 -c file:$CloudWatchAgentConfig -s; ",
"} -Verbose -ErrorAction Stop\""
]
]
},
Expand Down
50 changes: 33 additions & 17 deletions templates/ra_rdgw_autoscale_public_lb.template.cfn.json
Original file line number Diff line number Diff line change
Expand Up @@ -222,9 +222,9 @@
"Type": "String"
},
"CloudWatchAgentUrl": {
"AllowedPattern": "^$|^s3://.*$",
"AllowedPattern": "^$|^s3://.*\\.msi$",
"Default": "",
"Description": "(Optional) S3 URL to CloudWatch Agent installer. Example: s3://amazoncloudwatch-agent/windows/amd64/latest/AmazonCloudWatchAgent.zip",
"Description": "(Optional) S3 URL to CloudWatch Agent MSI. Example: s3://amazoncloudwatch-agent/windows/amd64/latest/amazon-cloudwatch-agent.msi",
"Type": "String"
},
"DesiredCapacity": {
Expand Down Expand Up @@ -707,32 +707,31 @@
"command"
]
},
" \"& { ",
" -Command \"Invoke-Command -ScriptBlock { ",
"$ErrorActionPreference = 'Stop'; ",
"$CloudWatchAgentUri = [System.Uri]'",
{
"Ref": "CloudWatchAgentUrl"
},
"'; ",
"$CloudWatchAgentScriptDir = 'c:\\cfn\\scripts\\AmazonCloudWatchAgent'; ",
"$CloudWatchAgentZipFile = Join-Path $CloudWatchAgentScriptDir $CloudWatchAgentUri.Segments[($CloudWatchAgentUri.Segments.Length-1)]; ",
"$CloudWatchAgentInstaller = Join-Path $CloudWatchAgentScriptDir $CloudWatchAgentUri.Segments[($CloudWatchAgentUri.Segments.Length-1)]; ",
"$Null = New-Item $CloudWatchAgentScriptDir -Type Directory -Force; ",
"Read-S3Object",
" -BucketName $CloudWatchAgentUri.Host",
" -Key ($CloudWatchAgentUri.Segments[1..($CloudWatchAgentUri.Segments.Length-1)] -Join '')",
" -File $CloudWatchAgentZipFile",
" -File $CloudWatchAgentInstaller",
" -Region ",
{
"Ref": "AWS::Region"
},
"; ",
"$CloudWatchAgentInstallScript = \"$CloudWatchAgentScriptDir\"+'\\install.ps1';",
"$CloudWatchAgentConfig = \"$CloudWatchAgentScriptDir\"+'\\aws-cloudwatch-agent-config.json';",
" Expand-Archive -Path $CloudWatchAgentZipFile -DestinationPath $CloudWatchAgentScriptDir;",
"Push-Location -Path $CloudWatchAgentScriptDir;",
"iex $CloudWatchAgentInstallScript;",
".\\amazon-cloudwatch-agent-ctl.ps1 -a fetch-config -m ec2 -c file:$CloudWatchAgentConfig -s;",
"Pop-Location",
"}\""
"$CloudWatchAgentConfig = $CloudWatchAgentScriptDir + '\\aws-cloudwatch-agent-config.json'; ",
"Start-Process msiexec.exe -Wait -ArgumentList \\\"/i $CloudWatchAgentInstaller\\\"; ",
"$CloudWatchAgentCtl = \\\"${Env:ProgramFiles}\\Amazon\\AmazonCloudWatchAgent\\amazon-cloudwatch-agent-ctl.ps1\\\"; ",
"& $CloudWatchAgentCtl -Action cond-restart; ",
"& $CloudWatchAgentCtl -a fetch-config -m ec2 -c file:$CloudWatchAgentConfig -s; ",
"} -Verbose -ErrorAction Stop\""
]
]
},
Expand Down Expand Up @@ -1047,17 +1046,34 @@
"Ref": "ForceUpdateToggle"
},
"\n",
"cfn-init.exe -v -c config ",
" --stack ",
"cfn-init.exe -v -c config --stack ",
{
"Ref": "AWS::StackName"
},
" --resource LaunchConfig ",
" --region ",
" --resource LaunchConfig --region ",
{
"Ref": "AWS::Region"
},
"\n",
"if %ERRORLEVEL% equ 0 goto success",
"\n",
":error",
"\n",
"cfn-signal.exe -e 1 --stack ",
{
"Ref": "AWS::StackName"
},
" --resource LaunchConfig --region ",
{
"Ref": "AWS::Region"
},
"\n",
"echo 'ERROR: cfn-init failed! Aborting!'",
"\n",
"exit /b 1",
"\n",
":success",
"\n",
"</script>\n"
]
]
Expand Down
52 changes: 33 additions & 19 deletions templates/ra_rdsh_autoscale_internal_lb.template.cfn.json
Original file line number Diff line number Diff line change
Expand Up @@ -203,9 +203,9 @@
"Type": "String"
},
"CloudWatchAgentUrl": {
"AllowedPattern": "^$|^s3://.*$",
"AllowedPattern": "^$|^s3://.*\\.msi$",
"Default": "",
"Description": "(Optional) S3 URL to CloudWatch Agent installer. Example: s3://amazoncloudwatch-agent/windows/amd64/latest/AmazonCloudWatchAgent.zip",
"Description": "(Optional) S3 URL to CloudWatch Agent MSI. Example: s3://amazoncloudwatch-agent/windows/amd64/latest/amazon-cloudwatch-agent.msi",
"Type": "String"
},
"ConnectionBrokerFqdn": {
Expand Down Expand Up @@ -771,34 +771,31 @@
"command"
]
},
" \"& { ",
" -Command \"Invoke-Command -ScriptBlock { ",
"$ErrorActionPreference = 'Stop'; ",
"$CloudWatchAgentUri = [System.Uri]'",
{
"Ref": "CloudWatchAgentUrl"
},
"'; ",
"Write-Host '$CloudWatchAgentUri is' $CloudWatchAgentUri ; ",
"Write-Host '$CloudWatchAgentUri.host is' $CloudWatchAgentUri.host ; ",
"$CloudWatchAgentScriptDir = 'c:\\cfn\\scripts\\AmazonCloudWatchAgent'; ",
"$CloudWatchAgentZipFile = Join-Path $CloudWatchAgentScriptDir $CloudWatchAgentUri.Segments[($CloudWatchAgentUri.Segments.Length-1)]; ",
"$CloudWatchAgentInstaller = Join-Path $CloudWatchAgentScriptDir $CloudWatchAgentUri.Segments[($CloudWatchAgentUri.Segments.Length-1)]; ",
"$Null = New-Item $CloudWatchAgentScriptDir -Type Directory -Force; ",
"Read-S3Object",
" -BucketName $CloudWatchAgentUri.Host",
" -Key ($CloudWatchAgentUri.Segments[1..($CloudWatchAgentUri.Segments.Length-1)] -Join '')",
" -File $CloudWatchAgentZipFile",
" -File $CloudWatchAgentInstaller",
" -Region ",
{
"Ref": "AWS::Region"
},
"; ",
"$CloudWatchAgentInstallScript = \"$CloudWatchAgentScriptDir\"+'\\install.ps1';",
"$CloudWatchAgentConfig = \"$CloudWatchAgentScriptDir\"+'\\aws-cloudwatch-agent-config.json';",
" Expand-Archive -Path $CloudWatchAgentZipFile -DestinationPath $CloudWatchAgentScriptDir;",
"Push-Location -Path $CloudWatchAgentScriptDir;",
"iex $CloudWatchAgentInstallScript;",
".\\amazon-cloudwatch-agent-ctl.ps1 -a fetch-config -m ec2 -c file:$CloudWatchAgentConfig -s;",
"Pop-Location",
"}\""
"$CloudWatchAgentConfig = $CloudWatchAgentScriptDir + '\\aws-cloudwatch-agent-config.json'; ",
"Start-Process msiexec.exe -Wait -ArgumentList \\\"/i $CloudWatchAgentInstaller\\\"; ",
"$CloudWatchAgentCtl = \\\"${Env:ProgramFiles}\\Amazon\\AmazonCloudWatchAgent\\amazon-cloudwatch-agent-ctl.ps1\\\"; ",
"& $CloudWatchAgentCtl -Action cond-restart; ",
"& $CloudWatchAgentCtl -a fetch-config -m ec2 -c file:$CloudWatchAgentConfig -s; ",
"} -Verbose -ErrorAction Stop\""
]
]
},
Expand Down Expand Up @@ -1245,17 +1242,34 @@
"Ref": "ForceUpdateToggle"
},
"\n",
"cfn-init.exe -v -c config",
" --stack ",
"cfn-init.exe -v -c config --stack ",
{
"Ref": "AWS::StackName"
},
" --resource LaunchConfig ",
" --region ",
" --resource LaunchConfig --region ",
{
"Ref": "AWS::Region"
},
"\n",
"if %ERRORLEVEL% equ 0 goto success",
"\n",
":error",
"\n",
"cfn-signal.exe -e 1 --stack ",
{
"Ref": "AWS::StackName"
},
" --resource LaunchConfig --region ",
{
"Ref": "AWS::Region"
},
"\n",
"echo 'ERROR: cfn-init failed! Aborting!'",
"\n",
"exit /b 1",
"\n",
":success",
"\n",
"</script>\n"
]
]
Expand Down

0 comments on commit a1c00a0

Please sign in to comment.