Skip to content

Commit 13d7650

Browse files
authored
Feat/adding git workflow (#1)
* Add Fargate health check parameters to ECS service construct * Fix health check grace period to use Duration.seconds for ECS service * Adding github action to sync aws infrastructure
1 parent 71c3228 commit 13d7650

File tree

10 files changed

+350
-6
lines changed

10 files changed

+350
-6
lines changed
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
name: AWS CDK Deployment
2+
3+
on:
4+
push:
5+
branches: longitude
6+
7+
permissions:
8+
contents: read
9+
10+
concurrency:
11+
group: ci-${{ github.ref }}
12+
cancel-in-progress: true
13+
14+
jobs:
15+
deploy:
16+
runs-on: ubuntu-latest
17+
18+
steps:
19+
- name: Check out code
20+
uses: actions/checkout@v4
21+
22+
- name: Configure AWS credentials
23+
uses: aws-actions/configure-aws-credentials@v4
24+
with:
25+
aws-region: ${{ secrets.AWS_REGION }}
26+
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY }}
27+
aws-secret-access-key: ${{ secrets.AWS_ACCESS_SECRET }}
28+
aws-session-token: ${{ secrets.AWS_ACCESS_TOKEN }}
29+
30+
- name: Set up Python
31+
uses: actions/setup-python@v5
32+
with:
33+
python-version: "3.13"
34+
35+
- name: Set up Node
36+
uses: actions/setup-node@v4
37+
with:
38+
node-version: "20"
39+
40+
- name: Install and configure Poetry
41+
uses: snok/install-poetry@v1
42+
with:
43+
virtualenvs-create: true
44+
virtualenvs-in-project: true
45+
installer-parallel: true
46+
47+
- name: Install Dependencies
48+
working-directory: ./source
49+
run: |
50+
npm install -g aws-cdk
51+
poetry install
52+
53+
- name: Run tests
54+
working-directory: ./deployment
55+
run: bash ./run-unit-tests.sh --in-venv 1
56+
57+
- name: Build
58+
working-directory: ./source
59+
run: |
60+
. $VENV
61+
cd infrastructure
62+
cdk bootstrap --cloudformation-execution-policies arn:aws:iam::aws:policy/AdministratorAccess
63+
cdk synth
64+
65+
- name: Deploy
66+
working-directory: ./source
67+
68+
run: |
69+
. $VENV
70+
cd infrastructure
71+
cdk deploy --require-approval never
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
#!/usr/bin/env bash
2+
3+
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
4+
# SPDX-License-Identifier: Apache-2.0
5+
6+
# -----------------------------------------------------------------------------
7+
# PURPOSE:
8+
# This entrypoint script is used to start the Prebid Server container.
9+
#
10+
# An environment variable named ECS_CONTAINER_METADATA_URI_V4
11+
# is injected by ECS into each container. The variable contains a URI that
12+
# is used to retrieve container status and data.
13+
#
14+
# See:
15+
# https://docs.aws.amazon.com/AmazonECS/latest/developerguide/task-metadata-endpoint-v4.html
16+
#
17+
# The entrypoint defined below retrieves the data and parses the
18+
# container's unique ID from it and uses the ID to ensure
19+
# log data is written to a unique directory under /mnt/efs/.
20+
# The container ID is also included with logs sent directly
21+
# to CloudWatch.
22+
#
23+
# If the environment variable ECS_CONTAINER_METADATA_URI_V4 is not set,
24+
# the string "default-container-id" is returned instead so that the
25+
# container can be run locally.
26+
#
27+
# Metrics are sent to /mnt/efs/metrics folder also using the container ID
28+
# in the path. Files have the name prebid-metrics.log.
29+
#
30+
# The default Java executable entry point specified in this script can be
31+
# customized or replaced with a different command or executable.
32+
# ------------------------------------------------------------------------------
33+
34+
echo "entrypoint.sh starting"
35+
36+
PREBID_CONFIGS_DIR="/prebid-configs"
37+
38+
echo "prebid_configs_dir set"
39+
40+
/usr/bin/java \
41+
-DcontainerId=$(if [ -z "$ECS_CONTAINER_METADATA_URI_V4" ]; then echo "default-container-id"; else curl -s "${ECS_CONTAINER_METADATA_URI_V4}/task" | jq -r '.Containers[0].DockerId' 2>/dev/null | cut -d'-' -f1 || echo "default-container-id"; fi) \
42+
-Dlogging.config=${PREBID_CONFIGS_DIR}/prebid-logging.xml \
43+
-XX:+UseParallelGC \
44+
-jar target/prebid-server.jar \
45+
--spring.config.additional-location=${PREBID_CONFIGS_DIR}/prebid-config.yaml
46+
47+
echo "actual shell script run"
Lines changed: 169 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,169 @@
1+
# Sets the response for a status check; used for simple health checks.
2+
status-response: "ok"
3+
4+
externalUrl: https://s2s.lngtd.com/
5+
6+
analytics:
7+
log:
8+
enabled: true
9+
10+
adapters:
11+
12+
medianet:
13+
enabled: true
14+
15+
appnexus:
16+
enabled: true
17+
endpoint: https://ib.adnxs.com/openrtb2 # essential to most bidders, need to verify that the endpoint is correct
18+
19+
triplelift:
20+
enabled: true
21+
endpoint: https://tlx.3lift.com/s2s/auction?supplier_id=68
22+
23+
kargo:
24+
enabled: true
25+
26+
conversant:
27+
enabled: true
28+
29+
sharethrough:
30+
enabled: true
31+
32+
generic:
33+
aliases:
34+
nativo:
35+
endpoint: https://exchange.postrelease.com/esi.json?ntv_epid=7
36+
enabled: true
37+
38+
openx:
39+
enabled: true
40+
41+
ix:
42+
enabled: true
43+
endpoint: http://longitude-ads-us-east.lb.indexww.com/pbs?p=192251
44+
45+
epsilon:
46+
enabled: true
47+
48+
rubicon:
49+
enabled: true
50+
endpoint: http://exapi-us-east.rubiconproject.com/a/api/exchange.json?tk_sdc=us-east
51+
usersync:
52+
redirect:
53+
url: https://pixel.rubiconproject.com/exchange/sync.php?p=pbs-longitude&gdpr={{gdpr}}&gdpr_consent={{gdpr_consent}}&us_privacy={{us_privacy}}&gpp={{gpp}}&gpp_sid={{gpp_sid}
54+
XAPI:
55+
Username: pb_longitude_ads
56+
Password: LK0Y31N2B5
57+
58+
pubmatic:
59+
enabled: true
60+
61+
gumgum:
62+
enabled: true
63+
64+
debug: true # enables logging for debugging requests
65+
66+
price-floors:
67+
# May need this to enforce price flooring on Prebid Server. Does it require an explicit minimum?
68+
enforce-floors: true # Enable floor enforcement globally on the server
69+
enforce-deal-floors: true # Ensure deal bids also respect floors (optional)
70+
# enhance-bid-floors: true # Indicates that there is server-side dynamic flooring in custom logic, which is all handled server-side.
71+
# bid-floor-fallback: 0.63 # Fallback floor if no floor is set in client payload
72+
# floor-minimum: 0.63 # The minimum floor Prebid Server should enforce
73+
74+
metrics:
75+
# Metrics collection configuration.
76+
77+
# Enables logging of metrics to the logging backend specified (e.g., for debugging purposes).
78+
logback:
79+
enabled: true
80+
# Name of the metrics logger, can be customized based on logging system setup.
81+
name: METRICS
82+
# Frequency of logging the metrics in seconds.
83+
interval: 30
84+
85+
cache:
86+
# Cache configuration to store responses for faster retrieval.
87+
88+
# Specifies the caching protocol (typically http or https).
89+
scheme: http
90+
# The host where the cache is stored (use localhost for local setup).
91+
host: localhost # We need a dedicated caching server accessible to all sites
92+
# Path on the server where cache data can be accessed.
93+
path: /cache
94+
# Query parameter used by the cache to retrieve specific cached data.
95+
query: uuid=
96+
97+
settings:
98+
# Settings configuration for Prebid Server behavior.
99+
100+
# Enforces the validation of account IDs. Setting this to false allows requests with non-validated accounts.
101+
enforce-valid-account: false
102+
# Generates a unique ID for bid requests if one is not provided.
103+
generate-storedrequest-bidrequest-id: true
104+
105+
# Configures settings for stored configurations (often useful in testing or non-production setups).
106+
filesystem:
107+
# Path to the primary settings file.
108+
settings-filename: sample/configs/sample-app-settings.yaml
109+
# Directory for stored requests (input from publishers).
110+
stored-requests-dir: sample
111+
# Directory for stored impressions.
112+
stored-imps-dir: sample
113+
# Directory for stored responses.
114+
stored-responses-dir: sample
115+
# Directory for categories used in bid filtering.
116+
categories-dir:
117+
118+
accounts:
119+
# Placeholder account configuration
120+
- id: "bookrags" # Replace with your actual account ID
121+
name: "Bookrags"
122+
# Additional optional fields can be added as needed
123+
# currency: "USD"
124+
# defaultTtl: 3600 # TTL in seconds for bid responses, if required
125+
126+
gdpr:
127+
# GDPR settings for handling user consent and privacy.
128+
129+
# Default GDPR consent value if none is provided (1 = consent, 0 = no consent).
130+
default-value: 0
131+
132+
# Vendor lists for GDPR compliance, organized by TCF versions (2 and 3 in this case).
133+
vendorlist:
134+
v2:
135+
# Directory to store the cached vendor list for TCF version 2.
136+
cache-dir: /var/tmp/vendor2
137+
v3:
138+
# Directory to store the cached vendor list for TCF version 3.
139+
cache-dir: /var/tmp/vendor3
140+
141+
admin-endpoints:
142+
# Administrative endpoints for controlling Prebid Server.
143+
logging-httpinteraction:
144+
enabled: true
145+
path: /logging/httpinteraction
146+
on-application-port: true
147+
protected: false
148+
149+
150+
# Allows changing log levels dynamically.
151+
logging-changelevel:
152+
enabled: true
153+
# Path to access the logging level change endpoint.
154+
path: /logging/changelevel
155+
# Whether this endpoint is accessible on the main application port.
156+
on-application-port: true
157+
# Sets the endpoint as unprotected; consider adding protection in production.
158+
protected: false
159+
160+
# Logging Configuration for Verbose Debugging
161+
logging:
162+
sampling-rate: 0.01
163+
level:
164+
root: ERROR # Set the default log level for all packages
165+
change-level:
166+
max-duration-ms: 3600000 # 1h
167+
output:
168+
stdout: true # Output logs to console
169+
file: /var/log/prebid-server.log # Output logs to file
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<configuration>
3+
<include resource="org/springframework/boot/logging/logback/defaults.xml" />
4+
<include resource="org/springframework/boot/logging/logback/console-appender.xml" />
5+
6+
<!-- Get the ECS container id -->
7+
<property name="CONTAINER_ID" value="${containerId}" />
8+
9+
<!-- Define the stdout appender for INFO and lower levels -->
10+
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
11+
<target>System.out</target>
12+
<encoder>
13+
<pattern>{"timestamp":"%d{yyyy-MM-dd'T'HH:mm:ss.SSSZ}", "level":"%p", "logger":"%logger", "thread":"%t", "message":"%msg", "exception":"%ex", "containerId":"${CONTAINER_ID}"}%n</pattern>
14+
</encoder>
15+
</appender>
16+
17+
<!-- Async wrapper for stdout -->
18+
<appender name="LOG_ASYNC" class="ch.qos.logback.classic.AsyncAppender">
19+
<appender-ref ref="STDOUT" />
20+
</appender>
21+
22+
<!-- Define the metrics appender -->
23+
<appender name="METRICS_APPENDER" class="ch.qos.logback.core.rolling.RollingFileAppender">
24+
<file>/mnt/efs/metrics/${CONTAINER_ID}/prebid-test-metrics.log</file>
25+
<rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
26+
<!-- Rollover at the top of each hour -->
27+
<fileNamePattern>
28+
/mnt/efs/metrics/${CONTAINER_ID}/archived/prebid-test-metrics.%d{yyyy-MM-dd_HH}.%i.log.gz</fileNamePattern>
29+
<maxFileSize>100MB</maxFileSize>
30+
</rollingPolicy>
31+
<encoder>
32+
<pattern>{"timestamp":"%d{yyyy-MM-dd'T'HH:mm:ss.SSSZ}", "level":"%p", "logger":"%logger", "thread":"%t", "message":"%msg", "containerId":"${CONTAINER_ID}"}%n</pattern>
33+
</encoder>
34+
</appender>
35+
36+
<appender name="METRICS_ASYNC" class="ch.qos.logback.classic.AsyncAppender">
37+
<appender-ref ref="METRICS_APPENDER" />
38+
</appender>
39+
40+
<!-- Logger for metrics with no additivity -->
41+
<logger name="METRICS" additivity="false">
42+
<appender-ref ref="METRICS_ASYNC" />
43+
</logger>
44+
45+
<logger name="http-interaction" level="INFO"/>
46+
47+
<!-- Root logger to output logs to stdout and stderr -->
48+
<root level="info">
49+
<appender-ref ref="LOG_ASYNC" /> <!-- Sends logs to stdout for info and below -->
50+
</root>
51+
</configuration>

