Skip to content

Commit 0428e51

Browse files
committed
Remove Public Endpoint for EC2 Platforms
1 parent 0737925 commit 0428e51

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+281
-531
lines changed

.github/workflows/java-ec2-asg-e2e-test.yml

Lines changed: 11 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -122,60 +122,13 @@ jobs:
122122
-var="sample_remote_app_jar=${{ env.SAMPLE_APP_REMOTE_SERVICE_JAR }}" \
123123
-var="get_cw_agent_rpm_command=${{ env.GET_CW_AGENT_RPM_COMMAND }}" \
124124
-var="get_adot_jar_command=${{ env.GET_ADOT_JAR_COMMAND }}" \
125+
-var="canary_type=${{ github.job }}" \
125126
|| deployment_failed=$?
126127
127128
if [ $deployment_failed -eq 1 ]; then
128129
echo "Terraform deployment was unsuccessful. Will attempt to retry deployment."
129130
fi
130131
131-
# If the deployment_failed is still 0, then the terraform deployment succeeded and now try to connect to the endpoint.
132-
# Attempts to connect will be made for up to 10 minutes
133-
if [ $deployment_failed -eq 0 ]; then
134-
echo "Attempting to connect to the endpoint"
135-
main_service_instance_id=$(aws autoscaling describe-auto-scaling-groups --auto-scaling-group-names ec2-single-asg-${{ env.TESTING_ID }} --region ${{ env.E2E_TEST_AWS_REGION }} --query "AutoScalingGroups[].Instances[0].InstanceId" --output text)
136-
main_service_public_ip=$(aws ec2 describe-instances --instance-ids $main_service_instance_id --region ${{ env.E2E_TEST_AWS_REGION }} --query "Reservations[].Instances[].PublicIpAddress" --output text)
137-
main_service_private_dns_name=$(aws ec2 describe-instances --instance-ids $main_service_instance_id --region ${{ env.E2E_TEST_AWS_REGION }} --query "Reservations[].Instances[].PrivateDnsName" --output text)
138-
139-
echo "INSTANCE_ID=$main_service_instance_id" >> $GITHUB_ENV
140-
echo "MAIN_SERVICE_ENDPOINT=$main_service_public_ip:8080" >> $GITHUB_ENV
141-
echo "PRIVATE_DNS_NAME=$main_service_private_dns_name" >> $GITHUB_ENV
142-
echo "EC2_INSTANCE_AMI=$(terraform output ec2_instance_ami)" >> $GITHUB_ENV
143-
echo "REMOTE_SERVICE_IP=$(terraform output sample_app_remote_service_public_ip)" >> $GITHUB_ENV
144-
145-
main_service_sample_app_endpoint=http://$main_service_public_ip:8080
146-
echo "The main service endpoint is $main_service_sample_app_endpoint"
147-
148-
attempt_counter=0
149-
max_attempts=30
150-
until $(curl --output /dev/null --silent --head --fail $(echo "$main_service_sample_app_endpoint" | tr -d '"')); do
151-
if [ ${attempt_counter} -eq ${max_attempts} ];then
152-
echo "Failed to connect to endpoint. Will attempt to redeploy sample app."
153-
deployment_failed=1
154-
break
155-
fi
156-
157-
printf '.'
158-
attempt_counter=$(($attempt_counter+1))
159-
sleep 10
160-
done
161-
162-
echo "Attempting to connect to the remote sample app endpoint"
163-
remote_sample_app_endpoint=http://$(terraform output sample_app_remote_service_public_ip):8080/healthcheck
164-
attempt_counter=0
165-
max_attempts=30
166-
until $(curl --output /dev/null --silent --head --fail $(echo "$remote_sample_app_endpoint" | tr -d '"')); do
167-
if [ ${attempt_counter} -eq ${max_attempts} ];then
168-
echo "Failed to connect to endpoint. Will attempt to redeploy sample app."
169-
deployment_failed=1
170-
break
171-
fi
172-
173-
printf '.'
174-
attempt_counter=$(($attempt_counter+1))
175-
sleep 10
176-
done
177-
fi
178-
179132
# If the success is 1 then either the terraform deployment or the endpoint connection failed, so first destroy the
180133
# resources created from terraform and try again.
181134
if [ $deployment_failed -eq 1 ]; then
@@ -195,14 +148,16 @@ jobs:
195148
fi
196149
done
197150
198-
# This steps increases the speed of the validation by creating the telemetry data in advance
199-
- name: Call all test APIs
200-
continue-on-error: true
201-
run: |
202-
curl -S -s "http://${{ env.MAIN_SERVICE_ENDPOINT }}/outgoing-http-call"
203-
curl -S -s "http://${{ env.MAIN_SERVICE_ENDPOINT }}/aws-sdk-call?ip=${{ env.REMOTE_SERVICE_IP }}&testingId=${{ env.TESTING_ID }}"
204-
curl -S -s "http://${{ env.MAIN_SERVICE_ENDPOINT }}/remote-service?ip=${{ env.REMOTE_SERVICE_IP }}&testingId=${{ env.TESTING_ID }}"
205-
curl -S -s "http://${{ env.MAIN_SERVICE_ENDPOINT }}/client-call"
151+
- name: Get the sample app and EC2 instance information
152+
working-directory: terraform/java/ec2/asg
153+
run: |
154+
main_service_instance_id=$(aws autoscaling describe-auto-scaling-groups --auto-scaling-group-names ec2-single-asg-${{ env.TESTING_ID }} --region ${{ env.E2E_TEST_AWS_REGION }} --query "AutoScalingGroups[].Instances[0].InstanceId" --output text)
155+
main_service_private_dns_name=$(aws ec2 describe-instances --instance-ids $main_service_instance_id --region ${{ env.E2E_TEST_AWS_REGION }} --query "Reservations[].Instances[].PrivateDnsName" --output text)
156+
echo "INSTANCE_ID=$main_service_instance_id" >> $GITHUB_ENV
157+
echo "MAIN_SERVICE_ENDPOINT=localhost:8080" >> $GITHUB_ENV
158+
echo "PRIVATE_DNS_NAME=$main_service_private_dns_name" >> $GITHUB_ENV
159+
echo "EC2_INSTANCE_AMI=$(terraform output ec2_instance_ami)" >> $GITHUB_ENV
160+
echo "REMOTE_SERVICE_IP=$(terraform output sample_app_remote_service_private_ip)" >> $GITHUB_ENV
206161
207162
- name: Initiate Gradlew Daemon
208163
if: steps.initiate-gradlew == 'failure'

