Skip to content

Commit a0cde94

Browse files
authored
Merge branch 'main' into java-sample-app-version
2 parents 93179a1 + e205bb0 commit a0cde94

File tree

7 files changed

+56
-48
lines changed

7 files changed

+56
-48
lines changed

.github/workflows/dotnet-ec2-windows-test.yml

Lines changed: 38 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ jobs:
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'

.github/workflows/python-eks-test.yml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,11 @@ jobs:
208208
RDS_MYSQL_CLUSTER_SECRETS, ${{env.RDS_MYSQL_CLUSTER_CREDENTIAL_SECRET_NAME}}
209209
parse-json-secrets: true
210210

211+
- name: Convert RDS database credentials to base64
212+
continue-on-error: true
213+
run: |
214+
echo "RDS_MYSQL_CLUSTER_SECRETS_PASSWORD_BASE64=$(echo -n '${{env.RDS_MYSQL_CLUSTER_SECRETS_PASSWORD}}' | base64)" >> $GITHUB_ENV
215+
211216
- name: Initiate Terraform
212217
uses: ./.github/workflows/actions/execute_and_retry
213218
with:
@@ -246,7 +251,7 @@ jobs:
246251
-var='python_remote_app_image=${{ env.REMOTE_SAMPLE_APP_IMAGE_ARN }}' \
247252
-var='rds_mysql_cluster_endpoint=${{env.RDS_MYSQL_CLUSTER_ENDPOINT}}' \
248253
-var='rds_mysql_cluster_username=${{env.RDS_MYSQL_CLUSTER_SECRETS_USERNAME}}' \
249-
-var='rds_mysql_cluster_password=${{env.RDS_MYSQL_CLUSTER_SECRETS_PASSWORD}}' \
254+
-var='rds_mysql_cluster_password=${{env.RDS_MYSQL_CLUSTER_SECRETS_PASSWORD_BASE64}}' \
250255
-var='rds_mysql_cluster_database=information_schema' \
251256
-var='account_id=${{ env.ACCOUNT_ID }}' \
252257
|| deployment_failed=$?

sample-apps/dotnet/dotnet-ec2-win-main-setup.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ $ProgressPreference = 'SilentlyContinue'
1515

1616
# Install Dotnet
1717
Write-Host "Installing Dotnet" | %{ "{0:HH:mm:ss:fff}: {1}" -f (Get-Date), $_ }
18-
wget -O dotnet-install.ps1 https://dot.net/v1/dotnet-install.ps1
18+
curl.exe -L -o dotnet-install.ps1 https://dot.net/v1/dotnet-install.ps1 --retry 5 --retry-all-errors --retry-delay 5
1919
.\dotnet-install.ps1 -Version 8.0.302
2020

2121
# Install and start Cloudwatch Agent

sample-apps/dotnet/dotnet-ec2-win-remote-setup.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ $ProgressPreference = 'SilentlyContinue'
1313

1414
# Install Dotnet
1515
Write-Host "Installing Dotnet" | %{ "{0:HH:mm:ss:fff}: {1}" -f (Get-Date), $_ }
16-
wget -O dotnet-install.ps1 https://dot.net/v1/dotnet-install.ps1
16+
curl.exe -L -o dotnet-install.ps1 https://dot.net/v1/dotnet-install.ps1 --retry 5 --retry-all-errors --retry-delay 5
1717
.\dotnet-install.ps1 -Version 8.0.302
1818

1919
# Install and start Cloudwatch Agent

sample-apps/python/django_frontend_service/frontend_service_app/views.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
## SPDX-License-Identifier: Apache-2.0
33
import logging
44
import os
5+
import base64
56
import threading
67
import time
78

@@ -110,10 +111,14 @@ def get_xray_trace_id():
110111

111112
def mysql(request):
112113
logger.info("mysql received")
114+
115+
encoded_password = os.environ["RDS_MYSQL_CLUSTER_PASSWORD"]
116+
decoded_password = base64.b64decode(encoded_password).decode('utf-8')
117+
113118
try:
114119
connection = pymysql.connect(host=os.environ["RDS_MYSQL_CLUSTER_ENDPOINT"],
115120
user=os.environ["RDS_MYSQL_CLUSTER_USERNAME"],
116-
password=os.environ["RDS_MYSQL_CLUSTER_PASSWORD"],
121+
password=decoded_password,
117122
database=os.environ["RDS_MYSQL_CLUSTER_DATABASE"])
118123
with connection:
119124
with connection.cursor() as cursor:

terraform/dotnet/ec2/windows/main.tf

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -172,17 +172,6 @@ resource "aws_ssm_document" "main_service_setup" {
172172
DOC
173173
}
174174

175-
# Create SSM Association for main service instance
176-
resource "aws_ssm_association" "main_service_association" {
177-
name = aws_ssm_document.main_service_setup.name
178-
targets {
179-
key = "InstanceIds"
180-
values = [aws_instance.main_service_instance.id]
181-
}
182-
183-
depends_on = [aws_instance.main_service_instance]
184-
}
185-
186175
# Create SSM Document for remote service setup
187176
resource "aws_ssm_document" "remote_service_setup" {
188177
name = "remote_service_setup_${var.test_id}"
@@ -208,14 +197,4 @@ resource "aws_ssm_document" "remote_service_setup" {
208197
]
209198
}
210199
DOC
211-
}
212-
213-
# Create SSM Association for remote service instance
214-
resource "aws_ssm_association" "remote_service_association" {
215-
name = aws_ssm_document.remote_service_setup.name
216-
targets {
217-
key = "InstanceIds"
218-
values = [aws_instance.remote_service_instance.id]
219-
}
220-
depends_on = [aws_instance.remote_service_instance]
221200
}

terraform/dotnet/ec2/windows/output.tf

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,10 @@ output "ec2_instance_ami" {
2929
value = data.aws_ami.ami.id
3030
}
3131

32-
output "frontend_script_association_id" {
33-
value = aws_ssm_association.main_service_association.id
32+
output "frontend_document_name" {
33+
value = aws_ssm_document.main_service_setup.name
3434
}
3535

36-
output "remote_script_association_id" {
37-
value = aws_ssm_association.remote_service_association.id
36+
output "remote_document_name" {
37+
value = aws_ssm_document.remote_service_setup.name
3838
}

0 commit comments

Comments
 (0)