# Deploy ScyllaDB to Your Own Cloud Account - AWS

Available with the Professional plan and above

When you select Amazon Web Services as your cloud provider when creating
a cluster, your cluster is deployed by default under the ScyllaDB AWS account.
As an alternative, you can deploy the ScyllaDB database into your own AWS
account—we refer to it as Bring Your Own Account (BYOA).

When using BYOA for AWS, it is recommended to have a dedicated AWS sub-account
for ScyllaDB Cloud by using AWS Organizations and following the procedure using
that dedicated account. This will give you better control and visibility of
ScyllaDB Cloud permissions and actions.

This article will guide you through the process of integrating your AWS account with ScyllaDB Cloud.

## Prerequisites

* Verify that the recommended limits are set for your AWS account. See:
  * [AWS Account Limits](#byoa-aws-account-limits)
  * [AWS Credentials](#byoa-aws-role-permissions)
* Database encryption requires AWS Key Management Service (AWS KMS) to be
  available in the same region as your ScyllaDB Cloud cluster.

## Linking Your AWS Account to ScyllaDB Cloud

Before you provision a cluster in your AWS account, you must link that
account with ScyllaDB Cloud.
You can link multiple AWS accounts with one ScyllaDB Cloud account.

To link your AWS account with ScyllaDB Cloud, you need to run
a pre-configured CloudFormation Stack that will provision a user
with all necessary permissions.

#### NOTE
We recommend that you add one role per each AWS cluster you want to link.
This will help you achieve better accountability.

1. Go to **Managed Resources** via the drop-down in the top right corner next
   to your username.
2. Open the **Bring Your Own Account** tab.
3. Click **Add Account** to open the *Add Cloud Account* pop-up.
4. Choose your **Amazon Web Services** from the **Provider** drop-down.
5. Click **Launch Stack** to open a pre-filled CloudFormation form.
6. Complete the form and select the **I acknowledge that AWS CloudFormation might
   create IAM resources with custom names** checkbox at the bottom of the page
   to confirm you understand that CloudFormation might create IAM resources,
   like roles, users, or policies, and assign custom names to those resources.
7. Click **Create stack** at the bottom of the page.
8. When the stack creation process is completed, return to the ScyllaDB Cloud
   page. The *Launch Stack* button will be greyed out.
9. Click **Verify** to verify that your AWS account has been set up correctly.
10. (Optional) While waiting for verification to complete, you can add a custom
    alias for your account. A user-friendly identifier is helpful if your
    ScyllaDB account is connected to multiple AWS accounts to clearly identify
    and manage each account.

<i class="inline-icon icon-check" aria-hidden="true"></i> Once CloudFormation completes successfully and access is verified, your AWS
account is ready to be used for the deployment of ScyllaDB clusters. When you
select the **Your AWS Account** option during cluster creation, the new account
will be available in the drop-down (either the alias, if provided, or the Account
name will be displayed).

To add another AWS account, repeat the steps above. You can link multiple AWS accounts
to one ScyllaDB Cloud account.

## Reviewing and Managing Your Accounts

To review the list of your accounts linked with ScyllaDB Cloud, go to
**Managed Resources** via the drop-down and open the **Bring Your Own Account** tab.

It will display the following information:

* **Alias** - A user-friendly name for your account that simplifies referencing
  and management.
  To add or update an alias, click the **Actions** menu for the account and
  choose **Edit Alias**.
* **Account/Project** - The name of your AWS account or GCP Project.
* **ID** - The ID of your account in ScyllaDB Cloud (`byoa_id`). It is
  required to create a cluster using ScyllaDB Cloud API or Terraform.
* **Provider** - Your cloud provider name.
* **Date Added** - The date when the account was added to ScyllaDB Cloud.
* **Status** - The status of the account in ScyllaDB Cloud:
  * *Available* - The account is added to ScyllaDB Cloud and verified.
    You can use it when creating a new cluster.
  * *Pending Action* - The account has not been provisioned.
    You can click *Resume* to finalize your account.
  * *In Use* - The account is in use by an existing cluster. You can click
    the **Cluster Name** link next to the status to view the information about
    the cluster.
  * *Deleted* - The account has been deleted and cannot be re-used.
* **Clusters** - The list of clusters deployed under this account.
* **Actions** - An actions menu for managing the account. It includes options
  to delete the account or create an alias for it.

### Deleting an Account

You can delete an account that is not in use. To delete your account:

1. Go to **Managed Resources** via the drop-down and open
   the **Bring Your Own Account** tab.
2. Click the **Actions** menu for the account you want to delete.
3. Choose **Delete**.

This will remove any information associated with that account from ScyllaDB Cloud.
Consequently, you won’t be able to use that account to provision new clusters.

Next, you can remove ScyllaDB Cloud resources from your AWS account or GCP project
by clicking the **Clean Up** button displayed for the account you deleted.

<a id="byoa-aws-account-limits"></a>

## AWS Account Limits

To ensure that you don’t exceed your AWS account quota, we suggest setting
a specific quota for the resources that ScyllaDB Cloud will use. These quotas
should be adjusted for each region where you intend to operate. Please note
that the recommended limits should be considered in addition to your current
resource allocation.

Use **AWS Service Quotas** to increase the following resources limits:

| Service Name                              | Additional Requested Value   | Quota Name                                                       |
|-------------------------------------------|------------------------------|------------------------------------------------------------------|
| Amazon Virtual Private Cloud (Amazon VPC) | 50                           | VPCs per region                                                  |
| Amazon Virtual Private Cloud (Amazon VPC) | 96                           | Inbound or outbound rules per security group                     |
| Amazon Elastic Compute Cloud (Amazon EC2) | 20                           | EC2-VPC Elastic IPs                                              |
| Amazon Elastic Compute Cloud (Amazon EC2) | 1000 (see note)              | Running On-Demand Standard (A, C, D, H, I, M, R, T, Z) instances |
| Amazon Simple Storage Service (Amazon S3) | 50                           | Buckets                                                          |
| AWS CloudFormation                        | 100                          | Stack count                                                      |

#### NOTE
You can use this [`helper script`](https://cloud.docs.scylladb.com/stable/cloud-setup/https:/raw.githubusercontent.com/scylladb/scylla-code-samples/master/scylla-cloud/scripts/scylla-check-aws-limits.sh) to
quickly list relevant quotas for your account.

#### NOTE
1000 doesn’t represent the limit for the number of instances, but the limit for vCPUs. Any launched instance of any of the listed instance types (A, C, D, H, I, M, R, T, Z) contributes its vCPU count towards this quota. See more in this [AWS blog](https://aws.amazon.com/blogs/compute/preview-vcpu-based-instance-limits/).

<a id="byoa-aws-role-permissions"></a>

## AWS BYOA Role Permissions

This section lists the permissions that ScyllaDB Cloud role requires to deploy
and manage your clusters in your AWS account.

| Category          | Permision                                                                                                                                                                                                                                                                                                                                                                                                 |
|-------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| Roles             | * iam:GetRole<br/>* iam:ListAttachedRolePolicies<br/>* iam:ListAttachedUserPolicies<br/>* iam:ListGroupsForUser<br/>* iam:ListRolePolicies<br/>* iam:GetRolePolicy<br/>* iam:GetUserPolicy<br/>* iam:ListUserPolicies<br/>* iam:GetLoginProfile<br/>* iam:ListEntitiesForPolicy<br/>* iam:CreateRole<br/>* iam:DeleteRole<br/>* iam:TagRole<br/>* iam:PassRole<br/>* iam:ListRoles<br/>* iam:ListRoleTags |
| Policies          | * iam:GetPolicy<br/>* iam:GetPolicyVersion<br/>* iam:AttachRolePolicy<br/>* iam:DetachRolePolicy<br/>* iam:ListAttachedRolePolicies<br/>* iam:SetDefaultPolicyVersion<br/>* iam:DeletePolicyVersion<br/>* iam:ListPolicyVersions<br/>* iam:DeletePolicy<br/>* iam:CreatePolicyVersion<br/>* iam:CreatePolicy<br/>* iam:TagPolicy                                                                          |
| Instance Profiles | * iam:CreateInstanceProfile<br/>* iam:GetInstanceProfile<br/>* iam:DeleteInstanceProfile<br/>* iam:RemoveRoleFromInstanceProfile<br/>* iam:AddRoleToInstanceProfile<br/>* iam:TagInstanceProfile<br/>* iam:AssociateIamInstanceProfile<br/>* iam:DisassociateIamInstanceProfile<br/>* iam:ListInstanceProfiles                                                                                            |

| Category        | Permision                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               |
|-----------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| Instances       | * ec2:RunInstances<br/>* ec2:TerminateInstances<br/>* ec2:StartInstances<br/>* ec2:StopInstances<br/>* ec2:RebootInstances<br/>* ec2:GetConsoleOutput<br/>* ec2:ModifyInstanceAttribute<br/>* ec2:AssociateIamInstanceProfile<br/>* ec2:DisassociateIamInstanceProfile<br/>* ec2:CreatePlacementGroup<br/>* ec2:DeletePlacementGroup<br/>* ec2:Describe\*                                                                                                                                                                                                                                                                                                                                                                                                                                                               |
| Networking      | * ec2:CreateNetworkInterface<br/>* ec2:DeleteNetworkInterface<br/>* ec2:ModifyNetworkInterfaceAttribute<br/>* ec2:AttachNetworkInterface<br/>* ec2:DetachNetworkInterface                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               |
| Storage         | * ec2:CreateVolume<br/>* ec2:ModifyVolume<br/>* ec2:AttachVolume<br/>* ec2:DetachVolume<br/>* ec2:DeleteVolume                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          |
| Security Groups | * ec2:CreateSecurityGroup<br/>* ec2:AuthorizeSecurityGroupIngress<br/>* ec2:AuthorizeSecurityGroupEgress<br/>* ec2:RevokeSecurityGroupIngress<br/>* ec2:RevokeSecurityGroupEgress<br/>* ec2:DeleteSecurityGroup                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         |
| Key Pairs       | * ec2:CreateKeyPair<br/>* ec2:ImportKeyPair<br/>* ec2:DeleteKeyPair                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     |
| VPC             | * ec2:CreateVpc<br/>* ec2:DeleteVpc<br/>* ec2:ModifyVpcAttribute<br/>* ec2:CreateVpcPeeringConnection<br/>* ec2:AcceptVpcPeeringConnection<br/>* ec2:DeleteVpcPeeringConnection<br/>* ec2:AssociateRouteTable<br/>* ec2:CreateInternetGateway<br/>* ec2:AttachInternetGateway<br/>* ec2:DetachInternetGateway<br/>* ec2:DeleteInternetGateway<br/>* ec2:CreateRoute<br/>* ec2:DeleteRoute<br/>* ec2:ReplaceRoute<br/>* ec2:CreateRouteTable<br/>* ec2:DeleteRouteTable<br/>* ec2:DisassociateRouteTable<br/>* ec2:CreateSubnet<br/>* ec2:DeleteSubnet<br/>* ec2:ModifySubnetAttribute<br/>* ec2:CreateVpcEndpoint<br/>* ec2:DeleteVpcEndpoints<br/>* ec2:CreateTransitGatewayVpcAttachment<br/>* ec2:DeleteTransitGatewayVpcAttachment<br/>* ec2:DescribeTransitGatewayVpcAttachments<br/>* ec2:DescribeTransitGateways |
| Elastic IP      | * ec2:AllocateAddress<br/>* ec2:AssociateAddress<br/>* ec2:DisassociateAddress<br/>* ec2:ReleaseAddress                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 |
| Tags            | * ec2:CreateTags<br/>* ec2:DeleteTags                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   |
| Snapshots       | * ec2:CreateSnapshot<br/>* ec2:DeleteSnapshot<br/>* ec2:DescribeSnapshots<br/>* ec2:CopySnapshot                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        |

| Category   | Permision                                                                             |
|------------|---------------------------------------------------------------------------------------|
| Buckets    | * s3:CreateBucket<br/>* s3:DeleteBucket<br/>* s3:ListBucket<br/>* s3:PutBucketTagging |
| Objects    | * s3:GetObject<br/>* s3:GetObjectVersion<br/>* s3:PutObject<br/>* s3:DeleteObject     |

| Category   | Permision                                                                                                                                                                                                                                                                                                                                                                                                                     |
|------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| Stacks     | * cloudformation:CreateStack<br/>* cloudformation:DeleteStack<br/>* cloudformation:Describe\*<br/>* cloudformation:DetectStackDrift<br/>* cloudformation:DetectStackResourceDrift<br/>* cloudformation:GetStackPolicy<br/>* cloudformation:SetStackPolicy<br/>* cloudformation:ListStackResources<br/>* cloudformation:CreateChangeSet<br/>* cloudformation:UpdateTerminationProtection<br/>* cloudformation:ValidateTemplate |

| Category   | Permision            |
|------------|----------------------|
| Functions  | * lambda:GetFunction |

| Category   | Permision                                             |
|------------|-------------------------------------------------------|
| Security   | * sts:AssumeRole<br/>* sts:DecodeAuthorizationMessage |

| Category   | Permision                                                                                                           |
|------------|---------------------------------------------------------------------------------------------------------------------|
| Limits     | * servicequotas:ListServiceQuotas<br/>* servicequotas:GetServiceQuota<br/>* servicequotas:GetAWSDefaultServiceQuota |

| Category   | Permision                                                                |
|------------|--------------------------------------------------------------------------|
| Logs       | * logs:CreateLogGroup<br/>* logs:CreateLogStream<br/>* logs:PutLogEvents |

| Category        | Permision                                                                                                                     |
|-----------------|-------------------------------------------------------------------------------------------------------------------------------|
| Resource Shares | * ram:ListResources<br/>* ram:GetResourceShares<br/>* ram:GetResourceShareInvitations<br/>* ram:AcceptResourceShareInvitation |
