Skip to content

Commit bdf1566

Browse files
committed
Merge remote-tracking branch 'origin' into retry-remote-application-and-addon
2 parents 97ac117 + 7dee03a commit bdf1566

File tree

37 files changed

+677
-13
lines changed

37 files changed

+677
-13
lines changed

.github/workflows/appsignals-e2e-ec2-test.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -158,10 +158,10 @@ jobs:
158158
- name: Call all test APIs
159159
continue-on-error: true
160160
run: |
161-
curl -S -o /dev/null http://${{ env.MAIN_SERVICE_ENDPOINT }}/outgoing-http-call/
162-
curl -S -o /dev/null http://${{ env.MAIN_SERVICE_ENDPOINT }}/aws-sdk-call/
163-
curl -S -o /dev/null http://${{ env.MAIN_SERVICE_ENDPOINT }}/remote-service?ip=${{ env.REMOTE_SERVICE_IP }}/
164-
curl -S -o /dev/null http://${{ env.MAIN_SERVICE_ENDPOINT }}/client-call/
161+
curl -S -s http://${{ env.MAIN_SERVICE_ENDPOINT }}/outgoing-http-call/
162+
curl -S -s http://${{ env.MAIN_SERVICE_ENDPOINT }}/aws-sdk-call/
163+
curl -S -s http://${{ env.MAIN_SERVICE_ENDPOINT }}/remote-service?ip=${{ env.REMOTE_SERVICE_IP }}/
164+
curl -S -s http://${{ env.MAIN_SERVICE_ENDPOINT }}/client-call/
165165
166166
- name: Build Gradlew
167167
run: |

.github/workflows/appsignals-e2e-eks-test.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -261,10 +261,10 @@ jobs:
261261
- name: Call all test APIs
262262
continue-on-error: true
263263
run: |
264-
curl -S -o /dev/null http://${{ env.APP_ENDPOINT }}/outgoing-http-call/
265-
curl -S -o /dev/null http://${{ env.APP_ENDPOINT }}/aws-sdk-call/
266-
curl -S -o /dev/null http://${{ env.APP_ENDPOINT }}/remote-service?ip=${{ env.REMOTE_SERVICE_POD_IP }}/
267-
curl -S -o /dev/null http://${{ env.APP_ENDPOINT }}/client-call/
264+
curl -S -s http://${{ env.APP_ENDPOINT }}/outgoing-http-call/
265+
curl -S -s http://${{ env.APP_ENDPOINT }}/aws-sdk-call/
266+
curl -S -s http://${{ env.APP_ENDPOINT }}/remote-service?ip=${{ env.REMOTE_SERVICE_POD_IP }}/
267+
curl -S -s http://${{ env.APP_ENDPOINT }}/client-call/
268268
269269
- name: Build Gradlew
270270
run: |
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
## Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2+
## SPDX-License-Identifier: Apache-2.0
3+
4+
name: App Signals Enablement - S3 Django Sample App Deployment
5+
on:
6+
workflow_dispatch: # be able to run the workflow on demand
7+
8+
permissions:
9+
id-token: write
10+
contents: read
11+
12+
jobs:
13+
upload-sample-app-zip:
14+
strategy:
15+
fail-fast: false
16+
matrix:
17+
aws-region: [ 'af-south-1','ap-east-1','ap-northeast-1','ap-northeast-2','ap-northeast-3','ap-south-1','ap-south-2','ap-southeast-1',
18+
'ap-southeast-2','ap-southeast-3','ap-southeast-4','ca-central-1','eu-central-1','eu-central-2','eu-north-1',
19+
'eu-south-1','eu-south-2','eu-west-1','eu-west-2','eu-west-3','il-central-1','me-central-1','me-south-1', 'sa-east-1',
20+
'us-east-1','us-east-2', 'us-west-1', 'us-west-2' ]
21+
runs-on: ubuntu-latest
22+
steps:
23+
- uses: actions/checkout@v4
24+
with:
25+
fetch-depth: 0
26+
27+
- name: Configure AWS Credentials
28+
uses: aws-actions/configure-aws-credentials@v4
29+
with:
30+
role-to-assume: ${{ secrets.E2E_SECRET_TEST_ROLE_ARN }}
31+
aws-region: us-east-1
32+
33+
- name: Retrieve account
34+
uses: aws-actions/aws-secretsmanager-get-secrets@v1
35+
with:
36+
secret-ids:
37+
ACCOUNT_ID, region-account/${{ matrix.aws-region }}
38+
39+
- name: Configure AWS Credentials
40+
uses: aws-actions/configure-aws-credentials@v4
41+
with:
42+
role-to-assume: arn:aws:iam::${{ env.ACCOUNT_ID }}:role/${{ secrets.E2E_TEST_ROLE_ARN }}
43+
aws-region: ${{ matrix.aws-region }}
44+
45+
46+
47+
- name: Build Sample App Zip
48+
working-directory: sample-apps/python
49+
run: zip -r python-sample-app.zip .
50+
51+
- name: Upload to S3
52+
working-directory: sample-apps/python
53+
run: aws s3api put-object --bucket ${{ secrets.APP_SIGNALS_E2E_EC2_JAR }}-prod-${{ matrix.aws-region }} --body ./python-sample-app.zip --key python-sample-app.zip
54+