.github/workflows/java-ec2-default-e2e-test.yml

Lines changed: 8 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ env:
3030
LOG_GROUP_NAME: /aws/application-signals/data
3131
TEST_RESOURCES_FOLDER: ${GITHUB_WORKSPACE}
3232

33-
3433
jobs:
3534
java-ec2-default:
3635
runs-on: ubuntu-latest
@@ -99,7 +98,7 @@ jobs:
9998
- name: Initiate Terraform
10099
uses: ./.github/workflows/actions/execute_and_retry
101100
with:
102-
command: "cd ${{ env.TEST_RESOURCES_FOLDER }}/terraform/java/ec2/default && terraform init && terraform validate"
101+
command: "pwd && cd ${{ env.TEST_RESOURCES_FOLDER }}/terraform/java/ec2/default && terraform init && terraform validate"
103102
cleanup: "rm -rf .terraform && rm -rf .terraform.lock.hcl"
104103
max_retry: 6
105104
sleep_time: 60
@@ -123,48 +122,17 @@ jobs:
123122
-var="sample_remote_app_jar=${{ env.SAMPLE_APP_REMOTE_SERVICE_JAR }}" \
124123
-var="get_cw_agent_rpm_command=${{ env.GET_CW_AGENT_RPM_COMMAND }}" \
125124
-var="get_adot_jar_command=${{ env.GET_ADOT_JAR_COMMAND }}" \
125+
-var="canary_type=${{ github.job }}" \
126126
|| deployment_failed=$?
127+
128+
echo $(terraform state show aws_key_pair.aws_ssh_key)
129+
echo $(terraform output -json private_key_content)
130+
127131
128132
if [ $deployment_failed -eq 1 ]; then
129133
echo "Terraform deployment was unsuccessful. Will attempt to retry deployment."
130134
fi
131135
132-
# If the deployment_failed is still 0, then the terraform deployment succeeded and now try to connect to the endpoint.
133-
# Attempts to connect will be made for up to 10 minutes
134-
if [ $deployment_failed -eq 0 ]; then
135-
echo "Attempting to connect to the endpoint"
136-
main_sample_app_endpoint=http://$(terraform output sample_app_main_service_public_dns):8080
137-
attempt_counter=0
138-
max_attempts=30
139-
until $(curl --output /dev/null --silent --head --fail $(echo "$main_sample_app_endpoint" | tr -d '"')); do
140-
if [ ${attempt_counter} -eq ${max_attempts} ];then
141-
echo "Failed to connect to endpoint. Will attempt to redeploy sample app."
142-
deployment_failed=1
143-
break
144-
fi
145-
146-
printf '.'
147-
attempt_counter=$(($attempt_counter+1))
148-
sleep 10
149-
done
150-
151-
echo "Attempting to connect to the remote sample app endpoint"
152-
remote_sample_app_endpoint=http://$(terraform output sample_app_remote_service_public_ip):8080/healthcheck
153-
attempt_counter=0
154-
max_attempts=30
155-
until $(curl --output /dev/null --silent --head --fail $(echo "$remote_sample_app_endpoint" | tr -d '"')); do
156-
if [ ${attempt_counter} -eq ${max_attempts} ];then
157-
echo "Failed to connect to endpoint. Will attempt to redeploy sample app."
158-
deployment_failed=1
159-
break
160-
fi
161-
162-
printf '.'
163-
attempt_counter=$(($attempt_counter+1))
164-
sleep 10
165-
done
166-
fi
167-
168136
# If the success is 1 then either the terraform deployment or the endpoint connection failed, so first destroy the
169137
# resources created from terraform and try again.
170138
if [ $deployment_failed -eq 1 ]; then
@@ -192,19 +160,10 @@ jobs:
192160
- name: Get the sample app and EC2 instance information
193161
working-directory: terraform/java/ec2/default
194162
run: |
195-
echo "MAIN_SERVICE_ENDPOINT=$(terraform output sample_app_main_service_public_dns):8080" >> $GITHUB_ENV
196-
echo "REMOTE_SERVICE_IP=$(terraform output sample_app_remote_service_public_ip)" >> $GITHUB_ENV
163+
echo "MAIN_SERVICE_ENDPOINT=localhost:8080" >> $GITHUB_ENV
164+
echo "REMOTE_SERVICE_IP=$(terraform output sample_app_remote_service_private_ip)" >> $GITHUB_ENV
197165
echo "MAIN_SERVICE_INSTANCE_ID=$(terraform output main_service_instance_id)" >> $GITHUB_ENV
198166
199-
# This steps increases the speed of the validation by creating the telemetry data in advance
200-
- name: Call all test APIs
201-
continue-on-error: true
202-
run: |
203-
curl -S -s "http://${{ env.MAIN_SERVICE_ENDPOINT }}/outgoing-http-call"
204-
curl -S -s "http://${{ env.MAIN_SERVICE_ENDPOINT }}/aws-sdk-call?ip=${{ env.REMOTE_SERVICE_IP }}&testingId=${{ env.TESTING_ID }}"
205-
curl -S -s "http://${{ env.MAIN_SERVICE_ENDPOINT }}/remote-service?ip=${{ env.REMOTE_SERVICE_IP }}&testingId=${{ env.TESTING_ID }}"
206-
curl -S -s "http://${{ env.MAIN_SERVICE_ENDPOINT }}/client-call"
207-
208167
- name: Initiate Gradlew Daemon
209168
if: steps.initiate-gradlew == 'failure'
210169
uses: ./.github/workflows/actions/execute_and_retry

