|
1 |
| -## My Project |
| 1 | +# Serverless Silos |
2 | 2 |
|
3 |
| -TODO: Fill this README out! |
| 3 | +A reference architecture using services such as CDK and Lambda to demonstrate a hands-on approach to implementing Serverless Silos. |
4 | 4 |
|
5 |
| -Be sure to: |
| 5 | +This was demonstrated at AWS Summit ANZ 2023: Simplify multi-tenant microservice applications - https://www.youtube.com/watch?v=upfYIB6Rz0o |
6 | 6 |
|
7 |
| -* Change the title in this README |
8 |
| -* Edit your repository description on GitHub |
9 | 7 |
|
10 |
| -## Security |
11 | 8 |
|
12 |
| -See [CONTRIBUTING](CONTRIBUTING.md#security-issue-notifications) for more information. |
| 9 | +<p align="center"> |
| 10 | + <img src="/img/architecture.png" /> |
| 11 | +</p> |
| 12 | + |
| 13 | +> :warning: This artifact deploys a **public API** resource and should be **deleted** when not in use or a form of **authentication should be added** to the API. You are responsible for the costs associated with deploying this project, it is recommended to **destroy the stack when not in use**. |
| 14 | +
|
| 15 | +### Solution Overview |
| 16 | + |
| 17 | +#### Infrastructure Deployment |
| 18 | + |
| 19 | +<p align="center"> |
| 20 | + <img src="/img/template_synth.png" width="500"/> |
| 21 | +</p> |
| 22 | + |
| 23 | +CDK is used to define the infrastructure as code and synthesize CloudFormation templates. The templates are then stored in an S3 bucket for deployment. |
| 24 | + |
| 25 | +To deploy the CDK application: |
| 26 | + |
| 27 | +1. Clone this repository |
| 28 | +2. Run `cdk bootstrap` to setup CDK toolkit stack |
| 29 | +3. Run `cdk deploy` to deploy the stack (assuming you have AWS credentials in your environment) |
| 30 | + |
| 31 | +#### Tenant Control Plane |
| 32 | + |
| 33 | +The tenant control plane manages tenant lifecycle via API Gateway. Lambda functions handle tenant onboarding/offboarding. DynamoDB stores the state of all tenancies and streams changes to trigger provisioning. Step Functions can be used to orchestrate the provisioning of new tenancies based on DynamoDB state. |
| 34 | + |
| 35 | +**Note**: In the example code the Step Function has been replaced with a single deployment lambda. If you have a multi step deployment process you should use a Step Function to orchestrate it. |
| 36 | + |
| 37 | +<p align="center"> |
| 38 | + <img src="/img/tenant_control_plane.png" width="800"/> |
| 39 | +</p> |
| 40 | + |
| 41 | +#### Tenant Deployment |
| 42 | + |
| 43 | + The onboarding Lambda retrieves templates from S3, populates parameters, and calls CloudFormation to deploy tenant resources. |
| 44 | + |
| 45 | + <p align="center"> |
| 46 | + <img src="/img/tenant_deployment.png" width="800"/> |
| 47 | +</p> |
| 48 | + |
| 49 | +An example tenant stack is then deployed with DynamoDB table, Lambda function, and permissions. |
| 50 | + |
| 51 | +To create, update or delete tenants use the endpoints outlined below. |
| 52 | + |
| 53 | +## Deployed Endpoints |
| 54 | + |
| 55 | +#### Fetch Tenants |
| 56 | +**HTTP Method**: GET |
| 57 | +**Endpoint**: /tenants |
| 58 | +**Description**: Retrieves a list of all tenant records from the system. |
| 59 | +**Request**: No request body required. |
| 60 | +**Response**: An array of tenant objects in JSON format. |
| 61 | + |
| 62 | +```json |
| 63 | +[ |
| 64 | + { |
| 65 | + "tenantName": "silo_tenant", |
| 66 | + "status": "running", |
| 67 | + "tenantId": "12345678-1234-1234-1234-123456789100", |
| 68 | + "created": "1600000000.000000000000000000000", |
| 69 | + "deploymentType": "silo", |
| 70 | + "tenantSafeName": "silo_tenant" |
| 71 | + } |
| 72 | + ... |
| 73 | +] |
| 74 | +``` |
| 75 | + |
| 76 | + |
| 77 | +#### Create Tenant |
| 78 | + |
| 79 | +**HTTP Method**: POST |
| 80 | +**Endpoint**: /onboarding |
| 81 | +**Description**: Onboards a new tenant with a specified name and deployment type. |
| 82 | +**Request Body**: |
| 83 | + |
| 84 | + |
| 85 | +```json |
| 86 | +{ |
| 87 | + "tenantName": "string", |
| 88 | + "deploymentType": "string" |
| 89 | +} |
| 90 | +``` |
| 91 | + |
| 92 | + |
| 93 | +#### Delete Tenant |
| 94 | + |
| 95 | +**HTTP Method**: POST |
| 96 | +**Endpoint**: /delete |
| 97 | +**Description**: Deletes an existing tenant based on the provided tenant information. |
| 98 | +**Request Body**: |
| 99 | + |
| 100 | +```json |
| 101 | +{ |
| 102 | + "tenantName": "string", |
| 103 | + "tenantId": "string" |
| 104 | +} |
| 105 | +``` |
| 106 | + |
| 107 | +#### Get Tenant Information |
| 108 | + |
| 109 | +**HTTP Method**: POST |
| 110 | +**Endpoint**: /tenant-info |
| 111 | +**Description**: Retrieves detailed information for a specific tenant CloudFormation deployment using the tenant's ID. |
| 112 | +**Request Body**: |
| 113 | + |
| 114 | +```json |
| 115 | +[ |
| 116 | + { |
| 117 | + "LogicalResourceId": "LambdaTenantSilo123456", |
| 118 | + "PhysicalResourceId": "12345678-1234-1234-1234-123456789100", |
| 119 | + "ResourceType": "AWS::Lambda::Function", |
| 120 | + "LastUpdatedTimestamp": "2000-01-01 00:00:00.000000+00:00", |
| 121 | + "ResourceStatus": "CREATE_COMPLETE", |
| 122 | + "DriftInformation": { "StackResourceDriftStatus": "NOT_CHECKED" } |
| 123 | + } |
| 124 | +] |
| 125 | +``` |
| 126 | + |
| 127 | + |
| 128 | +## Useful commands |
| 129 | + * `cdk synth` emits the synthesized CloudFormation template |
| 130 | + * `cdk deploy` deploy this stack to your default AWS account/region |
| 131 | + * `cdk destroy` destroy this stack and remove resources from your AWS account |
| 132 | + |
13 | 133 |
|
14 | 134 | ## License
|
15 | 135 |
|
16 |
| -This library is licensed under the MIT-0 License. See the LICENSE file. |
| 136 | +This library is licensed under the [MIT-0](https://github.com/aws/mit-0) license. For more details, please see [LICENSE](LICENSE) file |
| 137 | + |
| 138 | +## Legal disclaimer |
17 | 139 |
|
| 140 | +Sample code, software libraries, command line tools, proofs of concept, templates, or other related technology are provided as AWS Content or Third-Party Content under the AWS Customer Agreement, or the relevant written agreement between you and AWS (whichever applies). You should not use this AWS Content or Third-Party Content in your production accounts, or on production or other critical data. You are responsible for testing, securing, and optimizing the AWS Content or Third-Party Content, such as sample code, as appropriate for production grade use based on your specific quality control practices and standards. Deploying AWS Content or Third-Party Content may incur AWS charges for creating or using AWS chargeable resources, such as running Amazon EC2 instances or using Amazon S3 storage. |
0 commit comments