solution-manifest.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
id: SO0248
2-
name: prebid-server-deployment-on-aws
2+
name: longitude-s2s
33
version: v1.1.1
44
cloudformation_templates:
55
- template: prebid-server-deployment-on-aws.template

source/infrastructure/cdk.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,10 @@
2828
"aws-cn"
2929
],
3030
"@aws-cdk/aws-s3:serverAccessLogsUseBucketPolicy": true,
31-
"SOLUTION_NAME": "Prebid Server Deployment on AWS",
31+
"SOLUTION_NAME": "longitude-s2s",
3232
"SOLUTION_ID": "SO0248",
3333
"SOLUTION_VERSION": "v1.1.1",
3434
"METRICS_NAMESPACE": "prebid-server-deployment-on-aws-metrics",
3535
"BUCKET_NAME": "BUCKET_NAME"
3636
}
37-
}
37+
}

source/infrastructure/prebid_server/ecs_service_construct.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,9 @@ def __init__(
3333
cluster=prebid_cluster,
3434
task_definition=prebid_task_definition,
3535
vpc_subnets=ec2.SubnetSelection(subnets=prebid_task_subnets),
36+
min_healthy_percent=globals.FARGATE_MIN_HEALTHY_PERCENT,
37+
max_healthy_percent=globals.FARGATE_MAX_HEALTHY_PERCENT,
38+
health_check_grace_period=Duration.seconds(globals.HEALTH_CHECK_GRACE_PERIOD),
3639
capacity_provider_strategies=[
3740
ecs.CapacityProviderStrategy(
3841
capacity_provider="FARGATE",

source/infrastructure/prebid_server/prebid_server_stack.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525

2626

2727
class PrebidServerStack(SolutionStack):
28-
name = "prebid-server-deployment-on-aws"
28+
name = "longitude-s2s"
2929
description = "Prebid Server Deployment on AWS"
3030
template_filename = "prebid-server-deployment-on-aws.template"
3131

0 commit comments

Comments
 (0)