# Prepare AWS for a Nitro API Signer

Before [deploying](/developers/getting-started/set-up-an-api-signer/api-signer-aws-enclave), prepare the following for either
CLI or CloudFormation setup. See the [overview](/developers/getting-started/set-up-an-api-signer/api-signer-aws-enclave-intro)
for benefits and tradeoffs.

## Prerequisites

- **Fordefi:** Administrator access to the intended organization, the mobile
app, and Nitro onboarding enabled. Each organization supports one API Signer.
- **Trusted workstation:** AWS CLI v2, OpenSSL, and Python 3.11+ for the packaged CLI.
No additional Python packages or build tools are needed.
- **AWS:** Your account and a commercial region supporting the chosen instance.
- **Network:** An existing VPC/private subnet with Amazon-provided DNS and
outbound HTTPS routing, such as a NAT gateway. The stack does not create
networking; no inbound access is needed.
- **Instance:** Nitro Enclaves support, **x86-64**, **4+ vCPUs**, and **8+ GiB RAM**.
Default: `m6i.xlarge`. Other qualifying types are allowed; not all Nitro-based
instances [support Enclaves](https://docs.aws.amazon.com/enclaves/latest/user/nitro-enclave.html#nitro-enclave-reqs).
The current release is built for x86-64 and reserves two vCPUs for the enclave,
leaving at least two for the parent instance.
- **AMI:** An Amazon Linux 2023 x86-64 AMI in the deployment region (lookup below).


### AWS permissions and roles

One customer IAM role can deploy the stack and administer its keys. An optional
backup administrator preserves key administration if that role is deleted.
The template creates the restricted EC2 runtime role.

Your AWS administrator must grant deployment-scoped permissions for:

- **Deployment:** CloudFormation stack creation/updates; management of EC2
security groups/launch templates, Auto Scaling, IAM roles/instance profiles/
policies, KMS keys/policies, S3 buckets/policies, and CloudWatch Logs;
`iam:PassRole` for the stack's roles.
- **Workstation:** Read stack outputs, `s3:PutObject`, `kms:GetPublicKey`, and
`ssm:GetParameter` for the AMI lookup.


If using a separate CloudFormation execution role, give it the deployment
permissions and include it among the key administrators. Workstation permissions
are still required. Supply IAM role ARNs, not STS assumed-role session ARNs.

### Outbound destinations

Allow HTTPS to these destinations for production:

- Fordefi: `api.fordefi.com`, `direct.fordefi.com`.
- Regional S3 (including the stack bucket), EC2, KMS, CloudFormation,
CloudWatch Logs, and CloudWatch Metrics endpoints.
- The selected AMI's [Amazon Linux repositories](https://docs.aws.amazon.com/linux/al2023/ug/managing-repos-os-updates.html).
For hostname allowlists, inspect `dnf repolist -v` on a matching AMI.
- Time sources: `www.google.com`, `api.binance.com`.
- With `EnableSSM=true`: regional `ssm`, `ssmmessages`, and `ec2messages` where
required; see [SSM connectivity](https://docs.aws.amazon.com/systems-manager/latest/userguide/setup-create-vpc.html).


JFrog access is required only on the workstation. Runtime files are uploaded to
S3 and downloaded by EC2 using its IAM role.

## Deployment parameters

Select an authenticated AWS profile and region, then verify the account:

```sh
export AWS_PROFILE='<customer-profile>' AWS_REGION='<deployment-region>'
aws sts get-caller-identity
```

Find an AMI using the [AWS public parameter](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/finding-an-ami-parameter-store.html):

```sh
aws ssm get-parameter \
  --name /aws/service/ami-amazon-linux-latest/al2023-ami-kernel-default-x86_64 \
  --query Parameter.Value --output text
```

Supply the returned AMI ID and retain it on upgrades unless deliberately changing it.

| CLI argument | CloudFormation parameter | Value |
|  --- | --- | --- |
| `--vpc-id` | `VpcId` | Existing VPC. |
| `--subnet-id` | `SubnetId` | Private subnet in that VPC. |
| `--ami-id` | `AmiId` | Regional Amazon Linux 2023 x86-64 AMI. |
| `--instance-type` | `InstanceType` | Default: `m6i.xlarge`; must meet the requirements above. |
| `--key-administrator-arn` | `KeyAdministratorArns` | Deployment IAM role, plus execution role if used. Repeat for optional backup administrators; use commas in CloudFormation. |


The CLI requires `--account-id` and `--region`; also supply your `--profile`.
`--stack-name` defaults to `fordefi-api-signer`. Optional `--role-arn` selects a
CloudFormation execution role, not the workstation profile.

### Optional and managed parameters

Defaults suit a typical deployment. Override optional settings with
`--parameter Name=Value` or their CloudFormation fields.

| Parameter | Default / usage |
|  --- | --- |
| `PermissionsBoundaryArn` | Empty; optional runtime-role permissions boundary. |
| `EnableSSM` | `false`; set `true` for Systems Manager access. |
| `LogRetentionDays` | `30`. |
| `EnclaveMemoryMiB` | `4096`; `2048` also supported. |
| `EnclaveCPUCount` | Fixed at `2`. |
| `EnableRuntime` | CLI-managed; for manual deployment, enable only after uploading release files. Defaults to `false`. |
| `ReleaseVersion`, `FordefiEnvironment` | Keep the release template's defaults. |


## Next step

Continue to [Deploy and manage](/developers/getting-started/set-up-an-api-signer/api-signer-aws-enclave).