Skip to content

Commit 613e6ff

Browse files
authored
Merge pull request #66 from thand-io/docs-p11
Docs p11
2 parents 5aeba9f + c34f532 commit 613e6ff

19 files changed

Lines changed: 335 additions & 8 deletions

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ Thand Agent ──HTTPS──▶ Thand Server ──HTTPS──▶ Tha
5858

5959
### Option 1: Use Thand Cloud (SaaS)
6060

61-
Firstly, install the Thand agent on your local machine. You can do this via the install script:
61+
Firstly, install the Thand Agent on your local machine. You can do this via the install script:
6262

6363
```bash
6464
# Install agent (https://github.com/thand-io/agent/blob/main/scripts/install.sh). Trust but verify!

docs/Gemfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ gem "just-the-docs", "~> 0.7.0"
1111
group :jekyll_plugins do
1212
gem "jekyll-feed", "~> 0.15"
1313
gem "jekyll-sitemap", "~> 1.4"
14+
gem "jekyll-mermaid", "~> 1.0"
1415
end
1516

1617
# Fix for protobuf compatibility issues

docs/Gemfile.lock

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ GEM
3535
jekyll (>= 3.7, < 5.0)
3636
jekyll-include-cache (0.2.1)
3737
jekyll (>= 3.7, < 5.0)
38+
jekyll-mermaid (1.0.0)
3839
jekyll-sass-converter (3.1.0)
3940
sass-embedded (~> 1.75)
4041
jekyll-seo-tag (2.8.0)
@@ -82,6 +83,7 @@ DEPENDENCIES
8283
http_parser.rb (~> 0.6.0)
8384
jekyll (~> 4.3.2)
8485
jekyll-feed (~> 0.15)
86+
jekyll-mermaid (~> 1.0)
8587
jekyll-sitemap (~> 1.4)
8688
just-the-docs (~> 0.7.0)
8789
tzinfo (>= 1, < 3)

docs/_config.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ gh_edit_view_mode: "tree" # "tree" or "edit" if you want the user to jump into t
7575
plugins:
7676
- jekyll-feed
7777
- jekyll-sitemap
78+
- jekyll-mermaid
7879

7980
exclude:
8081
# from https://github.com/jekyll/jekyll/blob/master/lib/site_template/_config.yml:
Lines changed: 278 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,278 @@
1+
---
2+
layout: default
3+
title: App Runner
4+
parent: AWS
5+
grand_parent: Environments
6+
nav_order: 1
7+
description: "Setup guide for deploying Thand Agent on AWS App Runner"
8+
---
9+
10+
# App Runner Setup
11+
{: .no_toc }
12+
13+
Complete guide to deploying Thand Agent on AWS App Runner with IAM integration.
14+
{: .fs-6 .fw-300 }
15+
16+
## Table of contents
17+
{: .no_toc .text-delta }
18+
19+
## Prerequisites
20+
21+
- An AWS account with billing enabled.
22+
- Enable the following AWS services in your account:
23+
- AWS App Runner
24+
- Amazon Elastic Container Registry (ECR)
25+
- AWS Key Management Service (KMS)
26+
- AWS Secrets Manager
27+
- AWS CLI installed and configured with appropriate permissions
28+
29+
### Elastic Container Registry Setup
30+
31+
Before deploying your App Runner service, you need to set up an ECR repository to store your Thand Agent Docker images.
32+
33+
- Navigate to the [Amazon ECR console](https://console.aws.amazon.com/ecr/) in your AWS account.
34+
- Under **Private repositories**, click on "Create repository".
35+
- Provide a namespace name and repo name for your repository (e.g., `thand-io/agent`). To mirror the official Thand GHCR repository, you can use `thand-io/agent`.
36+
- Configure scan settings as desired (this may incur additional costs).
37+
- Click "Create repository".
38+
39+
Once created, you'll see the repository details page. Note the URI of your repository - you'll need this later. It should look like:
40+
`AWS_ACCOUNT_ID.dkr.ecr.REGION.amazonaws.com/thand-io/agent`
41+
42+
![Elastic Container Registry](step01.png)
43+
44+
As AWS ECR does not proxy images from external registries, you will need to push the Thand Agent image from GHCR to your ECR repository.
45+
46+
```bash
47+
# First pull the Thand Agent image from GHCR
48+
docker pull ghcr.io/thand-io/agent:latest
49+
50+
# Use the View push commands button in the ECR console to get the login command for your registry
51+
aws ecr get-login-password --region eu-central-1 | docker login --username AWS --password-stdin AWS_ACCOUNT_ID.dkr.ecr.REGION.amazonaws.com
52+
53+
# Tag the image for your ECR repository
54+
docker tag ghcr.io/thand-io/agent:latest AWS_ACCOUNT_ID.dkr.ecr.REGION.amazonaws.com/thand-io/agent:latest
55+
56+
# Push the image to your ECR repository
57+
docker push AWS_ACCOUNT_ID.dkr.ecr.REGION.amazonaws.com/thand-io/agent:latest
58+
```
59+
60+
### Setup App Runner Service
61+
62+
- Navigate to the [AWS App Runner console](https://console.aws.amazon.com/apprunner/) in your AWS account.
63+
- Click on "Create service".
64+
- Choose "Container registry" as the source.
65+
- For "Container image URI", enter your ECR repository URI followed by the tag (e.g., `AWS_ACCOUNT_ID.dkr.ecr.REGION.amazonaws.com/thand-io/agent:latest`).
66+
- Configure deployment settings:
67+
- Deployment trigger: "Manual" (you can change this to automatic later)
68+
- ECR access role: Create a new service role or use an existing one with ECR access
69+
- Click "Next".
70+
71+
{: .note}
72+
This will deploy your service and provide you with a URL to access it. Nothing has been configured yet. However, at this point it should be running. You will get unauthorized
73+
errors until you configure the agent with proper authentication.
74+
75+
### Enabling Encryption (AWS KMS)
76+
77+
To enable encryption with AWS KMS, you need to create a KMS key and configure the appropriate environment variables:
78+
79+
- Navigate to the [AWS KMS console](https://console.aws.amazon.com/kms/) in your AWS account.
80+
- Click on "Create key".
81+
- Choose "Symmetric" as the key type.
82+
- Choose "Encrypt and decrypt" as the key usage.
83+
- Choose "KMS" as the key material origin.
84+
- Click "Next".
85+
86+
![Elastic Container Registry](step02.png)
87+
88+
Configure the key details:
89+
- Add an alias for your key (e.g., `thand-agent`)
90+
- Add a description (e.g., "Encryption key for Thand Agent")
91+
- Click "Next".
92+
93+
Define key administrative permissions:
94+
- Select the IAM users and roles that can administer this key
95+
- Click "Next".
96+
97+
Define key usage permissions:
98+
- Select the IAM users and roles that can use this key for cryptographic operations
99+
- Make sure to include the App Runner instance role you created earlier
100+
- Click "Next".
101+
102+
![Elastic Container Registry](step03.png)
103+
104+
Review and create the key. **Note the key ARN - you'll need this for configuration.**
105+
106+
### Enabling Vault (AWS Secrets Manager)
107+
108+
Many of the providers supported by Thand that require API keys or secrets can be configured to use AWS Secrets Manager to store and retrieve these secrets securely.
109+
110+
This can either be done by configuring the provider to use Secrets Manager directly, or by configuring Thand to use Secrets Manager as its secret backend.
111+
112+
In this example, we will configure Thand to use Secrets Manager as its secret backend. We will create three secrets for our roles, providers, and workflows.
113+
114+
A default provider for AWS using the IAM role attached to the App Runner service would look something like this:
115+
116+
```yaml
117+
providers:
118+
aws:
119+
name: AWS Default
120+
description: Default AWS provider using IAM role
121+
provider: aws
122+
enabled: true
123+
config:
124+
region: us-east-1
125+
```
126+
127+
Create the secrets:
128+
129+
- Navigate to the [AWS Secrets Manager console](https://console.aws.amazon.com/secretsmanager/) in your AWS account.
130+
- Click on "Store a new secret".
131+
- Choose "Other type of secret".
132+
- Select "Plaintext" tab.
133+
- In the text area, provide your entire [provider](../../configuration/providers/) configuration in YAML or JSON format.
134+
- Click "Next".
135+
136+
Configure secret details:
137+
- Secret name: `thand-providers`
138+
- Description: "Thand Agent providers configuration"
139+
- Click "Next".
140+
141+
Configure rotation (optional):
142+
- For configuration secrets, rotation is typically not needed
143+
- Click "Next".
144+
145+
Review and store the secret.
146+
147+
Repeat the above steps to create two more secrets:
148+
- `thand-roles` - containing your [roles configuration](../../configuration/roles/)
149+
- `thand-workflows` - containing your [workflows configuration](../../configuration/workflows/)
150+
151+
Documentation for configuring providers, roles and workflows can be found in the [Configuration](../../configuration/) section.
152+
153+
![AWS Secrets Manager](step04.png)
154+
155+
You might also need to store other secrets depending on your provider configurations. Or other environment specific secrets you want to manage via Secrets Manager. Unfortunately, you will need to create a secret per environment variable.
156+
157+
Otherwise, you can provide your configuration via a mounted volume or other methods as described in the [Configuration](../../configuration/) section.
158+
159+
## IAM Role for App Runner
160+
161+
In order for your Thand Agent running on App Runner to access KMS and Secrets Manager, you need to create an IAM role with the appropriate permissions and attach it to your App Runner service.
162+
163+
- Navigate to the [IAM console](https://console.aws.amazon.com/iam/) in your AWS account.
164+
- Navigate to Roles and click "Create role".
165+
- Choose **Custom trust policy** and use the following trust relationship:
166+
167+
```json
168+
{
169+
"Version": "2012-10-17",
170+
"Statement": [
171+
{
172+
"Effect": "Allow",
173+
"Principal": {
174+
"Service": "tasks.apprunner.amazonaws.com"
175+
},
176+
"Action": "sts:AssumeRole"
177+
}
178+
]
179+
}
180+
```
181+
182+
- Click "Next".
183+
- Next add the following pre-defined permissions policies. Additionally add any other policies needed for your provider configurations. You can also define your own more restrictive policies as needed. However, for simplicity we will use pre-defined policies here:
184+
- `SecretsManagerReadWrite`
185+
- `AmazonSSMFullAccess`
186+
- `AmazonS3ReadOnlyAccess`
187+
- `AWSKeyManagementServicePowerUser`
188+
- `AWSSSOMasterAccountAdministrator` - if you plan to manage AWS SSO via Thand.
189+
- `IAMFullAccess` - if you plan to manage IAM roles via Thand.
190+
- Lastly, provide a role name (e.g., `ThandAppRunnerIamRole`) and description.
191+
- Click "Create role".
192+
193+
## Configure Thand App Runner Service
194+
195+
Now we've deployed all the necessary AWS resources, we need to configure our Thand Agent App Runner service to make use of them.
196+
197+
- Navigate to the AWS App Runner console. [AWS App Runner Console](https://console.aws.amazon.com/apprunner/)
198+
- Select your Thand Agent service.
199+
- Click on "Configuration" tab.
200+
- Click "Edit" in the "Configure service" section.
201+
202+
First, we need to update the instance resources to ensure the service has enough memory:
203+
- Under "Instance configuration", change the memory to at least 4 GB (2 vCPU, 4 GB memory recommended)
204+
205+
![Update App Memory](step05.png)
206+
207+
Next, Under **Runtime environment variables**, add the following:
208+
209+
| Variable Name | Description | Example Value |
210+
|----------------------------------|-----------------------------------------------------------------------------------------------|----------------------------------------------------|
211+
| `THAND_ENVIRONMENT_CONFIG_KMS_ARN` | Your KMS key ARN or alias | `arn:aws:kms:REGION:ACCOUNT_ID:key/KEY_ID` |
212+
| `THAND_ENVIRONMENT_CONFIG_REGION` | Your AWS region | `us-east-1` |
213+
| `THAND_LOGIN_ENDPOINT` | The endpoint for your deployed Thand Agent | `https://abc123.us-east-1.awsapprunner.com` |
214+
| `THAND_PROVIDERS_VAULT` | The name of the Secrets Manager secret containing your providers configuration | `thand-providers` |
215+
| `THAND_ROLES_VAULT` | The name of the Secrets Manager secret containing your roles configuration | `thand-roles` |
216+
| `THAND_WORKFLOWS_VAULT` | The name of the Secrets Manager secret containing your workflows configuration | `thand-workflows` |
217+
| `THAND_ENVIRONMENT_PLATFORM` | The environment platform for the Thand Agent | `aws` |
218+
219+
Your final environment variables should look something like this:
220+
221+
![Environment Variables](step06.png)
222+
223+
Lastly, under the **Security** section, ensure that the IAM role you created earlier (`ThandAppRunnerIamRole`) is selected as the instance role.
224+
225+
![Update App Memory](step07.png)
226+
227+
Click "Next" and then "Create & deploy" to create your App Runner service.
228+
229+
## Custom domain (Optional)
230+
231+
If you want to use a custom domain for your Thand Agent App Runner service, you can set it up as follows:
232+
233+
- Navigate to the AWS App Runner console.
234+
- Select your Thand Agent service.
235+
- Click on the "Configuration" tab.
236+
- Under the "Custom domain" section, click "Add custom domain".
237+
- Enter your custom domain name (e.g., `thand.example.com`).
238+
- Follow the instructions to verify domain ownership and configure DNS settings.
239+
240+
## Verification
241+
242+
Once the new deployment is complete, you can verify that the Thand Agent is correctly configured by accessing the App Runner service URL in your web browser.
243+
244+
You should see the Thand Agent interface indicating successful deployment.
245+
246+
You can then log in via the Thand CLI tool using the `--login-server` flag pointing to your App Runner service URL:
247+
248+
```bash
249+
thand login --login-server https://abc123.us-east-1.awsapprunner.com
250+
```
251+
252+
You can then query what roles you have access to:
253+
254+
```bash
255+
thand roles --login-server https://abc123.us-east-1.awsapprunner.com
256+
```
257+
258+
## Troubleshooting
259+
260+
If you encounter any issues, you can check the logs of your App Runner service:
261+
262+
- Navigate to the AWS App Runner console.
263+
- Select your Thand Agent service.
264+
- Click on the "Logs" tab to view the application logs.
265+
- Use CloudWatch Logs for more detailed log analysis if needed.
266+
267+
Common issues:
268+
- **Permission errors**: Ensure the instance role has the correct permissions for KMS and Secrets Manager
269+
- **Configuration errors**: Verify that the secret names and KMS key references are correct
270+
- **Network connectivity**: Check that your App Runner service can access AWS services (this should work by default)
271+
272+
## Security Considerations
273+
274+
- Use least-privilege IAM policies
275+
- Enable VPC connector if you need to access private resources
276+
- Consider using AWS WAF for additional protection
277+
- Regularly rotate secrets and review access logs
278+
- Enable CloudTrail for audit logging

docs/environments/aws/index.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,22 @@ description: "Setup guide for deploying Thand Server on AWS"
77
has_children: true
88
---
99

10+
# AWS Platform Setup
11+
{: .no_toc }
12+
13+
Complete guide to deploying Thand Agent on AWS with IAM integration.
14+
{: .fs-6 .fw-300 }
15+
16+
## Table of contents
17+
{: .no_toc .text-delta }
18+
19+
---
20+
21+
## Overview
22+
23+
This guide walks you through setting up Thand Agent on AWS, including:
24+
25+
- Creating the necessary AWS resources
26+
- Configuring IAM roles and service accounts
27+
- Deploying the Thand server on AWS
28+
- Setting up agent authentication

docs/environments/aws/step01.png

296 KB
Loading

docs/environments/aws/step02.png

349 KB
Loading

docs/environments/aws/step03.png

303 KB
Loading

docs/environments/aws/step04.png

230 KB
Loading

0 commit comments

Comments
 (0)