

# Deploy the solution
<a name="deploy-the-solution"></a>

This solution uses [AWS CDK and stacks](https://docs.aws.amazon.com/cdk/v2/guide/home.html) to automate its deployment. The CDK code specifies the AWS resources included in this solution and their properties. The CDK stack provisions the resources that are described in the template.

**Important**  
This solution includes an option to send anonymized operational metrics to AWS. We use this data to better understand how customers use this solution and related services and products. AWS owns the data gathered through this survey. Data collection is subject to the [AWS Privacy Notice](https://aws.amazon.com/privacy/).  
To opt out of this feature, modify the CDK code before deploying. For more information, see the [Anonymized data collection](anonymized-data-collection.md) section of this guide.

## Prerequisites
<a name="prerequisties"></a>

You need an AWS account with permissions to deploy CDK stack and all the resources defined within the stack for this solution. The `AdministratorAccess` IAM policy, which provides full access to AWS services and resources is sufficient to deploy this solution.

## Deployment process overview
<a name="deployment-process-overview"></a>

Deploy the solution guidance using the AWS CDK stack available in the [Github repository](https://github.com/aws-solutions-library-samples/prebid-server-deployment-on-aws).

Before you launch the solution, review the [cost](cost1.md), [architecture](architecture-overview.md), [network security](security-1.md), and other considerations discussed earlier in this guide.

The solution consists of two CDK stacks:

1.  **Main Prebid Server Stack**: The core infrastructure for running Prebid Server (always deployed)

1.  **Bidder Simulator Stack**: An optional stack for quick start testing and validation

### Deployment methods
<a name="deployment-methods"></a>

 **Quick Deploy with deploy.sh (Recommended)** 

For a streamlined deployment experience on Linux/macOS, use the provided `deploy.sh` script:

```
# Deploy with analytics (most common use case)
./deploy.sh --enable-log-analytics --profile <your-aws-cli-profile> --region <your-region>

# Deploy with bidder simulator
./deploy.sh --deploy-bidding-simulator --profile <your-aws-cli-profile> --region <your-region>

# Deploy with bidder simulator and RTB Fabric
./deploy.sh --deploy-bidding-simulator --include-rtb-fabric --profile <your-aws-cli-profile> --region <your-region>

# Deploy with all features enabled
./deploy.sh --deploy-bidding-simulator --include-rtb-fabric --enable-log-analytics --profile <your-aws-cli-profile> --region <your-region>
```

The `deploy.sh` script automatically:
+ Copies AMT bidder files to the Docker build context when `--deploy-bidding-simulator` is used
+ Sets up the Python virtual environment
+ Installs dependencies
+ Runs CDK with the appropriate context flags

 **Manual Deployment with AWS CDK** 

For customization or manual deployment:

```
cd source/infrastructure

# Bootstrap CDK (required once)
cdk bootstrap --cloudformation-execution-policies arn:aws:iam::aws:policy/AdministratorAccess

# Deploy with bidder simulator
cdk deploy --all --context deployBiddingSimulator=true --profile <your-aws-cli-profile> --region <your-region>

# Deploy with bidder simulator and RTB Fabric
cdk deploy --all --context deployBiddingSimulator=true --context includeRtbFabric=true --profile <your-aws-cli-profile> --region <your-region>

# Deploy with analytics enabled
cdk deploy --all --context enableLogAnalytics=true --profile <your-aws-cli-profile> --region <your-region>

# Deploy without optional components
cdk deploy --all --profile <your-aws-cli-profile> --region <your-region>
```

For detailed deployment instructions and prerequisites, see the "Deployment Steps" section in the [Git repo readme](https://github.com/aws-solutions-library-samples/prebid-server-deployment-on-aws).

### Deployment options
<a name="deployment-options"></a>

 **Bidder Simulator (`--deploy-bidding-simulator`)** 

Deploys an optional bidder simulator stack for quick start testing. The simulator includes:
+ internal ALB \+ Lambda and VPC peering
+ Support for banner and video ad formats (including VAST instream video)
+ Demo website with Prebid.js integration
+ Automatic AMT adapter configuration

 **RTB Fabric (`--include-rtb-fabric`)** 

Enables AWS RTB Fabric integration for low-latency, cost-optimized private network connectivity. Requirements:
+ Must be used with `--deploy-bidding-simulator` 
+ RTB Fabric must be available in your deployment region

When enabled, the solution creates:
+ Requester Gateway in the Prebid Server VPC
+ Responder Gateway in the Bidder Simulator VPC
+ Fabric Link connecting the two gateways
+ Lambda function for automatic link acceptance

 **Analytics Adapter (`--enable-log-analytics`)** 

Enables the custom analytics adapter for detailed auction-level data collection. This provides comprehensive business intelligence data through the ETL pipeline.

You can view the status of the stack in the AWS CloudFormation console in the **Status** column. You should receive a CREATE\_COMPLETE status in approximately 10 minutes.

 **Time to deploy:** Approximately 10-15 minutes (varies based on optional components)