# Shared CD

This repo serves for shared-provider related issues.

## Shared tier EKS CD project

The eks-sharedtier project stores in pool/eks-sharedtier. You can focus on this dir when you are developing eks-sharedtier CD.

### Deploy a new EKS region

Refer to https://docs.google.com/document/d/1GQsis4CAzAEsHkbRn9D6jdyVRqWPvMfWbTsF0JGDg1c/edit#.

- For Dev region, submit a PR request to `main` branch, you can refer to https://github.com/tidbcloud/aws-shared-cd/pull/15
- For staging region, submit a PR request to the latest `release-*` branch, you can refer to https://github.com/tidbcloud/aws-shared-cd/pull/17 and https://github.com/tidbcloud/aws-shared-cd/pull/24/files. (You can just create one PR to `release-*`.)

When the PR merge, the deploying process will be set off. You can check the action status on the target branch. 

![eks-retry](doc/images/eks-retry.png)

If the action failed, you can dignosis the problem, and re-run the action.

### Update Pulumi script / Update a EKS region

Modify Pulumi script(*.ts) will not set off the EKS region updating. You need to make some modification on Pulumi stack config(*.yaml) to set off the updating, eg. modify the code comments in `Pulumi.dev-us-east-1-s01.yaml` to set off the updating.

If you need to update all the regions, you can modify all the Pulumi stack configs.

### The relations between environments(dev/staging/prod) and branches

Currently, the relations follow these rule:

- For dev environment, only the changed Pulumi.(dev.*).yaml in `main` branch, or the target branch of PR is `main` will set off the CD action. You can submit PR to `main` to modify the dev EKS region. 
- For staging environment, only the changed Pulumi.(staging.*).yaml in `release-*` branch, or the target branch of PR is `release-*` will set off. You can submit PR to `main`, and cherry-pick the PR to `release-*` to modify the staging EKS region.
- (TBD) prod

You can refer to these codes: https://github.com/tidbcloud/aws-shared-cd/blob/6da5db83a7c32fc498e25edc8c6a5f751327c5e5/.github/workflows/eks-freetier.yml#L60-L75

### Destroy a EKS region

There's a manual set off action to destroy EKS region. Please be caution with this operation.

![destroy-eks-region](doc/images/destroy-eks-region.png)

Input the region name and input `Yes` to ensure this operation.

Once the region is successfully destroyed, you can submit a PR to remove the unused Pulumi stack.

In the future, destroy operation should be set off by PR approving.
