

# Deploy the solution

The solution is deployed as an AWS CDK application, using the `mdaa` CLI.

Before you deploy, review the [cost](cost.md), [architecture](architecture-overview.md), and other considerations discussed earlier in this guide.

**Tip**  
New to Secure AI Foundations? We recommend starting with the [Secure AI Foundations (formerly MDAA) Workshop](https://catalog.us-east-1.prod.workshops.aws/workshops/6e7289c7-5662-494d-8b56-b8706412c3a6/en-US) for a guided, hands-on introduction.

## Terminology
<a name="terminology"></a>
+  **Deployment Account** - The AWS account where deployment activities will be occurring. This includes source control, artifact building and publishing, and execution for Secure AI Foundations.
+  **Target Account** - The AWS account where Data Analytics Environment resources will ultimately be deployed by Secure AI Foundations. Note that Secure AI Foundations can execute in one account and deploy to another, or can execute and deploy to the same account.

## Prerequisites for CDK Deployment
<a name="prerequisites-for-cdk-deployment"></a>

### Manual Bootstrap (Single Deployment Source/Target Account)
<a name="manual-bootstrap-single-deployment-sourcetarget-account"></a>

1. Obtain AWS credentials for the account and place them into your credentials file or populate appropriate environment variables. These credentials should have sufficient permissions to create the following resources in the target account: \* IAM Roles \* SSM Parameters \* S3 Buckets

1. Run the CDK bootstrap command. Multiple regions can be specified simultaneously:

```bash
export CDK_NEW_BOOTSTRAP=1
cdk bootstrap aws://<AWS Account Number>/<Target Region>...
```

For example:

```bash
export CDK_NEW_BOOTSTRAP=1
cdk bootstrap aws://123456789012/ca-central-1 aws://123456789012/us-east-1
```

### Manual Bootstrap (Single Deployment Source Account and One or More Target Accounts)
<a name="manual-bootstrap-single-deployment-source-account-and-one-or-more-target-accounts"></a>

This procedure should be executed for each target account. This procedure bootstraps the target account while establishing trust with the source account (where deployments will be triggered)

Obtain AWS credentials for the target account and place them into your credentials file or populate appropriate environment variables.

These credentials should have sufficient permissions to create the following resources in the target account: \* IAM Roles \* SSM Parameters \* S3 Buckets

Run the CDK bootstrap command. Multiple regions can be specified simultaneously:

```bash
export CDK_NEW_BOOTSTRAP=1
cdk bootstrap --cloudformation-execution-policies <CDK Deployment IAM Policy Arns> --trust <Source Account Number> aws://<Target AWS Account Number>/<Target Region>...
```

Note that the permissions specified with cloudformation-execution-policies are granted to CloudFormation during deployment into the account. These permissions should be sufficient to deploy Secure AI Foundations resources, but not overly permissive.

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

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

The following are procedures which can be executed in order to manually deploy Secure AI Foundations to target accounts. These procedures assume that the appropriate preparations have been made within the organizations accounts.

### Deployment Patterns
<a name="deployment-patterns"></a>

Secure AI Foundations may be deployed using a number of patterns:
+ Same Deployment Source and Target Account (Centralized Data Environment)
+ Single Deployment Source account, One or More Separate Target Accounts (Centralized deployment governance, decentralized Data Environments)

### Deployment Preparation
<a name="deployment-preparation"></a>

#### Node Installation
<a name="node-installation"></a>

Install a version of Node.js using a method appropriate to your system. Secure AI Foundations requires nodejs 22.x and npm/npx version 10.x or greater.

As of Secure AI Foundations 1.8.0, the CLI is cross-platform: the shell commands it generates internally are emitted in the correct syntax for both POSIX shells and Windows `cmd.exe`, so the CLI runs on Windows as well as macOS and Linux. Note that the example commands shown throughout this guide use POSIX shell syntax; adapt them to your shell when running on Windows.

#### Environment Setup
<a name="environment-setup"></a>

Verify your credentials are populated either in your environment or in your \~/.aws/credentials file. Also, verify your AWS region is specified either in your environment or in your \~/.aws/config file:

```
[default]
region=us-east-1
```

#### Deployment from Published NPM Packages
<a name="deployment-from-published-npm-packages"></a>

Secure AI Foundations can be installed from a private NPM package repo, and will also attempt to install its modules from a private NPM repo. This is necessary if specific Secure AI Foundations versions are specified in mdaa.yaml.

Verify that your private NPM repo is accessible and contains the appropriate Secure AI Foundations NPM artifacts. If using a localhost based NPM repo (such as Verdaccio), verify it is running on localhost and updated with the latest Secure AI Foundations packages from S3 (See [PREDEPLOYMENT](https://github.com/aws/modern-data-architecture-accelerator/blob/main/PREDEPLOYMENT.md)). When executed from its NPM package, the `mdaa` CLI will also attempt to NPM install each module from NPM repo.

Install Secure AI Foundations from your private NPM repository using:

Global Installation:

```bash
npm install -g @aws-mdaa/cli
```

Then, the `mdaa` CLI can be executed globally:

```bash
mdaa -h
```

Optionally, both the `mdaa` CLI can be instead npm installed in a local directory:

```bash
npm install @aws-mdaa/cli
```

 `mdaa` commands can then be run within the local directory using NPX.

```bash
npx mdaa -h
```