.github/workflows/util/execute_and_retry.sh

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,18 @@
33
# This function is for retrying commands in the case they fail. It accepts three arguments
44
# $1: Number of retries it will attempt
55
# $2: Command to execute
6-
# $3: Clean up commands
6+
# $3: (Optional) Command for cleaning up resources if $2 fails
77
execute_and_retry () {
88
retry_counter=0
99
max_retry=$1
10+
command=$2
11+
cleanup=$3
1012
while [ $retry_counter -lt $max_retry ]; do
1113
attempt_failed=0
12-
eval "$2" || attempt_failed=$?
14+
eval "$command" || attempt_failed=$?
1315

1416
if [ $attempt_failed -ne 0 ]; then
15-
eval "$3"
17+
eval "$cleanup"
1618
retry_counter=$(($retry_counter+1))
1719
sleep 5
1820
else

sample-apps/python/README.md

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# Python Demo Sample App Updating Guide
2+
3+
## Introduction:
4+
5+
The python sample app is used to perform E2E testing on cloudwatch, cloudwatch operator and adot repository. If any changes need to be made on the demo sample app, the following steps should be taken.
6+
7+
## EKS Use Case: Uploading to ECR
8+
9+
### Build the sample app locally:
10+
run `docker-compose build` to generate two docker images: `pythonsampleapp/frontend-service` and `pythonsampleapp/remote-service`
11+
12+
### Steps to update image:
13+
1. Login to the testing account
14+
2. Create a new ECR repository if there's no existing one.
15+
3. Login to ECR Repository: `aws ecr get-login-password --region us-east-1 | docker login --username AWS --password-stdin {REPOSITORY}`.
16+
4. tag images and push to repository:
17+
```
18+
docker tag pythonsampleapp/frontend-service:latest ${REPOSITORY_PREFIX}/pythonsampleapp/frontend-service:latest
19+
docker push ${REPOSITORY_PREFIX}/pythonsampleapp/frontend-service:latest
20+
docker tag pythonsampleapp/remote-service:latest ${REPOSITORY_PREFIX}/pythonsampleapp/remote-service:latest
21+
docker push ${REPOSITORY_PREFIX}/pythonsampleapp/remote-service:latest
22+
```
23+
24+
25+
## EC2 Use Case: Building the JAR Files:
26+
1. Compress the folder with: `zip -r python-sample-app.zip .`
27+
2. Login to the testing account
28+
3. Create a new S3 bucket if there's no existing one.
29+
4. upload `python-sample-app.zip` to the bucket
30+
31+
32+
## APIs
33+
The following are the APIs supported:
34+
1. http://${ FRONTEND_SERVICE_IP }:8000/outgoing-http-call/
35+
2. http://${ FRONTEND_SERVICE_IP }:8000/aws-sdk-call/
36+
3. http://${ FRONTEND_SERVICE_IP }:8000/remote-service?ip=${ REMOTE_SERVICE_IP }/
37+
4. http://${ FRONTEND_SERVICE_IP }:8000/client-call/
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
static
2+
.idea
3+
.env
4+
db.sqlite3
5+
*.iml
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
## Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2+
## SPDX-License-Identifier: Apache-2.0
3+
4+
# Use an official Python runtime as a parent image
5+
FROM python:3.10
6+
7+
# Set environment variables
8+
ENV PYTHONDONTWRITEBYTECODE 1
9+
ENV PYTHONUNBUFFERED 1
10+
11+
# Set the working directory
12+
WORKDIR /django_frontend_app
13+
14+
# Install dependencies
15+
COPY django_frontend_service/requirements.txt /django_frontend_app/
16+
RUN pip install -r requirements.txt
17+
18+
# Copy the project code into the container
19+
COPY django_frontend_service/. /django_frontend_app/
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
## Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2+
## SPDX-License-Identifier: Apache-2.0
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
## Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2+
## SPDX-License-Identifier: Apache-2.0
3+
import os
4+
5+
from django.core.asgi import get_asgi_application
6+
7+
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "django_frontend_service.settings")
8+
9+
application = get_asgi_application()
Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
## Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2+
## SPDX-License-Identifier: Apache-2.0
3+
import os
4+
from pathlib import Path
5+
from dotenv import load_dotenv
6+
7+
load_dotenv()
8+
# Build paths inside the project like this: BASE_DIR / 'subdir'.
9+
BASE_DIR = Path(__file__).resolve().parent.parent
10+
11+
12+
# Quick-start development settings - unsuitable for production
13+
# See https://docs.djangoproject.com/en/5.0/howto/deployment/checklist/
14+
15+
# SECURITY WARNING: keep the secret key used in production secret!
16+
SECRET_KEY = "django-insecure-!=+@($z#-ylp@au_@ey=9nh701y-p@_n-^c23k_&ia!o8catit"
17+
18+
# SECURITY WARNING: don't run with debug turned on in production!
19+
DEBUG = True
20+
21+
ALLOWED_HOSTS = ["*"]
22+
23+
24+
# Application definition
25+
# settings.py
26+
INSTALLED_APPS = [
27+
"django.contrib.admin",
28+
"django.contrib.auth",
29+
"django.contrib.contenttypes",
30+
"django.contrib.sessions",
31+
"django.contrib.messages",
32+
"django.contrib.staticfiles",
33+
]
34+
35+
MIDDLEWARE = [
36+
"django.middleware.security.SecurityMiddleware",
37+
"django.contrib.sessions.middleware.SessionMiddleware",
38+
"django.middleware.common.CommonMiddleware",
39+
"django.middleware.csrf.CsrfViewMiddleware",
40+
"django.contrib.auth.middleware.AuthenticationMiddleware",
41+
"django.contrib.messages.middleware.MessageMiddleware",
42+
"django.middleware.clickjacking.XFrameOptionsMiddleware",
43+
]
44+
45+
ROOT_URLCONF = "django_frontend_service.urls"
46+
47+
TEMPLATES = [
48+
{
49+
"BACKEND": "django.template.backends.django.DjangoTemplates",
50+
"DIRS": [],
51+
"APP_DIRS": True,
52+
"OPTIONS": {
53+
"context_processors": [
54+
"django.template.context_processors.debug",
55+
"django.template.context_processors.request",
56+
"django.contrib.auth.context_processors.auth",
57+
"django.contrib.messages.context_processors.messages",
58+
],
59+
},
60+
},
61+
]
62+
63+
WSGI_APPLICATION = "django_frontend_service.wsgi.application"
64+
65+
66+
# Database
67+
# https://docs.djangoproject.com/en/5.0/ref/settings/#databases
68+
69+
DATABASES = {
70+
"default": {
71+
"ENGINE": "django.db.backends.sqlite3",
72+
"NAME": BASE_DIR / "db.sqlite3",
73+
}
74+
}
75+
76+
77+
# Password validation
78+
# https://docs.djangoproject.com/en/5.0/ref/settings/#auth-password-validators
79+
80+
AUTH_PASSWORD_VALIDATORS = [
81+
{
82+
"NAME": "django.contrib.auth.password_validation.UserAttributeSimilarityValidator",
83+
},
84+
{
85+
"NAME": "django.contrib.auth.password_validation.MinimumLengthValidator",
86+
},
87+
{
88+
"NAME": "django.contrib.auth.password_validation.CommonPasswordValidator",
89+
},
90+
{
91+
"NAME": "django.contrib.auth.password_validation.NumericPasswordValidator",
92+
},
93+
]
94+
95+
96+
# Internationalization
97+
# https://docs.djangoproject.com/en/5.0/topics/i18n/
98+
99+
LANGUAGE_CODE = "en-us"
100+
101+
TIME_ZONE = "UTC"
102+
103+
USE_I18N = True
104+
105+
USE_TZ = True
106+
107+
108+
# Static files (CSS, JavaScript, Images)
109+
# https://docs.djangoproject.com/en/5.0/howto/static-files/
110+
111+
STATIC_URL = "static/"
112+
STATIC_ROOT = os.path.join(BASE_DIR, "static")
113+
114+
# Default primary key field type
115+
# https://docs.djangoproject.com/en/5.0/ref/settings/#default-auto-field
116+
117+
DEFAULT_AUTO_FIELD = "django.db.models.BigAutoField"
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
## Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2+
## SPDX-License-Identifier: Apache-2.0
3+
from django.urls import path
4+
from frontend_service_app import views
5+
6+
urlpatterns = [
7+
path('', views.healthcheck),
8+
path('aws-sdk-call', views.aws_sdk_call),
9+
path('outgoing-http-call', views.http_call),
10+
path('remote-service', views.downstream_service),
11+
path('client-call', views.async_service),
12+
]
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
## Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2+
## SPDX-License-Identifier: Apache-2.0
3+
import os
4+
5+
from django.core.wsgi import get_wsgi_application
6+
7+
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "django_frontend_service.settings")
8+
9+
application = get_wsgi_application()
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
## Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2+
## SPDX-License-Identifier: Apache-2.0
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
## Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2+
## SPDX-License-Identifier: Apache-2.0
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
## Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2+
## SPDX-License-Identifier: Apache-2.0
3+
from django.apps import AppConfig
4+
5+
6+
class FrontendServiceAppConfig(AppConfig):
7+
default_auto_field = "django.db.models.BigAutoField"
8+
name = "frontend_service_app"
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
## Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2+
## SPDX-License-Identifier: Apache-2.0
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
## Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2+
## SPDX-License-Identifier: Apache-2.0

0 commit comments

Comments
 (0)