Skip to content
Merged
4 changes: 2 additions & 2 deletions .github/workflows/dotnet-ec2-windows-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -185,10 +185,10 @@ jobs:
echo "REMOTE_SERVICE_INSTANCE_ID=$(terraform output remote_service_instance_id)" >> $GITHUB_ENV
# A standard Windows Deployment Script are Expect to run ~5min, plus waiting for SSM to be setup in EC2 instance ~2min
# 12 Min loose upper timeout bound is designed to allow for a rate situation: in a very small chance,
# 15 Min loose upper timeout bound is designed to allow for a rate situation: in a very small chance,
# It's possible for SSM document to take up to 8min to run and still produce expect setup outcome
- name: Monitor EC2 instances readiness and SSM execute status in Systems Manager
timeout-minutes: 12
timeout-minutes: 15
run: |
# Allow up to 5 min for EC2 instance connect to SSM
max_attempts=30
Expand Down
26 changes: 14 additions & 12 deletions sample-apps/dotnet/dotnet-ec2-win-main-setup.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,14 @@ param (
$ProgressPreference = 'SilentlyContinue'

# Install Dotnet
Write-Host "Installing Dotnet" | %{ "{0:HH:mm:ss:fff}: {1}" -f (Get-Date), $_ }
wget -O dotnet-install.ps1 https://dot.net/v1/dotnet-install.ps1
.\dotnet-install.ps1 -Version 8.0.302

# Install and start Cloudwatch Agent
Invoke-Expression $GetCloudwatchAgentCommand
Invoke-Expression $GetCloudwatchAgentCommand | %{ "{0:HH:mm:ss:fff}: {1}" -f (Get-Date), $_ }

Write-Host "Installing Cloudwatch Agent"
Write-Host "Installing Cloudwatch Agent" | %{ "{0:HH:mm:ss:fff}: {1}" -f (Get-Date), $_ }
msiexec /i amazon-cloudwatch-agent.msi
$timeout = 30
$interval = 5
Expand All @@ -33,6 +34,7 @@ while ($elapsedTime -lt $timeout) {
Write-Host "Install Finished"
break
} else {
$call_cloudwatch = & "C:\Program Files\Amazon\AmazonCloudWatchAgent\amazon-cloudwatch-agent-ctl.ps1"
Write-Host "Cloudwatch Agent not found: $filePath. Checking again in $interval seconds..."
Start-Sleep -Seconds $interval
$elapsedTime += $interval
Expand All @@ -43,7 +45,7 @@ if ($elapsedTime -ge $timeout) {
Write-Host "CloudWatch not found after $timeout seconds."
}

Write-Host "Install Finished"
Write-Host "Install Finished" | %{ "{0:HH:mm:ss:fff}: {1}" -f (Get-Date), $_ }

# Even after this step, it only expose 8080 to localhost and local (EC2) network on current config, so it's safe
# Leave it here for Debug purpose
Expand All @@ -52,11 +54,11 @@ New-NetFirewallRule -DisplayName "Allow TCP 8080" -Direction Inbound -Protocol T
& "C:\Program Files\Amazon\AmazonCloudWatchAgent\amazon-cloudwatch-agent-ctl.ps1" -a fetch-config -m ec2 -s -c file:./amazon-cloudwatch-agent.json

# Get Instrumentation Artifacts and Sample App
Invoke-Expression $GetAdotDistroCommand
Invoke-Expression $GetAdotDistroCommand | %{ "{0:HH:mm:ss:fff}: {1}" -f (Get-Date), $_ }

Invoke-Expression $GetSampleAppCommand
Invoke-Expression $GetSampleAppCommand | %{ "{0:HH:mm:ss:fff}: {1}" -f (Get-Date), $_ }

Expand-Archive -Path .\dotnet-sample-app.zip -DestinationPath .\ -Force
Expand-Archive -Path .\dotnet-sample-app.zip -DestinationPath .\ -Force | %{ "{0:HH:mm:ss:fff}: {1}" -f (Get-Date), $_ }

# Config Env variable for Windows EC2

Expand All @@ -82,7 +84,7 @@ $env:OTEL_TRACES_SAMPLER = "always_on"
$env:ASPNETCORE_URLS = "http://0.0.0.0:8080"


dotnet build
dotnet build | %{ "{0:HH:mm:ss:fff}: {1}" -f (Get-Date), $_ }


Start-Process -FilePath "dotnet" -ArgumentList "bin/Debug/netcoreapp8.0/asp_frontend_service.dll"
Expand All @@ -93,18 +95,18 @@ Start-Sleep -Seconds 10
# Deploy Traffic Generator

# Install node and setup path for node
wget -O nodejs.zip https://nodejs.org/dist/v20.16.0/node-v20.16.0-win-x64.zip
Expand-Archive -Path .\nodejs.zip -DestinationPath .\nodejs -Force
wget -O nodejs.zip https://nodejs.org/dist/v20.16.0/node-v20.16.0-win-x64.zip | %{ "{0:HH:mm:ss:fff}: {1}" -f (Get-Date), $_ }
Expand-Archive -Path .\nodejs.zip -DestinationPath .\nodejs -Force | %{ "{0:HH:mm:ss:fff}: {1}" -f (Get-Date), $_ }
$currentdir = Get-Location
Write-Host $currentdir
Write-Host $currentdir | %{ "{0:HH:mm:ss:fff}: {1}" -f (Get-Date), $_ }
$env:Path += ";$currentdir" + "\nodejs\node-v20.16.0-win-x64"

# Bring in the traffic generator files to EC2 Instance
aws s3 cp "s3://aws-appsignals-sample-app-prod-$AWSRegion/traffic-generator.zip" "./traffic-generator.zip"
Expand-Archive -Path "./traffic-generator.zip" -DestinationPath "./" -Force
Expand-Archive -Path "./traffic-generator.zip" -DestinationPath "./" -Force | %{ "{0:HH:mm:ss:fff}: {1}" -f (Get-Date), $_ }

# Install the traffic generator dependencies
npm install
npm install | %{ "{0:HH:mm:ss:fff}: {1}" -f (Get-Date), $_ }

# Start traffic generator
$env:MAIN_ENDPOINT = "localhost:8080"
Expand Down
16 changes: 9 additions & 7 deletions sample-apps/dotnet/dotnet-ec2-win-remote-setup.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,14 @@ param (
$ProgressPreference = 'SilentlyContinue'

# Install Dotnet
Write-Host "Installing Dotnet" | %{ "{0:HH:mm:ss:fff}: {1}" -f (Get-Date), $_ }
wget -O dotnet-install.ps1 https://dot.net/v1/dotnet-install.ps1
.\dotnet-install.ps1 -Version 8.0.302

# Install and start Cloudwatch Agent
Invoke-Expression $GetCloudwatchAgentCommand
Invoke-Expression $GetCloudwatchAgentCommand | %{ "{0:HH:mm:ss:fff}: {1}" -f (Get-Date), $_ }

Write-Host "Installing Cloudwatch Agent"
Write-Host "Installing Cloudwatch Agent" | %{ "{0:HH:mm:ss:fff}: {1}" -f (Get-Date), $_ }
msiexec /i amazon-cloudwatch-agent.msi
$timeout = 30
$interval = 5
Expand All @@ -31,6 +32,7 @@ while ($elapsedTime -lt $timeout) {
Write-Host "Install Finished"
break
} else {
$call_cloudwatch = & "C:\Program Files\Amazon\AmazonCloudWatchAgent\amazon-cloudwatch-agent-ctl.ps1"
Write-Host "Cloudwatch Agent not found: $filePath. Checking again in $interval seconds..."
Start-Sleep -Seconds $interval
$elapsedTime += $interval
Expand All @@ -44,14 +46,14 @@ if ($elapsedTime -ge $timeout) {
& "C:\Program Files\Amazon\AmazonCloudWatchAgent\amazon-cloudwatch-agent-ctl.ps1" -a fetch-config -m ec2 -s -c file:./amazon-cloudwatch-agent.json

# Get Instrumentation Artifacts and Sample App
Invoke-Expression $GetAdotDistroCommand
Invoke-Expression $GetAdotDistroCommand | %{ "{0:HH:mm:ss:fff}: {1}" -f (Get-Date), $_ }

Invoke-Expression $GetSampleAppCommand
Invoke-Expression $GetSampleAppCommand | %{ "{0:HH:mm:ss:fff}: {1}" -f (Get-Date), $_ }

Expand-Archive -Path .\dotnet-sample-app.zip -DestinationPath .\ -Force
Expand-Archive -Path .\dotnet-sample-app.zip -DestinationPath .\ -Force | %{ "{0:HH:mm:ss:fff}: {1}" -f (Get-Date), $_ }

# Allow income traffic from main-service
New-NetFirewallRule -DisplayName "Allow TCP 8081" -Direction Inbound -Protocol TCP -LocalPort 8081 -Action Allow
New-NetFirewallRule -DisplayName "Allow TCP 8081" -Direction Inbound -Protocol TCP -LocalPort 8081 -Action Allow | %{ "{0:HH:mm:ss:fff}: {1}" -f (Get-Date), $_ }

$current_dir = Get-Location
Write-Host $current_dir
Expand All @@ -76,7 +78,7 @@ $env:OTEL_TRACES_SAMPLER = "always_on"
$env:ASPNETCORE_URLS = "http://0.0.0.0:8081"


dotnet build
dotnet build | %{ "{0:HH:mm:ss:fff}: {1}" -f (Get-Date), $_ }


Start-Process -FilePath "dotnet" -ArgumentList "bin/Debug/netcoreapp8.0/asp_remote_service.dll"
Expand Down