.github/workflows/python-ec2-asg-e2e-test.yml

Lines changed: 10 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -125,59 +125,12 @@ jobs:
125125
-var="sample_app_zip=${{ env.SAMPLE_APP_ZIP }}" \
126126
-var="get_cw_agent_rpm_command=${{ env.GET_CW_AGENT_RPM_COMMAND }}" \
127127
-var="get_adot_wheel_command=${{ env.GET_ADOT_WHEEL_COMMAND }}" \
128+
-var="canary_type=${{ github.job }}" \
128129
|| deployment_failed=$?
129130
130131
if [ $deployment_failed -eq 1 ]; then
131132
echo "Terraform deployment was unsuccessful. Will attempt to retry deployment."
132133
fi
133-
134-
# If the deployment_failed is still 0, then the terraform deployment succeeded and now try to connect to the endpoint.
135-
# Attempts to connect will be made for up to 10 minutes
136-
if [ $deployment_failed -eq 0 ]; then
137-
echo "Attempting to connect to the endpoint"
138-
main_service_instance_id=$(aws autoscaling describe-auto-scaling-groups --auto-scaling-group-names python-ec2-single-asg-${{ env.TESTING_ID }} --region ${{ env.E2E_TEST_AWS_REGION }} --query "AutoScalingGroups[].Instances[0].InstanceId" --output text)
139-
main_service_public_ip=$(aws ec2 describe-instances --instance-ids $main_service_instance_id --region ${{ env.E2E_TEST_AWS_REGION }} --query "Reservations[].Instances[].PublicIpAddress" --output text)
140-
main_service_private_dns_name=$(aws ec2 describe-instances --instance-ids $main_service_instance_id --region ${{ env.E2E_TEST_AWS_REGION }} --query "Reservations[].Instances[].PrivateDnsName" --output text)
141-
142-
echo "INSTANCE_ID=$main_service_instance_id" >> $GITHUB_ENV
143-
echo "MAIN_SERVICE_ENDPOINT=$main_service_public_ip:8000" >> $GITHUB_ENV
144-
echo "PRIVATE_DNS_NAME=$main_service_private_dns_name" >> $GITHUB_ENV
145-
echo "EC2_INSTANCE_AMI=$(terraform output ec2_instance_ami)" >> $GITHUB_ENV
146-
echo "REMOTE_SERVICE_IP=$(terraform output sample_app_remote_service_public_ip)" >> $GITHUB_ENV
147-
148-
main_service_sample_app_endpoint=http://$main_service_public_ip:8000
149-
echo "The main service endpoint is $main_service_sample_app_endpoint"
150-
151-
attempt_counter=0
152-
max_attempts=30
153-
until $(curl --output /dev/null --silent --head --fail $(echo "$main_service_sample_app_endpoint" | tr -d '"')); do
154-
if [ ${attempt_counter} -eq ${max_attempts} ];then
155-
echo "Failed to connect to endpoint. Will attempt to redeploy sample app."
156-
deployment_failed=1
157-
break
158-
fi
159-
160-
printf '.'
161-
attempt_counter=$(($attempt_counter+1))
162-
sleep 10
163-
done
164-
165-
echo "Attempting to connect to the remote sample app endpoint"
166-
remote_sample_app_endpoint=http://$(terraform output sample_app_remote_service_public_ip):8001/healthcheck
167-
attempt_counter=0
168-
max_attempts=30
169-
until $(curl --output /dev/null --silent --head --fail $(echo "$remote_sample_app_endpoint" | tr -d '"')); do
170-
if [ ${attempt_counter} -eq ${max_attempts} ];then
171-
echo "Failed to connect to endpoint. Will attempt to redeploy sample app."
172-
deployment_failed=1
173-
break
174-
fi
175-
176-
printf '.'
177-
attempt_counter=$(($attempt_counter+1))
178-
sleep 10
179-
done
180-
fi
181134
182135
# If the success is 1 then either the terraform deployment or the endpoint connection failed, so first destroy the
183136
# resources created from terraform and try again.
@@ -198,14 +151,16 @@ jobs:
198151
fi
199152
done
200153
201-
# This steps increases the speed of the validation by creating the telemetry data in advance
202-
- name: Call all test APIs
203-
continue-on-error: true
154+
- name: Get the sample app and EC2 instance information
155+
working-directory: terraform/python/ec2/asg
204156
run: |
205-
curl -S -s "http://${{ env.MAIN_SERVICE_ENDPOINT }}/outgoing-http-call"; echo
206-
curl -S -s "http://${{ env.MAIN_SERVICE_ENDPOINT }}/aws-sdk-call?ip=${{ env.REMOTE_SERVICE_IP }}&testingId=${{ env.TESTING_ID }}"; echo
207-
curl -S -s "http://${{ env.MAIN_SERVICE_ENDPOINT }}/remote-service?ip=${{ env.REMOTE_SERVICE_IP }}&testingId=${{ env.TESTING_ID }}"; echo
208-
curl -S -s "http://${{ env.MAIN_SERVICE_ENDPOINT }}/client-call"; echo
157+
main_service_instance_id=$(aws autoscaling describe-auto-scaling-groups --auto-scaling-group-names python-ec2-single-asg-${{ env.TESTING_ID }} --region ${{ env.E2E_TEST_AWS_REGION }} --query "AutoScalingGroups[].Instances[0].InstanceId" --output text)
158+
main_service_private_dns_name=$(aws ec2 describe-instances --instance-ids $main_service_instance_id --region ${{ env.E2E_TEST_AWS_REGION }} --query "Reservations[].Instances[].PrivateDnsName" --output text)
159+
echo "INSTANCE_ID=$main_service_instance_id" >> $GITHUB_ENV
160+
echo "MAIN_SERVICE_ENDPOINT=localhost:8000" >> $GITHUB_ENV
161+
echo "PRIVATE_DNS_NAME=$main_service_private_dns_name" >> $GITHUB_ENV
162+
echo "EC2_INSTANCE_AMI=$(terraform output ec2_instance_ami)" >> $GITHUB_ENV
163+
echo "REMOTE_SERVICE_IP=$(terraform output sample_app_remote_service_private_ip)" >> $GITHUB_ENV
209164
210165
- name: Initiate Gradlew Daemon
211166
if: steps.initiate-gradlew == 'failure'

