9494 echo GET_ADOT_DISTRO_COMMAND="aws s3 cp s3://adot-autoinstrumentation-dotnet-staging/${{ env.ADOT_DISTRO_NAME }} ./${{ env.ADOT_DISTRO_NAME }}; Expand-Archive -Path /${{ env.ADOT_DISTRO_NAME }} -DestinationPath ./dotnet-distro" >> $GITHUB_ENV
9595 else
9696 # After Release will switch to latest tag instead of hard code version for canary purpose
97- echo GET_ADOT_DISTRO_COMMAND="wget -O ./aws-distro-opentelemetry-dotnet-instrumentation-windows.zip https://github.com/aws-observability/aws-otel-dotnet-instrumentation/releases/latest/download/aws-distro-opentelemetry-dotnet-instrumentation-windows.zip; Expand-Archive -Path ./aws-distro-opentelemetry-dotnet-instrumentation-windows.zip -DestinationPath ./dotnet-distro -Force" >> $GITHUB_ENV
97+ echo GET_ADOT_DISTRO_COMMAND="curl.exe -L -o ./aws-distro-opentelemetry-dotnet-instrumentation-windows.zip https://github.com/aws-observability/aws-otel-dotnet-instrumentation/releases/latest/download/aws-distro-opentelemetry-dotnet-instrumentation-windows.zip --retry 5 --retry-all-errors --retry-delay 5 ; Expand-Archive -Path ./aws-distro-opentelemetry-dotnet-instrumentation-windows.zip -DestinationPath ./dotnet-distro -Force" >> $GITHUB_ENV
9898 fi
9999
100100 - name : Set Get CW Agent command environment variable
@@ -103,7 +103,7 @@ jobs:
103103 # Get cloudwatch agent staging file if triggered by cw-a repo
104104 echo GET_CW_AGENT_MSI_COMMAND= "aws s3 cp s3://${{ secrets.S3_INTEGRATION_BUCKET }}/integration-test/binary/${{ github.sha }}/amazon-cloudwatch-agent.msi ./cw-agent.msi" >> $GITHUB_ENV
105105 else
106- echo GET_CW_AGENT_MSI_COMMAND= "wget -O ./amazon-cloudwatch-agent.msi https://amazoncloudwatch-agent.s3.amazonaws.com/windows/amd64/latest/amazon-cloudwatch-agent.msi" >> $GITHUB_ENV
106+ echo GET_CW_AGENT_MSI_COMMAND= "curl.exe -L -o ./amazon-cloudwatch-agent.msi https://amazoncloudwatch-agent.s3.amazonaws.com/windows/amd64/latest/amazon-cloudwatch-agent.msi --retry 5 --retry-all-errors --retry-delay 5 " >> $GITHUB_ENV
107107 fi
108108
109109 - name : Set up terraform
@@ -173,8 +173,8 @@ jobs:
173173 - name : Get SSM outputs
174174 working-directory : terraform/dotnet/ec2/windows
175175 run : |
176- echo "FRONTEND_SSM_ASSOCIATION_ID =$(terraform output frontend_script_association_id )" >> $GITHUB_ENV
177- echo "REMOTE_SSM_ASSOCIATION__ID =$(terraform output remote_script_association_id )" >> $GITHUB_ENV
176+ echo "FRONTEND_DOCUMENT_NAME =$(terraform output frontend_document_name )" >> $GITHUB_ENV
177+ echo "REMOTE_DOCUMENT_NAME =$(terraform output remote_document_name )" >> $GITHUB_ENV
178178
179179 - name : Get the sample app endpoint
180180 working-directory : terraform/dotnet/ec2/windows
@@ -220,35 +220,54 @@ jobs:
220220 check_instance_ready ${{ env.MAIN_SERVICE_INSTANCE_ID }}
221221 check_instance_ready ${{ env.REMOTE_SERVICE_INSTANCE_ID }}
222222
223- # Allow up to 10 min for SSM Document to run
224- max_attempts=60
225- attempt=0
226-
227- check_status() {
228- local association_id=$1
223+ main_command_id=$(aws ssm send-command \
224+ --instance-ids "${{ env.MAIN_SERVICE_INSTANCE_ID }}" \
225+ --document-name "${{ env.FRONTEND_DOCUMENT_NAME }}" \
226+ --query "Command.CommandId" \
227+ --output text)
228+
229+ remote_command_id=$(aws ssm send-command \
230+ --instance-ids "${{ env.REMOTE_SERVICE_INSTANCE_ID }}" \
231+ --document-name "${{ env.REMOTE_DOCUMENT_NAME }}" \
232+ --query "Command.CommandId" \
233+ --output text)
234+
235+ watch_command() {
236+ local command_id=$1
237+ local max_attempts=20 # 10 minutes timeout with 30 seconds interval
238+ local attempt=0
239+ local interval=30
229240
230241 while [[ $attempt -lt $max_attempts ]]; do
231- aws ssm describe-association --association-id $association_id
232- local status=$(aws ssm describe-association --association-id $association_id --query "AssociationDescription.Overview.AssociationStatusAggregatedCount.Success" --output text)
233- echo "Attempt $((attempt + 1))/$max_attempts: Current status of SSM Association $association_id: $status"
234- if [[ "$status" == "1" ]]; then
235- echo "SSM Association $association_id succeeded."
242+ status=$(aws ssm list-command-invocations \
243+ --command-id "$command_id" \
244+ --details \
245+ --query "CommandInvocations[0].Status" \
246+ --output text)
247+
248+ echo "Attempt $((attempt + 1))/$max_attempts: Current status of command $command_id: $status"
249+
250+ if [[ "$status" == "Success" || "$status" == "Failed" ]]; then
251+ echo "SSM Command $command_id completed with status: $status"
252+ if [[ "$status" == "Failed" ]]; then
253+ exit 1
254+ fi
236255 break
237256 else
238- echo "Waiting for SSM Association $association_id to succeed ..."
257+ echo "Waiting for SSM Command $command_id to complete ..."
239258 sleep $interval
240259 attempt=$((attempt + 1))
241260 fi
242261 done
243262
244263 if [[ $attempt -ge $max_attempts ]]; then
245- echo "Max attempts reached: SSM Association $association_id did not succeed after $max_attempts attempts ."
264+ echo "Timeout reached: SSM Command $command_id did not complete within 10 minutes ."
246265 exit 1
247266 fi
248267 }
249268
250- check_status ${{ env.FRONTEND_SSM_ASSOCIATION_ID }}
251- check_status ${{ env.REMOTE_SSM_ASSOCIATION__ID }}
269+ watch_command $main_command_id
270+ watch_command $remote_command_id
252271
253272 - name : Initiate Gradlew Daemon
254273 if : steps.initiate-gradlew == 'failure'
0 commit comments