user-data.ps1 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. <powershell>
  2. $ErrorActionPreference = "Continue"
  3. $VerbosePreference = "Continue"
  4. Start-Transcript -Path "C:\UserData.log" -Append
  5. ${pre_install}
  6. # Install Chocolatey
  7. [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.SecurityProtocolType]::Tls12
  8. $env:chocolateyUseWindowsCompression = 'true'
  9. Invoke-WebRequest https://chocolatey.org/install.ps1 -UseBasicParsing | Invoke-Expression
  10. # Add Chocolatey to powershell profile
  11. $ChocoProfileValue = @'
  12. $ChocolateyProfile = "$env:ChocolateyInstall\helpers\chocolateyProfile.psm1"
  13. if (Test-Path($ChocolateyProfile)) {
  14. Import-Module "$ChocolateyProfile"
  15. }
  16. refreshenv
  17. '@
  18. # Write it to the $profile location
  19. Set-Content -Path "$PsHome\Microsoft.PowerShell_profile.ps1" -Value $ChocoProfileValue -Force
  20. # Source it
  21. . "$PsHome\Microsoft.PowerShell_profile.ps1"
  22. refreshenv
  23. Write-Host "Installing cloudwatch agent..."
  24. Invoke-WebRequest -Uri https://s3.amazonaws.com/amazoncloudwatch-agent/windows/amd64/latest/amazon-cloudwatch-agent.msi -OutFile C:\amazon-cloudwatch-agent.msi
  25. $cloudwatchParams = '/i', 'C:\amazon-cloudwatch-agent.msi', '/qn', '/L*v', 'C:\CloudwatchInstall.log'
  26. Start-Process "msiexec.exe" $cloudwatchParams -Wait -NoNewWindow
  27. Remove-Item C:\amazon-cloudwatch-agent.msi
  28. # Install dependent tools
  29. Write-Host "Installing additional development tools"
  30. choco install git awscli -y
  31. refreshenv
  32. ${install_runner}
  33. ${post_install}
  34. ${start_runner}
  35. Stop-Transcript
  36. </powershell>