.github/workflows/python-ec2-default-e2e-test.yml

Lines changed: 3 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -124,48 +124,13 @@ jobs:
124124
-var="sample_app_zip=${{ env.SAMPLE_APP_ZIP }}" \
125125
-var="get_cw_agent_rpm_command=${{ env.GET_CW_AGENT_RPM_COMMAND }}" \
126126
-var="get_adot_wheel_command=${{ env.GET_ADOT_WHEEL_COMMAND }}" \
127+
-var="canary_type=${{ github.job }}" \
127128
|| deployment_failed=$?
128129
129130
if [ $deployment_failed -eq 1 ]; then
130131
echo "Terraform deployment was unsuccessful. Will attempt to retry deployment."
131132
fi
132133
133-
# If the deployment_failed is still 0, then the terraform deployment succeeded and now try to connect to the endpoint.
134-
# Attempts to connect will be made for up to 10 minutes
135-
if [ $deployment_failed -eq 0 ]; then
136-
echo "Attempting to connect to the endpoint"
137-
sample_app_endpoint=http://$(terraform output sample_app_main_service_public_dns):8000
138-
attempt_counter=0
139-
max_attempts=60
140-
until $(curl --output /dev/null --silent --head --fail $(echo "$sample_app_endpoint" | tr -d '"')); do
141-
if [ ${attempt_counter} -eq ${max_attempts} ];then
142-
echo "Failed to connect to endpoint. Will attempt to redeploy sample app."
143-
deployment_failed=1
144-
break
145-
fi
146-
147-
printf '.'
148-
attempt_counter=$(($attempt_counter+1))
149-
sleep 10
150-
done
151-
152-
echo "Attempting to connect to the remote sample app endpoint"
153-
remote_sample_app_endpoint=http://$(terraform output sample_app_remote_service_public_ip):8001/healthcheck
154-
attempt_counter=0
155-
max_attempts=30
156-
until $(curl --output /dev/null --silent --head --fail $(echo "$remote_sample_app_endpoint" | tr -d '"')); do
157-
if [ ${attempt_counter} -eq ${max_attempts} ];then
158-
echo "Failed to connect to endpoint. Will attempt to redeploy sample app."
159-
deployment_failed=1
160-
break
161-
fi
162-
163-
printf '.'
164-
attempt_counter=$(($attempt_counter+1))
165-
sleep 10
166-
done
167-
fi
168-
169134
# If the success is 1 then either the terraform deployment or the endpoint connection failed, so first destroy the
170135
# resources created from terraform and try again.
171136
if [ $deployment_failed -eq 1 ]; then
@@ -192,20 +157,11 @@ jobs:
192157

