Skip to content

Commit 014557a

Browse files
Changes for v1.1.0 (#5)
1 parent 6149c26 commit 014557a

File tree

78 files changed

+2896
-3550
lines changed

Some content is hidden

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

78 files changed

+2896
-3550
lines changed

.github/ISSUE_TEMPLATE/bug_report.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ To get the version of the solution, you can look at the description of the creat
2525
"Environment": {
2626
"Variables": {
2727
"SOLUTION_ID": "SO0248",
28-
"SOLUTION_VERSION": "v1.0.2"
28+
"SOLUTION_VERSION": "v1.1.0"
2929
}
3030
},
3131
```
@@ -34,7 +34,7 @@ This information is also provided in `source/infrastructure/cdk.json`:
3434

3535
```json
3636
"SOLUTION_ID": "SO0248",
37-
"SOLUTION_VERSION": "v1.0.2",
37+
"SOLUTION_VERSION": "v1.1.0",
3838
```
3939

4040

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,3 +73,7 @@ source/aws_lambda/shared/util/build/*
7373
*.tmp
7474
*.sav
7575
*.dtmp
76+
77+
# generated files
78+
source/infrastructure/custom_resources/docker_configs_bucket_lambda/current-config/
79+
source/infrastructure/custom_resources/docker_configs_bucket_lambda/default-config/

CHANGELOG.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1616
- Remove python `setuptools` and `pip` from prebid server docker image
1717
- Include missing copyright header for `source/infrastructure/prebid_server/stack_constants.py`
1818

19-
2019
## [1.0.2] - 2024-09-23
2120

2221
- Upgrade Python `requests` package to version 2.32.3 in requirements.txt
2322
- Bug fix for launch failure of EfsCleanupContainerStop Lambda function
23+
24+
## [1.1.0] - 2024-10-31
25+
- Upgrade to Prebid Server v3.13 and underlying Docker base image
26+
- ECS runtime logs in AWS CloudWatch instead of S3
27+
- Option to opt-out of installing CloudFront and WAF
28+
- Customize Prebid Server configuration through files in S3
29+
- Option to specify a custom container image

NOTICE.txt

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,7 @@ THIRD PARTY COMPONENTS
1313
This software includes third party software subject to the following copyrights:
1414

1515
Name Version License
16-
prebid-server-java 2.12.0 Apache-2.0
17-
Jinja2 3.1.2 BSD License
18-
MarkupSafe 2.1.1 BSD License
19-
PyYAML 6.0 MIT License
20-
Werkzeug 2.1.2 BSD License
16+
prebid-server-java 3.13.0 Apache-2.0
2117
attrs 22.1.0 MIT License
2218
avro 1.11.1 Apache Software License
2319
aws-cdk-lib 2.140.0 Apache-2.0
@@ -33,7 +29,6 @@ This software includes third party software subject to the following copyrights:
3329
aws-solutions-constructs.core 2.25.0 Apache-2.0
3430
aws-solutions-python 2.0.0 Apache Software License
3531
aws-xray-sdk 2.11.0 Apache Software License
36-
black 22.10.0 MIT License
3732
boto3 1.26.12 Apache Software License
3833
botocore 1.29.12 Apache Software License
3934
cattrs 22.2.0 MIT License
@@ -53,8 +48,10 @@ This software includes third party software subject to the following copyrights:
5348
idna 3.4 BSD License
5449
infrastructure 1.0.0 Apache Software License
5550
iniconfig 1.1.1 MIT License
51+
Jinja2 3.1.2 BSD License
5652
jmespath 1.0.1 MIT License
5753
jsii 1.71.0 Apache Software License
54+
MarkupSafe 2.1.1 BSD License
5855
moto 4.0.3 Apache Software License
5956
mypy-extensions 0.4.3 MIT License
6057
packaging 21.3 Apache Software License; BSD License
@@ -71,6 +68,7 @@ This software includes third party software subject to the following copyrights:
7168
pytest-mock 3.10.0 MIT License
7269
python-dateutil 2.8.2 Apache Software License; BSD License
7370
pytz 2022.6 MIT License
71+
PyYAML 6.0.2 MIT License
7472
requests 2.32.3 Apache Software License
7573
responses 0.17.0 Apache 2.0
7674
s3transfer 0.6.0 Apache Software License
@@ -85,4 +83,5 @@ This software includes third party software subject to the following copyrights:
8583
wrapt 1.14.1 BSD License
8684
xmltodict 0.13.0 MIT License
8785
wheel 0.38.4 MIT License
86+
Werkzeug 2.1.2 BSD License
8887

README.md

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1+
12
# Prebid Server Deployment on AWS
23

3-
This solution deploys v2.12.0 of [Prebid Server Java](https://github.com/prebid/prebid-server-java.git) with infrastructure in a single region of the AWS Cloud to handle a wide range of request traffic, and recording of auction and bid transaction data.
4+
This solution deploys v3.13.0 of [Prebid Server Java](https://github.com/prebid/prebid-server-java.git) with infrastructure in a single region of the AWS Cloud to handle a wide range of request traffic, and recording of auction and bid transaction data.
45

56
## Architecture
67

@@ -60,6 +61,13 @@ sh ../deployment/run-unit-tests.sh --in-venv 1
6061

6162
### 3. Build the solution for deployment
6263

64+
#### Prebid Server Container Image
65+
By default, the Prebid Server container image will be built locally using Docker ([README](deployment/ecr/prebid-server/README.md)). If you prefer to use a remote image (from ECR or Docker Hub), set the following environment variable with your fully qualified image name before building the template:
66+
67+
```bash
68+
export OVERRIDE_ECR_REGISTRY=your-fully-qualified-image-name
69+
```
70+
6371
#### Using AWS CDK (recommended)
6472
Packaging and deploying the solution with the AWS CDK allows for the most flexibility in development
6573
```bash
@@ -90,6 +98,7 @@ export DIST_BUCKET_PREFIX=my-bucket-name
9098
export SOLUTION_NAME=my-solution-name
9199
export VERSION=my-version
92100
export REGION_NAME=my-region
101+
export OVERRIDE_ECR_REGISTRY=my-ecr-registry
93102

94103
build-s3-cdk-dist deploy \
95104
--source-bucket-name $DIST_BUCKET_PREFIX \
@@ -108,6 +117,7 @@ build-s3-cdk-dist deploy \
108117
- `$SOLUTION_NAME` - The name of This solution (example: solution-customization)
109118
- `$VERSION` - The version number to use (example: v0.0.1)
110119
- `$REGION_NAME` - The region name to use (example: us-east-1)
120+
- `$OVERRIDE_ECR_REGISTRY` - The ecr-registry to use (example: public.ecr.aws/abc12345/prebid-server:latest)
111121

112122
This will result in all global assets being pushed to the `DIST_BUCKET_PREFIX`, and all regional assets being pushed to
113123
`DIST_BUCKET_PREFIX-<REGION_NAME>`. If your `REGION_NAME` is us-east-1, and the `DIST_BUCKET_PREFIX` is
@@ -122,19 +132,24 @@ After running the command, you can deploy the template:
122132
123133
> **Note:** You can drop `--sync` from the command to only perform the build and synthesis of the template without uploading to a remote location. This is helpful when testing new changes to the code.
124134
125-
#### Build prebid-server docker locally
126-
* [Docker README.md](deployment/ecr/prebid-server/README.md)
127-
128135
## Prebid Server Java Container Customization
129136

130137
You may choose to customize the container configuration, or create your own container to use with this solution. The infrastructure for this solution has only been tested on Prebid Server Java.
131138

139+
#### Deploy with Customized Prebid Server Configurations
140+
* After deploying the CloudFormation template stack, find the S3 bucket in the CloudFormation stack outputs named `ContainerImagePrebidSolutionConfigBucket`.
141+
1. Review the `/prebid-server/default/README.md` and `/prebid-server/current/README.md` files in the bucket.
142+
2. Upload your changes to the `/prebid-server/current/` prefix in that bucket.
143+
3. To update the ECS service manually, navigate to the Amazon ECS cluster associated with the deployed CloudFormation stack using the AWS Management Console. Then, update the ECS service by selecting the 'Force New Deployment' option with the new task definition version, as described in the official AWS documentation for updating an ECS service via the console. [ref](https://docs.aws.amazon.com/AmazonECS/latest/developerguide/update-service-console-v2.html).[ref](https://docs.aws.amazon.com/AmazonECS/latest/developerguide/update-service-console-v2.html).
144+
132145
### Runtime and Metric Logging for ETL
133146

147+
The Prebid Server container shipped with this solution is configured for two types of logging.
148+
149+
Runtime logs from the Prebid Server are sent to CloudWatch logs under the `PrebidContainerLogGroup` log group. This log group collects runtime logs for all containers and includes the container ID from ECS. Container logs are available to use with CloudWatch Log Insights and Live Tailing.
150+
134151
Review the file named `deployment/ecr/prebid-server/prebid-logging.xml` for the required locations of log file output. Resources outside of the containers instances, including Lambda Functions and AWS DataSync jobs, expect to find log files at the following locations.
135152

136-
* `/mnt/efs/logs/CONTAINER_ID/prebid-server.log` is where the current stdout/stderr output log is written.
137-
* `/mnt/efs/logs/CONTAINER_ID/archived/prebid-server.TIMESTAMP.log.gz` is where logs are rotated on a schedule. This location is scanned by AWS DataSync periodically to migrate logs from EFS to S3 for the long-term storage. Rotated logs are removed from EFS after migration to S3.
138153
* `/mnt/efs/metrics/CONTAINER_ID/prebid-metrics.log` is where the current metrics output log is written. The default interval for outputting metrics to this file is 30 seconds.
139154
* `/mnt/efs/metrics/CONTAINER_ID/archived/prebid-metrics.TIMESTAMP.log.gz`is where logs are rotated on a schedule. This location is scanned by AWS DataSync periodically to migrate logs from EFS to S3 for the ETL process to AWS Glue Catalog. Rotated logs are removed from EFS after migration to S3.
140155

@@ -153,7 +168,7 @@ If you'd like to use a different container:
153168
* Build and host the solution assets for installation in your account using the process described above
154169
* Change to the `deployment/global-s3-assets` folder on the build workstation
155170
* Open the file `prebid-server-deployment-on-aws.template` in an editor
156-
* Find the line in the template under the Task Definition resource that is `"Image": "public.ecr.aws/aws-solutions/prebid-server:v1.0.2",`
171+
* Find the line in the template under the Task Definition resource that is `"Image": "public.ecr.aws/aws-solutions/prebid-server:v1.1.0",`
157172
* Update the Image property value with your container image URI
158173
* Create the stack by uploading the changed template to the CloudFormation console
159174

deployment/build-s3-dist.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
# Paramenters:
1010
# - source-bucket-base-name: Name for the S3 bucket location where the template will source the Lambda
1111
# code from. The template will append '-[region_name]' to this bucket name.
12-
# For example: ./build-s3-dist.sh solutions v1.0.2
12+
# For example: ./build-s3-dist.sh solutions v1.1.0
1313
# The template will then expect the source code to be located in the solutions-[region_name] bucket
1414
#
1515
# - solution-name: name of the solution for consistency
@@ -21,7 +21,7 @@
2121
# Check to see if input has been provided:
2222
if [ -z "$1" ] || [ -z "$2" ] || [ -z "$3" ]; then
2323
echo "Please provide the base source bucket name, trademark approved solution name and version where the lambda code will eventually reside."
24-
echo "For example: ./build-s3-dist.sh solutions trademarked-solution-name v1.0.2"
24+
echo "For example: ./build-s3-dist.sh solutions trademarked-solution-name v1.1.0"
2525
exit 1
2626
fi
2727

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
/logs/*
2+
/metrics/*
3+
bootstrap.log
4+
sample/configs/prebid-config.yaml
Lines changed: 37 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,54 +1,50 @@
11
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
22
# SPDX-License-Identifier: Apache-2.0
33

4-
FROM public.ecr.aws/amazonlinux/amazonlinux:2023
54

6-
# Setup environment for building prebid-server-java
7-
RUN yum -y install maven-amazon-corretto17
5+
# ------------------------------------------------------------------------------------------------------------------------------------------------------
6+
# PURPOSE:
7+
# This Dockerfile is designed to build a Docker image for the Prebid Server Java application by cloning the repository,
8+
# building the application using Maven, and setting up the necessary configuration and scripts to run the application inside the container on aws.
9+
# -------------------------------------------------------------------------------------------------------------------------------------------------------
10+
# USAGE:
11+
# For instructions on how to build this Dockerfile locally, please refer to the README.md file in the current directory.
12+
# -------------------------------------------------------------------------------------------------------------------------------------------------------
813

9-
# Remove python setuptools and package installer
10-
RUN yum -y remove python-setuptools
11-
RUN yum -y remove python-pip
1214

13-
RUN yum -y install git
14-
RUN yum -y install jq
15-
RUN git clone https://github.com/prebid/prebid-server-java.git
16-
COPY config.json prebid-server-java/
17-
COPY prebid-logging.xml prebid-server-java/
18-
COPY prebid-server-java-patches.diff prebid-server-java/
15+
FROM public.ecr.aws/docker/library/maven:3-amazoncorretto-21-al2023
16+
17+
# Install required packages
18+
RUN yum -y install git jq aws-cli
19+
20+
# Update Python packages to address security vulnerabilities
21+
RUN dnf update python-setuptools --releasever 2023.1.20230719
22+
RUN dnf update python-pip --releasever 2023.3.20231211
23+
24+
# Clone the Prebid Server Java repository
25+
RUN git clone --single-branch --branch master https://github.com/prebid/prebid-server-java.git
26+
27+
# Copy source build configuration file
28+
COPY docker-build-config.json docker-build-config.json
29+
30+
# Set the working directory to the cloned repository
1931
WORKDIR /prebid-server-java
2032

21-
# Download the user-specified version of prebid-server-java
33+
# Fetch tags and checkout the specified version
2234
RUN git fetch origin --tags
23-
RUN git checkout $(jq -r .GIT_TAG_VERSION config.json)
24-
RUN git apply prebid-server-java-patches.diff
35+
RUN git checkout $(jq -r .GIT_TAG_VERSION ../docker-build-config.json)
2536

26-
# Build prebid-server-java using Maven
27-
RUN mvn clean package $(jq -r .MVN_CLI_OPTIONS config.json)
37+
# Build the Prebid Server Java application using Maven
38+
RUN mvn clean package $(jq -r .MVN_CLI_OPTIONS ../docker-build-config.json)
2839

29-
# Remove the local Maven repository
40+
# Remove the local Maven repository to reduce image size
3041
RUN rm -rf /root/.m2
3142

32-
EXPOSE 8080
33-
EXPOSE 8060
34-
35-
# An environment variable named ECS_CONTAINER_METADATA_URI_V4
36-
# is injected by AWS Fargate into each container in a task.
37-
# The entrypoint defined below parses the container's unique
38-
# ID from that environment variable and uses it to ensure the
39-
# prebid-server.log is written to a unique directory under
40-
# /mnt/efs/.
41-
#
42-
# Metrics are sent to /mnt/efs/metrics folder also using the
43-
# container ID in the path. Files have the name prebid-metrics.log.
44-
#
45-
# The space that is prepended to ${ECS_CONTAINER_METADATA_URI_V4})
46-
# is needed so that the container can be built locally where that
47-
# environment variable is not defined.
48-
ENTRYPOINT /usr/bin/java \
49-
-DcontainerId=$(basename " "${ECS_CONTAINER_METADATA_URI_V4}) \
50-
-Dlogging.config=./prebid-logging.xml \
51-
-XX:+UseParallelGC \
52-
-jar target/prebid-server.jar \
53-
--spring.config.additional-location=sample/prebid-config.yaml
54-
43+
# Expose ports for the Prebid Server Java application
44+
EXPOSE 8080 8060
45+
46+
# Copy the bootstrap script
47+
COPY bootstrap.sh ../bootstrap.sh
48+
49+
# Set the entrypoint to execute the bootstrap script
50+
ENTRYPOINT ["sh", "../bootstrap.sh"]

deployment/ecr/prebid-server/README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,11 @@
88
* Build prebid-server image.
99
`docker build -t prebid-server .`
1010
* Run prebid-server image:
11-
`docker run -v ./:/mnt/efs -p 8080:8080 prebid-server`
11+
`docker run -v ./:/mnt/efs -v ~/.aws:/root/.aws -p 8080:8080 prebid-server`
1212
* View prebid server log:
1313
`tail -f ./logs/prebid-server.log`
14+
* Check server to verify status `200 OK`, `{"application":{"status":"ok"}}`:
15+
`curl -i http://localhost:8080/status`
1416

1517

1618
### Docker Config
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
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+
# * Download Prebid Server configuration files and scripts from an S3 bucket.
9+
# * The S3 bucket name is obtained from the environment variable DOCKER_CONFIGS_S3_BUCKET_NAME.
10+
# * The configuration files are downloaded into a local /prebid-configs directory.
11+
# * The default and current configuration files are fetched from two specific prefixes in the S3 bucket.
12+
# * After download, the script verifies that essential configuration files exist.
13+
# * The entrypoint script is then executed to start the Docker containers.
14+
# -----------------------------------------------------------------------------------------------------------------------------------------------------------------
15+
16+
set -euo pipefail
17+
18+
# Set variables
19+
PREBID_CONFIGS_DIR="prebid-configs"
20+
ENTRYPOINT_SCRIPT="entrypoint.sh"
21+
REQUIRED_CONFIG_FILES="${ENTRYPOINT_SCRIPT} prebid-config.yaml prebid-logging.xml"
22+
ENTRYPOINT_DIR="../${PREBID_CONFIGS_DIR}"
23+
24+
# Check if the S3 bucket environment variable is set
25+
if [ -z "${DOCKER_CONFIGS_S3_BUCKET_NAME:-}" ]; then
26+
echo "Error: DOCKER_CONFIGS_S3_BUCKET_NAME environment variable is not set"
27+
exit 1
28+
else
29+
# Define S3 paths
30+
DEFAULT_S3_PATH="s3://${DOCKER_CONFIGS_S3_BUCKET_NAME}/prebid-server/default/"
31+
CURRENT_S3_PATH="s3://${DOCKER_CONFIGS_S3_BUCKET_NAME}/prebid-server/current/"
32+
33+
echo "Cleaning up and recreating ${ENTRYPOINT_DIR}"
34+
rm -rvf "${ENTRYPOINT_DIR}" || { echo "Failed to remove ${ENTRYPOINT_DIR}"; exit 1; }
35+
mkdir -pv "${ENTRYPOINT_DIR}" || { echo "Failed to create ${ENTRYPOINT_DIR}"; exit 1; }
36+
37+
# Download default Prebid configuration files from S3
38+
echo "Downloading default configuration files from S3 bucket: ${DEFAULT_S3_PATH}"
39+
if aws s3 cp "$DEFAULT_S3_PATH" "$ENTRYPOINT_DIR" --recursive --exclude "README.md"; then
40+
echo "Successfully downloaded default configuration files"
41+
else
42+
echo "Failed to download default configuration files"
43+
exit 1
44+
fi
45+
46+
# Download current Prebid configuration files from S3 (ignore if missing)
47+
echo "Downloading current configuration files from S3 bucket: ${CURRENT_S3_PATH}"
48+
if aws s3 cp "$CURRENT_S3_PATH" "$ENTRYPOINT_DIR" --recursive --exclude "README.md"; then
49+
echo "Successfully downloaded current configuration files"
50+
else
51+
echo "Warning: Failed to download current configuration files, proceeding without them"
52+
fi
53+
fi
54+
55+
# Check if all required configuration files exist
56+
for required_config_file in $REQUIRED_CONFIG_FILES; do
57+
echo "Checking if ${required_config_file} exists"
58+
if [ ! -f "${ENTRYPOINT_DIR}/${required_config_file}" ]; then
59+
echo "Error: Required configuration file ${required_config_file} is missing"
60+
exit 1
61+
fi
62+
done
63+
64+
# Execute the entrypoint script to start Docker containers
65+
echo "Executing ${ENTRYPOINT_SCRIPT}"
66+
sh "${ENTRYPOINT_DIR}/${ENTRYPOINT_SCRIPT}" || { echo "Failed to execute ${ENTRYPOINT_SCRIPT}"; exit 1; }

0 commit comments

Comments
 (0)