193158
- name: Get the sample app endpoint
194159
run: |
195-
echo "MAIN_SERVICE_ENDPOINT=$(terraform output sample_app_main_service_public_dns):8000" >> $GITHUB_ENV
196-
echo "REMOTE_SERVICE_IP=$(terraform output sample_app_remote_service_public_ip)" >> $GITHUB_ENV
160+
echo "MAIN_SERVICE_ENDPOINT=localhost:8000" >> $GITHUB_ENV
161+
echo "REMOTE_SERVICE_IP=$(terraform output sample_app_remote_service_private_ip)" >> $GITHUB_ENV
197162
echo "MAIN_SERVICE_INSTANCE_ID=$(terraform output main_service_instance_id)" >> $GITHUB_ENV
198163
working-directory: terraform/python/ec2/default
199164

200-
# This steps increases the speed of the validation by creating the telemetry data in advance
201-
- name: Call all test APIs
202-
continue-on-error: true
203-
run: |
204-
curl -S -s "http://${{ env.MAIN_SERVICE_ENDPOINT }}/outgoing-http-call"; echo
205-
curl -S -s "http://${{ env.MAIN_SERVICE_ENDPOINT }}/aws-sdk-call?ip=${{ env.REMOTE_SERVICE_IP }}&testingId=${{ env.TESTING_ID }}"; echo
206-
curl -S -s "http://${{ env.MAIN_SERVICE_ENDPOINT }}/remote-service?ip=${{ env.REMOTE_SERVICE_IP }}&testingId=${{ env.TESTING_ID }}"; echo
207-
curl -S -s "http://${{ env.MAIN_SERVICE_ENDPOINT }}/client-call"; echo
208-
209165
- name: Initiate Gradlew Daemon
210166
if: steps.initiate-gradlew == 'failure'
211167
uses: ./.github/workflows/actions/execute_and_retry

0 commit comments

Comments
 (0)