@aws/nx-plugin-mcp 1.5.0 → 1.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/aws-nx-mcp.js +254 -65
- package/docs/get_started/tutorials/dungeon-game/4.mdx +5 -1
- package/docs/get_started/tutorials/dungeon-game/greengrass-dice.mdx +290 -0
- package/docs/get_started/tutorials/dungeon-game/wrap-up.mdx +66 -3
- package/docs/get_started/tutorials/greengrass/1.mdx +116 -0
- package/docs/get_started/tutorials/greengrass/2.mdx +198 -0
- package/docs/get_started/tutorials/greengrass/3.mdx +131 -0
- package/docs/get_started/tutorials/greengrass/cleanup.mdx +137 -0
- package/docs/get_started/tutorials/greengrass/overview.mdx +65 -0
- package/docs/guides/connection/py-container-dynamodb.mdx +120 -0
- package/docs/guides/connection/py-container-rdb.mdx +153 -0
- package/docs/guides/connection/ts-agent-rdb.mdx +1 -1
- package/docs/guides/connection/ts-container-dynamodb.mdx +122 -0
- package/docs/guides/connection/ts-container-rdb.mdx +155 -0
- package/docs/guides/connection/ts-mcp-server-rdb.mdx +1 -1
- package/docs/guides/docker-bundling.mdx +6 -0
- package/docs/guides/greengrass-component.mdx +7 -1
- package/docs/guides/observability-langfuse.mdx +146 -0
- package/docs/guides/py-container.mdx +457 -0
- package/docs/guides/ts-container.mdx +457 -0
- package/docs/guides/ts-rdb.mdx +7 -1
- package/docs/snippets/connection/strands-agent-rdb-ssl-requirements.mdx +3 -28
- package/docs/snippets/connection/ts-mcp-server-rdb-ssl-requirements.mdx +3 -28
- package/generators.json +57 -1
- package/package.json +1 -1
- package/src/observability/langfuse/schema.json +38 -0
- package/src/py/container/schema.json +47 -0
- package/src/py/dynamodb/container-connection/schema.json +27 -0
- package/src/py/rdb/container-connection/schema.json +27 -0
- package/src/ts/container/schema.json +47 -0
- package/src/ts/dynamodb/container-connection/schema.json +27 -0
- package/src/ts/rdb/container-connection/schema.json +27 -0
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Python Container Service to Relational Database
|
|
3
|
+
description: Connect a Python container service to a Python Relational Database
|
|
4
|
+
when:
|
|
5
|
+
sourceType: py#container
|
|
6
|
+
targetType: py#rdb
|
|
7
|
+
---
|
|
8
|
+
import { FileTree } from '@astrojs/starlight/components';
|
|
9
|
+
import Link from '@components/link.astro';
|
|
10
|
+
import RunGenerator from '@components/run-generator.astro';
|
|
11
|
+
import GeneratorParameters from '@components/generator-parameters.astro';
|
|
12
|
+
import NxCommands from '@components/nx-commands.astro';
|
|
13
|
+
import Infrastructure from '@components/infrastructure.astro';
|
|
14
|
+
|
|
15
|
+
The `connection` generator lets a <Link path="guides/py-container">Python container service</Link> use a <Link path="guides/py-rdb">Python Relational Database</Link> project. It adds the database package as a dependency of the service's project, and prepares the service's Docker image for SSL connections to Amazon Aurora.
|
|
16
|
+
|
|
17
|
+
## How this works
|
|
18
|
+
|
|
19
|
+
A container service with `infra=ecs` runs as tasks on Amazon ECS (Elastic Container Service) in your VPC. Each task runs as the service's task role, an IAM role that can only read runtime configuration until you grant more, and sits in the service's security group, which allows outbound traffic on port 443 only. To use the database, the service needs two things that it does not have by default:
|
|
20
|
+
|
|
21
|
+
- IAM permission for `rds-db:connect`, so it can sign in to the database with IAM authentication.
|
|
22
|
+
- A security group rule pair on the database port: an inbound rule on the database's security group, and an outbound rule on the service's security group. Without the outbound rule the service cannot reach the database, because its security group allows only port 443 out.
|
|
23
|
+
|
|
24
|
+
The generator rejects a service with `infra=none`, because such a service has no task role to grant access to.
|
|
25
|
+
|
|
26
|
+
## Prerequisites
|
|
27
|
+
|
|
28
|
+
Before using this generator, ensure you have:
|
|
29
|
+
|
|
30
|
+
1. A container service with `infra=ecs` (generated using the <Link path="guides/py-container">`py#container`</Link> generator)
|
|
31
|
+
2. A <Link path="guides/py-rdb">`py#rdb`</Link> project
|
|
32
|
+
|
|
33
|
+
## Usage
|
|
34
|
+
|
|
35
|
+
### Run the Generator
|
|
36
|
+
|
|
37
|
+
<RunGenerator generator="connection" />
|
|
38
|
+
|
|
39
|
+
Select the project containing your container service as the source and your relational database project as the target. If the source project holds several components, set `sourceComponent` to the service's name.
|
|
40
|
+
|
|
41
|
+
### Options
|
|
42
|
+
|
|
43
|
+
<GeneratorParameters generator="connection" />
|
|
44
|
+
|
|
45
|
+
## Generator Output
|
|
46
|
+
|
|
47
|
+
<FileTree>
|
|
48
|
+
|
|
49
|
+
- packages/my\_project
|
|
50
|
+
- project.json Adds a dependency from `my-service-serve` on the database's `dev` target
|
|
51
|
+
- pyproject.toml Adds the database package as a workspace dependency
|
|
52
|
+
- my\_project
|
|
53
|
+
- my\_service
|
|
54
|
+
- Dockerfile Installs the Amazon RDS CA bundle for SSL connections to Aurora
|
|
55
|
+
|
|
56
|
+
</FileTree>
|
|
57
|
+
|
|
58
|
+
## Using the Database in the Service
|
|
59
|
+
|
|
60
|
+
Import `session_context` from your database package and use it where you handle a request:
|
|
61
|
+
|
|
62
|
+
```python title="packages/my_project/my_project/my_service/orders.py"
|
|
63
|
+
from sqlmodel import select
|
|
64
|
+
from my_scope_my_database import session_context
|
|
65
|
+
from my_scope_my_database.models.example import ExampleModel
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
async def list_examples() -> list[dict]:
|
|
69
|
+
async with session_context() as session:
|
|
70
|
+
items = (await session.execute(select(ExampleModel))).scalars().all()
|
|
71
|
+
return [item.model_dump() for item in items]
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
The database package reads the database's connection details from <Link path="guides/runtime-config">runtime configuration</Link>, using the `RUNTIME_CONFIG_APP_ID` environment variable.
|
|
75
|
+
|
|
76
|
+
The generated container service sets `RUNTIME_CONFIG_APP_ID` and grants its task role read access to runtime configuration, so you do not add either yourself. In Terraform, the service's module block must pass `appconfig_application_id` and `appconfig_application_arn`, as shown in the <Link path="guides/py-container">container guide</Link>.
|
|
77
|
+
|
|
78
|
+
## Infrastructure
|
|
79
|
+
|
|
80
|
+
The generator does not change your stack or root Terraform module. Instead it prints the code to add, which is shown below for a service named `my-service` and a database named `my-database`. Until you add it, the service cannot reach the database port and the database refuses its IAM authentication.
|
|
81
|
+
|
|
82
|
+
<Infrastructure>
|
|
83
|
+
<Fragment slot="cdk">
|
|
84
|
+
|
|
85
|
+
In the example, `myService` is your `MyService` construct and `myDatabase` is your `MyDatabase` construct:
|
|
86
|
+
|
|
87
|
+
```ts title="packages/infra/src/stacks/application-stack.ts"
|
|
88
|
+
myDatabase.allowDefaultPortFrom(myService);
|
|
89
|
+
myDatabase.grantConnect(myService.taskRole);
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
`allowDefaultPortFrom` adds the inbound rule on the database's security group and the outbound rule on the service's security group. `grantConnect` grants `rds-db:connect` to the service's task role.
|
|
93
|
+
|
|
94
|
+
</Fragment>
|
|
95
|
+
<Fragment slot="terraform">
|
|
96
|
+
|
|
97
|
+
In the example, `module "my_service"` deploys the service and `module "my_database"` deploys the database. The `data "aws_region" "current"` and `data "aws_caller_identity" "current"` data sources are declared in the generated `providers.tf`:
|
|
98
|
+
|
|
99
|
+
```hcl title="packages/infra/src/main.tf"
|
|
100
|
+
resource "aws_iam_role_policy" "my_service_my_database_connect" {
|
|
101
|
+
name = "my-service-my-database-connect"
|
|
102
|
+
role = module.my_service.task_role_name
|
|
103
|
+
|
|
104
|
+
policy = jsonencode({
|
|
105
|
+
Version = "2012-10-17"
|
|
106
|
+
Statement = [
|
|
107
|
+
{
|
|
108
|
+
Effect = "Allow"
|
|
109
|
+
Action = ["rds-db:connect"]
|
|
110
|
+
Resource = ["arn:aws:rds-db:${data.aws_region.current.region}:${data.aws_caller_identity.current.account_id}:dbuser:${module.my_database.connect_resource_id}/${module.my_database.database_runtime_user}"]
|
|
111
|
+
},
|
|
112
|
+
]
|
|
113
|
+
})
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
resource "aws_vpc_security_group_ingress_rule" "my_service_to_my_database" {
|
|
117
|
+
description = "Allow the my-service container service to connect to the database"
|
|
118
|
+
security_group_id = module.my_database.security_group_id
|
|
119
|
+
referenced_security_group_id = module.my_service.security_group_id
|
|
120
|
+
from_port = module.my_database.cluster_port
|
|
121
|
+
to_port = module.my_database.cluster_port
|
|
122
|
+
ip_protocol = "tcp"
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
resource "aws_vpc_security_group_egress_rule" "my_service_to_my_database" {
|
|
126
|
+
description = "Allow the my-service container service to reach the database"
|
|
127
|
+
security_group_id = module.my_service.security_group_id
|
|
128
|
+
referenced_security_group_id = module.my_database.security_group_id
|
|
129
|
+
from_port = module.my_database.cluster_port
|
|
130
|
+
to_port = module.my_database.cluster_port
|
|
131
|
+
ip_protocol = "tcp"
|
|
132
|
+
}
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
</Fragment>
|
|
136
|
+
</Infrastructure>
|
|
137
|
+
|
|
138
|
+
### SSL Requirements When Connecting Without RDS Proxy
|
|
139
|
+
|
|
140
|
+
When the service connects to the Aurora cluster directly, without RDS Proxy, it must trust the Amazon RDS certificate authority. The generator adds these lines to the service's Dockerfile, before its `EXPOSE` line, to install the Amazon RDS CA bundle into the system trust store:
|
|
141
|
+
|
|
142
|
+
```dockerfile
|
|
143
|
+
ADD https://truststore.pki.rds.amazonaws.com/global/global-bundle.pem /usr/local/share/ca-certificates/rds-global-bundle.crt
|
|
144
|
+
RUN update-ca-certificates
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
When using RDS Proxy, you do not need the RDS CA bundle.
|
|
148
|
+
|
|
149
|
+
## Local Development
|
|
150
|
+
|
|
151
|
+
<NxCommands commands={["<service-name>-serve <project-name>"]} />
|
|
152
|
+
|
|
153
|
+
This starts the service and the database's local Docker database. With `LOCAL_DEV=true` set, the database client connects to the local database instead of Aurora.
|
|
@@ -42,7 +42,7 @@ The generator modifies the following files in your agent's source directory:
|
|
|
42
42
|
|
|
43
43
|
- packages/my-service/src/my-agent
|
|
44
44
|
- agent.ts Prisma client fetched inside `getAgent` and available to tools
|
|
45
|
-
- Dockerfile RDS CA bundle installed for SSL connections to Aurora (only when the agent's `infra` is `agentcore-ecr`)
|
|
45
|
+
- Dockerfile RDS CA bundle installed and `NODE_EXTRA_CA_CERTS` set for SSL connections to Aurora (only when the agent's `infra` is `agentcore-ecr`)
|
|
46
46
|
|
|
47
47
|
</FileTree>
|
|
48
48
|
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: TypeScript Container Service to DynamoDB
|
|
3
|
+
description: Connect a TypeScript container service to a TypeScript DynamoDB project
|
|
4
|
+
when:
|
|
5
|
+
sourceType: ts#container
|
|
6
|
+
targetType: ts#dynamodb
|
|
7
|
+
---
|
|
8
|
+
import Link from '@components/link.astro';
|
|
9
|
+
import RunGenerator from '@components/run-generator.astro';
|
|
10
|
+
import GeneratorParameters from '@components/generator-parameters.astro';
|
|
11
|
+
import NxCommands from '@components/nx-commands.astro';
|
|
12
|
+
import Infrastructure from '@components/infrastructure.astro';
|
|
13
|
+
|
|
14
|
+
The `connection` generator lets a <Link path="guides/ts-container">TypeScript container service</Link> use a <Link path="guides/ts-dynamodb">TypeScript DynamoDB</Link> project. It configures local development so the service and DynamoDB Local start together, and prints the grants the service needs.
|
|
15
|
+
|
|
16
|
+
## How this works
|
|
17
|
+
|
|
18
|
+
A container service with `infra=ecs` runs as tasks on Amazon ECS (Elastic Container Service). Each task runs as the service's task role, an IAM role that can only read runtime configuration until you grant more. To read and write the table, the task role needs the DynamoDB actions on the table and its indexes, and use of the table's AWS KMS encryption key.
|
|
19
|
+
|
|
20
|
+
The generator rejects a service with `infra=none`, because such a service has no task role to grant access to.
|
|
21
|
+
|
|
22
|
+
## Prerequisites
|
|
23
|
+
|
|
24
|
+
Before using this generator, ensure you have:
|
|
25
|
+
|
|
26
|
+
1. A container service with `infra=ecs` (generated using the <Link path="guides/ts-container">`ts#container`</Link> generator)
|
|
27
|
+
2. A <Link path="guides/ts-dynamodb">`ts#dynamodb`</Link> project
|
|
28
|
+
|
|
29
|
+
## Usage
|
|
30
|
+
|
|
31
|
+
### Run the Generator
|
|
32
|
+
|
|
33
|
+
<RunGenerator generator="connection" />
|
|
34
|
+
|
|
35
|
+
Select the project containing your container service as the source and your DynamoDB project as the target. If the source project holds several components, set `sourceComponent` to the service's name.
|
|
36
|
+
|
|
37
|
+
### Options
|
|
38
|
+
|
|
39
|
+
<GeneratorParameters generator="connection" />
|
|
40
|
+
|
|
41
|
+
## Generator Output
|
|
42
|
+
|
|
43
|
+
The generator updates the service's `<service-name>-serve` target in `project.json` to depend on the DynamoDB project's `dev` target. No source files are modified.
|
|
44
|
+
|
|
45
|
+
## Using DynamoDB in the Service
|
|
46
|
+
|
|
47
|
+
Import entity factories from the DynamoDB package and use them where you handle a request:
|
|
48
|
+
|
|
49
|
+
```ts title="packages/my-project/src/my-service/examples.ts"
|
|
50
|
+
import { createExampleEntity } from '@my-scope/my-table';
|
|
51
|
+
|
|
52
|
+
export const listExamples = async () => {
|
|
53
|
+
const entity = await createExampleEntity();
|
|
54
|
+
const result = await entity.scan.go();
|
|
55
|
+
return result.data;
|
|
56
|
+
};
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
## Infrastructure
|
|
60
|
+
|
|
61
|
+
The generator does not change your stack or root Terraform module. Instead it prints the code to add, which is shown below for a service named `my-service` and a table named `my-table`. Until you add it, the service's requests to the table are denied.
|
|
62
|
+
|
|
63
|
+
<Infrastructure>
|
|
64
|
+
<Fragment slot="cdk">
|
|
65
|
+
|
|
66
|
+
In the example, `myService` is your `MyService` construct and `myTable` is your `MyTable` construct:
|
|
67
|
+
|
|
68
|
+
```ts title="packages/infra/src/stacks/application-stack.ts"
|
|
69
|
+
myTable.grantReadWriteData(myService.taskRole);
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
`grantReadWriteData` grants both the DynamoDB and the KMS permissions to the service's task role.
|
|
73
|
+
|
|
74
|
+
</Fragment>
|
|
75
|
+
<Fragment slot="terraform">
|
|
76
|
+
|
|
77
|
+
In the example, `module "my_service"` deploys the service and `module "my_table"` deploys the table:
|
|
78
|
+
|
|
79
|
+
```hcl title="packages/infra/src/main.tf"
|
|
80
|
+
resource "aws_iam_role_policy" "my_service_my_table_access" {
|
|
81
|
+
name = "my-service-my-table-access"
|
|
82
|
+
role = module.my_service.task_role_name
|
|
83
|
+
|
|
84
|
+
policy = jsonencode({
|
|
85
|
+
Version = "2012-10-17"
|
|
86
|
+
Statement = [
|
|
87
|
+
{
|
|
88
|
+
Effect = "Allow"
|
|
89
|
+
Action = [
|
|
90
|
+
"dynamodb:GetItem", "dynamodb:PutItem", "dynamodb:UpdateItem",
|
|
91
|
+
"dynamodb:DeleteItem", "dynamodb:Query", "dynamodb:Scan",
|
|
92
|
+
"dynamodb:BatchGetItem", "dynamodb:BatchWriteItem",
|
|
93
|
+
]
|
|
94
|
+
Resource = [
|
|
95
|
+
module.my_table.table_arn,
|
|
96
|
+
"${module.my_table.table_arn}/index/*",
|
|
97
|
+
]
|
|
98
|
+
},
|
|
99
|
+
{
|
|
100
|
+
Effect = "Allow"
|
|
101
|
+
Action = [
|
|
102
|
+
"kms:Encrypt",
|
|
103
|
+
"kms:Decrypt",
|
|
104
|
+
"kms:ReEncrypt*",
|
|
105
|
+
"kms:GenerateDataKey*",
|
|
106
|
+
"kms:DescribeKey",
|
|
107
|
+
]
|
|
108
|
+
Resource = [module.my_table.kms_key_arn]
|
|
109
|
+
},
|
|
110
|
+
]
|
|
111
|
+
})
|
|
112
|
+
}
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
</Fragment>
|
|
116
|
+
</Infrastructure>
|
|
117
|
+
|
|
118
|
+
## Local Development
|
|
119
|
+
|
|
120
|
+
<NxCommands commands={["<service-name>-serve <project-name>"]} />
|
|
121
|
+
|
|
122
|
+
This starts the service and DynamoDB Local. With `LOCAL_DEV=true` set, `getDynamoDBClient()` and `resolveTableName()` connect to DynamoDB Local instead of AWS.
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: TypeScript Container Service to Relational Database
|
|
3
|
+
description: Connect a TypeScript container service to a Relational Database
|
|
4
|
+
when:
|
|
5
|
+
sourceType: ts#container
|
|
6
|
+
targetType: ts#rdb
|
|
7
|
+
---
|
|
8
|
+
import { FileTree } from '@astrojs/starlight/components';
|
|
9
|
+
import Link from '@components/link.astro';
|
|
10
|
+
import RunGenerator from '@components/run-generator.astro';
|
|
11
|
+
import GeneratorParameters from '@components/generator-parameters.astro';
|
|
12
|
+
import NxCommands from '@components/nx-commands.astro';
|
|
13
|
+
import Infrastructure from '@components/infrastructure.astro';
|
|
14
|
+
|
|
15
|
+
The `connection` generator lets a <Link path="guides/ts-container">TypeScript container service</Link> use a <Link path="guides/ts-rdb">Relational Database</Link> project. It adds a module that returns the database's Prisma client, and prepares the service's Docker image for SSL connections to Amazon Aurora.
|
|
16
|
+
|
|
17
|
+
## How this works
|
|
18
|
+
|
|
19
|
+
A container service with `infra=ecs` runs as tasks on Amazon ECS (Elastic Container Service) in your VPC. Each task runs as the service's task role, an IAM role that can only read runtime configuration until you grant more, and sits in the service's security group, which allows outbound traffic on port 443 only. To use the database, the service needs two things that it does not have by default:
|
|
20
|
+
|
|
21
|
+
- IAM permission for `rds-db:connect`, so it can sign in to the database with IAM authentication.
|
|
22
|
+
- A security group rule pair on the database port: an inbound rule on the database's security group, and an outbound rule on the service's security group. Without the outbound rule the service cannot reach the database, because its security group allows only port 443 out.
|
|
23
|
+
|
|
24
|
+
The generator rejects a service with `infra=none`, because such a service has no task role to grant access to.
|
|
25
|
+
|
|
26
|
+
## Prerequisites
|
|
27
|
+
|
|
28
|
+
Before using this generator, ensure you have:
|
|
29
|
+
|
|
30
|
+
1. A container service with `infra=ecs` (generated using the <Link path="guides/ts-container">`ts#container`</Link> generator)
|
|
31
|
+
2. A <Link path="guides/ts-rdb">`ts#rdb`</Link> project
|
|
32
|
+
|
|
33
|
+
## Usage
|
|
34
|
+
|
|
35
|
+
### Run the Generator
|
|
36
|
+
|
|
37
|
+
<RunGenerator generator="connection" />
|
|
38
|
+
|
|
39
|
+
Select the project containing your container service as the source and your relational database project as the target. If the source project holds several components, set `sourceComponent` to the service's name.
|
|
40
|
+
|
|
41
|
+
### Options
|
|
42
|
+
|
|
43
|
+
<GeneratorParameters generator="connection" />
|
|
44
|
+
|
|
45
|
+
## Generator Output
|
|
46
|
+
|
|
47
|
+
The generator changes the following files in your service's source directory:
|
|
48
|
+
|
|
49
|
+
<FileTree>
|
|
50
|
+
|
|
51
|
+
- packages/my-project/src/my-service
|
|
52
|
+
- my-database.ts Exports `getMyDatabase`, which returns the database's Prisma client
|
|
53
|
+
- Dockerfile Installs the Amazon RDS CA bundle for SSL connections to Aurora
|
|
54
|
+
|
|
55
|
+
</FileTree>
|
|
56
|
+
|
|
57
|
+
Additionally, the service's `<service-name>-serve` target is updated to depend on the database's `dev` target.
|
|
58
|
+
|
|
59
|
+
## Using the Database in the Service
|
|
60
|
+
|
|
61
|
+
Import the getter in your service's code and call it where you handle a request:
|
|
62
|
+
|
|
63
|
+
```ts title="packages/my-project/src/my-service/orders.ts"
|
|
64
|
+
import { getMyDatabase } from './my-database.js';
|
|
65
|
+
|
|
66
|
+
export const listOrders = async () => {
|
|
67
|
+
const myDatabase = await getMyDatabase();
|
|
68
|
+
return myDatabase.order.findMany();
|
|
69
|
+
};
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
The database client reads the database's connection details from <Link path="guides/runtime-config">runtime configuration</Link>, using the `RUNTIME_CONFIG_APP_ID` environment variable.
|
|
73
|
+
|
|
74
|
+
The generated container service sets `RUNTIME_CONFIG_APP_ID` and grants its task role read access to runtime configuration, so you do not add either yourself. In Terraform, the service's module block must pass `appconfig_application_id` and `appconfig_application_arn`, as shown in the <Link path="guides/ts-container">container guide</Link>.
|
|
75
|
+
|
|
76
|
+
## Infrastructure
|
|
77
|
+
|
|
78
|
+
The generator does not change your stack or root Terraform module. Instead it prints the code to add, which is shown below for a service named `my-service` and a database named `my-database`. Until you add it, the service cannot reach the database port and the database refuses its IAM authentication.
|
|
79
|
+
|
|
80
|
+
<Infrastructure>
|
|
81
|
+
<Fragment slot="cdk">
|
|
82
|
+
|
|
83
|
+
In the example, `myService` is your `MyService` construct and `myDatabase` is your `MyDatabase` construct:
|
|
84
|
+
|
|
85
|
+
```ts title="packages/infra/src/stacks/application-stack.ts"
|
|
86
|
+
myDatabase.allowDefaultPortFrom(myService);
|
|
87
|
+
myDatabase.grantConnect(myService.taskRole);
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
`allowDefaultPortFrom` adds the inbound rule on the database's security group and the outbound rule on the service's security group. `grantConnect` grants `rds-db:connect` to the service's task role.
|
|
91
|
+
|
|
92
|
+
</Fragment>
|
|
93
|
+
<Fragment slot="terraform">
|
|
94
|
+
|
|
95
|
+
In the example, `module "my_service"` deploys the service and `module "my_database"` deploys the database. The `data "aws_region" "current"` and `data "aws_caller_identity" "current"` data sources are declared in the generated `providers.tf`:
|
|
96
|
+
|
|
97
|
+
```hcl title="packages/infra/src/main.tf"
|
|
98
|
+
resource "aws_iam_role_policy" "my_service_my_database_connect" {
|
|
99
|
+
name = "my-service-my-database-connect"
|
|
100
|
+
role = module.my_service.task_role_name
|
|
101
|
+
|
|
102
|
+
policy = jsonencode({
|
|
103
|
+
Version = "2012-10-17"
|
|
104
|
+
Statement = [
|
|
105
|
+
{
|
|
106
|
+
Effect = "Allow"
|
|
107
|
+
Action = ["rds-db:connect"]
|
|
108
|
+
Resource = ["arn:aws:rds-db:${data.aws_region.current.region}:${data.aws_caller_identity.current.account_id}:dbuser:${module.my_database.connect_resource_id}/${module.my_database.database_runtime_user}"]
|
|
109
|
+
},
|
|
110
|
+
]
|
|
111
|
+
})
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
resource "aws_vpc_security_group_ingress_rule" "my_service_to_my_database" {
|
|
115
|
+
description = "Allow the my-service container service to connect to the database"
|
|
116
|
+
security_group_id = module.my_database.security_group_id
|
|
117
|
+
referenced_security_group_id = module.my_service.security_group_id
|
|
118
|
+
from_port = module.my_database.cluster_port
|
|
119
|
+
to_port = module.my_database.cluster_port
|
|
120
|
+
ip_protocol = "tcp"
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
resource "aws_vpc_security_group_egress_rule" "my_service_to_my_database" {
|
|
124
|
+
description = "Allow the my-service container service to reach the database"
|
|
125
|
+
security_group_id = module.my_service.security_group_id
|
|
126
|
+
referenced_security_group_id = module.my_database.security_group_id
|
|
127
|
+
from_port = module.my_database.cluster_port
|
|
128
|
+
to_port = module.my_database.cluster_port
|
|
129
|
+
ip_protocol = "tcp"
|
|
130
|
+
}
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
</Fragment>
|
|
134
|
+
</Infrastructure>
|
|
135
|
+
|
|
136
|
+
### SSL Requirements When Connecting Without RDS Proxy
|
|
137
|
+
|
|
138
|
+
When the service connects to the Aurora cluster directly, without RDS Proxy, Node.js must trust the Amazon RDS certificate authority. The generator adds this step to the service's Dockerfile, before its `EXPOSE` line:
|
|
139
|
+
|
|
140
|
+
```dockerfile
|
|
141
|
+
RUN apt-get update && apt-get install -y --no-install-recommends curl ca-certificates && \
|
|
142
|
+
rm -rf /var/lib/apt/lists/* && \
|
|
143
|
+
curl -fsSL "https://truststore.pki.rds.amazonaws.com/global/global-bundle.pem" \
|
|
144
|
+
-o /usr/local/share/ca-certificates/rds-bundle.crt && \
|
|
145
|
+
update-ca-certificates
|
|
146
|
+
ENV NODE_EXTRA_CA_CERTS=/usr/local/share/ca-certificates/rds-bundle.crt
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
`update-ca-certificates` writes the system certificate store, which Node.js does not read, so the generator also sets `NODE_EXTRA_CA_CERTS` in the Dockerfile. You do not need to configure it yourself, and with RDS Proxy it is unused. For more details, see the [Amazon RDS SSL/TLS documentation](https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/UsingWithRDS.SSL.html).
|
|
150
|
+
|
|
151
|
+
## Local Development
|
|
152
|
+
|
|
153
|
+
<NxCommands commands={["<service-name>-serve <project-name>"]} />
|
|
154
|
+
|
|
155
|
+
This starts the service and the database's local Docker database. With `LOCAL_DEV=true` set, the Prisma client connects to the local database instead of Aurora.
|
|
@@ -42,7 +42,7 @@ The generator modifies the following files in your MCP server's source directory
|
|
|
42
42
|
|
|
43
43
|
- packages/my-service/src/my-mcp
|
|
44
44
|
- server.ts Prisma client fetched and available to all tools registered inside `createServer`
|
|
45
|
-
- Dockerfile RDS CA bundle installed for SSL connections to Aurora (only when the MCP server's `infra` is `agentcore-ecr`)
|
|
45
|
+
- Dockerfile RDS CA bundle installed and `NODE_EXTRA_CA_CERTS` set for SSL connections to Aurora (only when the MCP server's `infra` is `agentcore-ecr`)
|
|
46
46
|
|
|
47
47
|
</FileTree>
|
|
48
48
|
|
|
@@ -34,6 +34,8 @@ export const trivyTarget = `{
|
|
|
34
34
|
|
|
35
35
|
Several generators (such as <Link path="/guides/ts-agent">`ts#agent`</Link> and <Link path="/guides/py-agent">`py#agent`</Link>) produce a Docker image that is pushed to Amazon ECR and consumed by AWS infrastructure. This guide describes the pattern they follow so that you can apply it to other use cases — for example, running a <Link path="/guides/fastapi">FastAPI</Link> project on Amazon ECS, or deploying a containerised Express server.
|
|
36
36
|
|
|
37
|
+
To run a containerised service privately on Amazon ECS without wiring this pattern yourself, use <Link path="/guides/ts-container">`ts#container`</Link> or <Link path="/guides/py-container">`py#container`</Link>.
|
|
38
|
+
|
|
37
39
|
:::tip[Docker or Finch]
|
|
38
40
|
The container engine used to build images is chosen at workspace creation time via the `--containers` flag (`docker`, `finch`, or `infer` — the default — which auto-detects what's installed). [Finch](https://runfinch.com/) is an open-source, drop-in alternative to Docker. The selection is recorded in `aws-nx-plugin.config.mts` and applied to every generator that emits container build commands. CDK image asset builds honour the choice via the `CDK_DOCKER` environment variable.
|
|
39
41
|
:::
|
|
@@ -397,6 +399,8 @@ CDK does not run the `bundle`/`docker` targets automatically — you must run `n
|
|
|
397
399
|
:::
|
|
398
400
|
|
|
399
401
|
Use the `DockerImageAsset` with any AWS construct that accepts a container image, for example `aws_ecs.ContainerImage.fromDockerImageAsset(image)`.
|
|
402
|
+
|
|
403
|
+
<Link path="/guides/ts-container">`ts#container`</Link> and <Link path="/guides/py-container">`py#container`</Link> use this pattern to run their image as an Amazon ECS service.
|
|
400
404
|
</Fragment>
|
|
401
405
|
<Fragment slot="terraform">
|
|
402
406
|
Terraform's AWS provider does not have a first-class "build and push a Docker image" resource. The pattern used by the generators is:
|
|
@@ -406,6 +410,8 @@ Terraform's AWS provider does not have a first-class "build and push a Docker im
|
|
|
406
410
|
3. A `null_resource` with a `local-exec` provisioner that authenticates to ECR, re-tags the locally-built image with its content digest, and pushes it.
|
|
407
411
|
4. The downstream resource (e.g. `aws_ecs_task_definition`) references the image by its immutable, digest-based tag.
|
|
408
412
|
|
|
413
|
+
<Link path="/guides/ts-container">`ts#container`</Link> and <Link path="/guides/py-container">`py#container`</Link> use this pattern in their Terraform module to run their image as an Amazon ECS service.
|
|
414
|
+
|
|
409
415
|
Because one repository holds every image, each tag is namespaced by the image's owner as well as its digest, so images sharing the registry never collide.
|
|
410
416
|
|
|
411
417
|
```d2
|
|
@@ -632,7 +632,9 @@ The recipe grants `aws.greengrass#PublishToTopic` on
|
|
|
632
632
|
reaches other components on the same core device, not AWS IoT Core. To publish
|
|
633
633
|
to AWS IoT Core, call `publish_to_iot_core`, grant
|
|
634
634
|
`aws.greengrass#PublishToIoTCore` under `aws.greengrass.ipc.mqttproxy` in the
|
|
635
|
-
recipe, and give the device's IoT policy `iot:Publish` on the exact topic.
|
|
635
|
+
recipe, and give the device's IoT policy `iot:Publish` on the exact topic. The
|
|
636
|
+
<Link path="get_started/tutorials/greengrass/overview">tutorial</Link> shows
|
|
637
|
+
that flow end to end.
|
|
636
638
|
</TabItem>
|
|
637
639
|
<TabItem label="TypeScript" _filter={{ language: 'typescript' }}>
|
|
638
640
|
With the default `ipc: false`, `main.ts` logs a line every 30 seconds and the
|
|
@@ -767,3 +769,7 @@ Greengrass limits one component to 5,000 versions per Region and
|
|
|
767
769
|
limited to 16 KB, and a deployment document to 31 KB for a thing group or 7 KB
|
|
768
770
|
for a single thing. Avoid using new versions as heartbeats and split large
|
|
769
771
|
deployments into smaller batches.
|
|
772
|
+
|
|
773
|
+
## Next steps
|
|
774
|
+
|
|
775
|
+
- <Link path="get_started/tutorials/greengrass/overview">Greengrass MQTT tutorial</Link>: Python, CDK, an EC2 core device, a cloud MQTT heartbeat, and a `NEXT_PATCH` update.
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Langfuse Observability
|
|
3
|
+
description: Export an existing Python Strands agent's application traces to Langfuse
|
|
4
|
+
generator: observability#langfuse
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
import RunGenerator from '@components/run-generator.astro';
|
|
8
|
+
import GeneratorParameters from '@components/generator-parameters.astro';
|
|
9
|
+
import Link from '@components/link.astro';
|
|
10
|
+
|
|
11
|
+
Add Langfuse trace viewing to an existing `py#agent`, both during local development and after deployment. This experimental component generator supports **Python Strands, HTTP, AgentCore zip deployment (`infra: agentcore`), CDK, and IAM authentication**. It preserves the agent's model, tools, and configured session storage.
|
|
12
|
+
|
|
13
|
+
Other languages, frameworks, protocols, MCP servers, containers, Terraform, and `infra: none` are rejected. Langfuse export selects AgentCore platform V1 and fails CDK validation for V2: credentials and exporter connections must not be captured in an unqualified startup snapshot. The generator does not deploy Langfuse or create a secret.
|
|
14
|
+
|
|
15
|
+
Existing agents continue using their generated tracing setup unless you run this generator. Langfuse starts on the next local `dev` run; deployed agents switch after you rebuild and redeploy. As an experimental generator, its output may change without an upgrade migration; users must review and reconcile those changes themselves.
|
|
16
|
+
|
|
17
|
+
## CloudWatch implications
|
|
18
|
+
|
|
19
|
+
:::caution[Application traces move to Langfuse]
|
|
20
|
+
For deployed agents, enabling Langfuse disables ADOT and changes the zip entrypoint. **New application spans from the agent, model calls, and tools go to Langfuse instead of CloudWatch.** They disappear from CloudWatch GenAI Observability and Transaction Search. **Dual export is not supported.** Local invocations also export to Langfuse; their stdout/stderr stays in the local terminal.
|
|
21
|
+
:::
|
|
22
|
+
|
|
23
|
+
| Signal or feature | Effect with Langfuse enabled |
|
|
24
|
+
| --- | --- |
|
|
25
|
+
| Agent/model/tool application spans | Exported to Langfuse. These spans are no longer delivered to `aws/spans` or the runtime's application spans stream. |
|
|
26
|
+
| Runtime service metrics | Invocations, Latency, UserErrors, and SystemErrors remain available in CloudWatch. |
|
|
27
|
+
| Agent stdout/stderr | Uvicorn logs and application output still go to the runtime's CloudWatch log group. Prompts or tool results printed by your app can therefore remain in AWS logs too. |
|
|
28
|
+
| ADOT structured telemetry logs | Disabled with ADOT. Ordinary application logs continue independently. Restoring ADOT restores its structured telemetry logs. |
|
|
29
|
+
| Separately delivered AgentCore service spans | Not redirected by this application exporter. Check the separate delivery configuration for Memory, Gateway, Identity, and built-in tools; this integration does not configure or guarantee their delivery. |
|
|
30
|
+
| AgentCore Evaluations | CloudWatch-backed online/batch evaluation and `CloudWatchAgentSpanCollector` lose new application spans for this agent. The on-demand Evaluate API can accept caller-supplied spans, but this generator supplies no replacement collector. |
|
|
31
|
+
| Application tests, dashboards, and evaluation jobs | Generated application tests do not require CloudWatch traces. Any dashboards, alarms, or evaluation jobs that read application spans from CloudWatch lose those new spans. Check the trace source used by each integration before enabling Langfuse. |
|
|
32
|
+
|
|
33
|
+
See AWS's [supported evaluation telemetry](https://docs.aws.amazon.com/bedrock-agentcore/latest/devguide/supported-frameworks-telemetry.html) and [observability configuration](https://docs.aws.amazon.com/bedrock-agentcore/latest/devguide/observability-configure.html) for service delivery and evaluation requirements.
|
|
34
|
+
|
|
35
|
+
### Data residency and cost
|
|
36
|
+
|
|
37
|
+
Prompts, completions, model usage, and tool inputs/outputs from **local and deployed invocations** are sent to the configured Langfuse endpoint. With Langfuse Cloud, this data leaves your laptop or AWS environment for a third-party service. With self-hosted Langfuse, it goes to the host you select. Check that endpoint, region, retention, and access controls against your data-handling requirements before enabling export. This generator does not redact trace content.
|
|
38
|
+
|
|
39
|
+
CloudWatch/X-Ray usage charges associated with the switched-off application traces decrease; runtime metrics and log charges remain. Langfuse has its own plan or hosting costs, and Secrets Manager and outbound transfer may add charges. There is no dual-export cost in this version.
|
|
40
|
+
|
|
41
|
+
The exporter batches spans and attempts a flush before each invocation's final response frame, with an 8-second flush timeout inside a 10-second guard. This can add up to 10 seconds of latency before the final response frame. Export failures or an interrupted process can still lose telemetry; traces are not a durable audit log.
|
|
42
|
+
|
|
43
|
+
## Usage
|
|
44
|
+
|
|
45
|
+
Commit your existing workspace changes before running this generator. Review and commit the Langfuse changes, including dependency installation, separately so you can revert the integration later.
|
|
46
|
+
|
|
47
|
+
### Select an existing agent
|
|
48
|
+
|
|
49
|
+
<RunGenerator generator="observability#langfuse" />
|
|
50
|
+
|
|
51
|
+
Use the project name recorded in `project.json`. If it contains several agents, also pass the agent component's name with `--agent`.
|
|
52
|
+
|
|
53
|
+
<GeneratorParameters generator="observability#langfuse" />
|
|
54
|
+
|
|
55
|
+
### Prepare a secret and endpoint
|
|
56
|
+
|
|
57
|
+
We recommend [self-hosting Langfuse on AWS](https://langfuse.com/self-hosting) when choosing where to keep your trace data. Use an existing, secured HTTPS installation; this generator does not provision one. Langfuse Cloud is also supported when you explicitly select its endpoint.
|
|
58
|
+
|
|
59
|
+
Create a Secrets Manager secret in the agent's AWS account and region. Its JSON must contain the string fields `LANGFUSE_PUBLIC_KEY` and `LANGFUSE_SECRET_KEY` with your Langfuse project's keys. Use the Secrets Manager console or an approved secret-management process; do not put keys in generator flags, source files, shell history, or runtime environment variables.
|
|
60
|
+
|
|
61
|
+
Use the AWS managed Secrets Manager encryption key for this first version. A secret encrypted with a customer-managed KMS key needs an additional, explicitly scoped decrypt grant that this generator does not create.
|
|
62
|
+
|
|
63
|
+
Pass the secret's **complete ARN**, including its six-character suffix, and the HTTPS base URL of an existing Langfuse deployment, such as one you already host on AWS. The endpoint must be reachable from **both your development machine and the deployed agent**. **There is no default destination; `--host` is required on first use.** This experimental generator accepts ARNs in the `aws`, `aws-us-gov`, and `aws-cn` partitions; ISO partitions are not supported.
|
|
64
|
+
|
|
65
|
+
```sh
|
|
66
|
+
pnpm nx g @aws/nx-plugin:observability#langfuse \
|
|
67
|
+
--project=my_agent \
|
|
68
|
+
--secretArn="$LANGFUSE_SECRET_ARN" \
|
|
69
|
+
--host=https://langfuse.example.com
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
Here `LANGFUSE_SECRET_ARN` contains only the ARN, not a key. CDK grants `secretsmanager:GetSecretValue` on exactly that ARN. The application loads both keys once at process startup and constructs Basic authentication in memory. Arrange a runtime restart when rotating keys; an unchanged CDK deployment does not refresh running processes.
|
|
73
|
+
|
|
74
|
+
The CDK helper writes the host and secret ARN to AppConfig at `agentcore.langfuse.<AgentClass>`, preserving entries for other agents. Deployed startup reads this entry through `get_agentcore_runtime_config()`, using the agent's existing AppConfig read grant. The generated runtime sets `DISABLE_ADOT_OBSERVABILITY=true` so AgentCore's managed ADOT pipeline leaves tracing to the application; host and secret ARN are not runtime environment variables.
|
|
75
|
+
|
|
76
|
+
Replace `https://langfuse.example.com` with your existing endpoint. To use Langfuse Cloud, explicitly pass its regional base URL, such as `https://cloud.langfuse.com` for EU or `https://us.cloud.langfuse.com` for US. Path prefixes are supported. Provide the base URL, without `/api/public/otel`; credentials, query parameters, and fragments in the URL are rejected. Repeat runs retain the previous host and secret unless you supply replacements; leaving either input blank keeps its saved value.
|
|
77
|
+
|
|
78
|
+
The exporter uses OTLP/HTTP with `x-langfuse-ingestion-version: 4`. Self-hosted installations must support that ingestion contract. Consult Langfuse's [OpenTelemetry integration](https://langfuse.com/integrations/native/opentelemetry) and [v4 migration guide](https://langfuse.com/integrations/native/opentelemetry/migration-to-v4) when choosing an endpoint.
|
|
79
|
+
|
|
80
|
+
### Run locally
|
|
81
|
+
|
|
82
|
+
Use your normal AWS development credentials, such as an authenticated AWS profile selected with `AWS_PROFILE`. That identity needs `secretsmanager:GetSecretValue` on the selected secret, in addition to the permissions your agent normally needs for its model and tools. The generated execution-role grant covers the deployed agent; it does not grant permissions to your developer identity.
|
|
83
|
+
|
|
84
|
+
```sh
|
|
85
|
+
pnpm nx run my_agent:dev
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
The agent's `dev` and `serve` targets run `langfuse_dev.py` through Uvicorn with automatic reload. It stores only the host and secret ARN, reads the keys from Secrets Manager, and initializes tracing before importing the agent. **No deployed AppConfig application is needed to start local tracing.** The assigned local port is preserved. Keys are never read from a local `.env` file or Langfuse environment variables.
|
|
89
|
+
|
|
90
|
+
**Local development can run without Langfuse secret access.** If its configuration or credentials cannot be loaded, startup logs a warning and the local agent continues without Langfuse export. Requests do not retry the secret lookup. Fix your AWS credentials, secret-read permission, or configuration, then restart `dev`/`serve` to enable tracing. Your agent still needs its normal model and tool permissions. Deployed agents continue to fail startup when their Langfuse credentials cannot be loaded.
|
|
91
|
+
|
|
92
|
+
Invoke the local agent using its generated chat client or HTTP endpoint. Both local and deployed invocations use the same Langfuse destination and session mapping. The agent's local HTTP server keeps its normal behavior; the HTTPS requirement applies to the Langfuse destination. A laptop-only Langfuse endpoint such as `http://localhost:3000` is not supported.
|
|
93
|
+
|
|
94
|
+
Builds, OpenAPI generation, and generated tests do not fetch Langfuse keys. The generated offline Python test checks both local configuration and AppConfig configuration with synthetic credentials and an in-memory exporter.
|
|
95
|
+
|
|
96
|
+
### Build, deploy, and check a trace
|
|
97
|
+
|
|
98
|
+
Build your workspace as described in the <Link path="guides/py-agent">Python agent guide</Link>. The generator changes deployment files; it does not deploy them.
|
|
99
|
+
|
|
100
|
+
:::caution[Use rollback-enabled deployment for configuration changes]
|
|
101
|
+
Enabling Langfuse on an existing stack, changing its host or secret ARN, or reverting the integration replaces an immutable AppConfig configuration version. The generated `deploy-sandbox` target uses express mode with rollback disabled by default, which rejects resource replacements and can leave the stack in `UPDATE_FAILED`.
|
|
102
|
+
|
|
103
|
+
Use standard deployment with rollback enabled for these changes. Replace `my_infra` with your infrastructure project name:
|
|
104
|
+
|
|
105
|
+
```sh
|
|
106
|
+
pnpm nx run my_infra:deploy-sandbox --no-express --rollback
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
For other stages, use the `deploy` target with an explicit stage or stack selector and rollback enabled, as described in the <Link path="guides/typescript-infrastructure">infrastructure guide</Link>.
|
|
110
|
+
|
|
111
|
+
If an earlier deployment has already left the stack in `UPDATE_FAILED`, recover it before switching deployment modes. CloudFormation can require follow-up operations to use the same express configuration until the stack reaches a complete state. Follow AWS's [failed-stack recovery guidance](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/stack-failure-options.html); changing the deployment flag alone does not recover a failed stack.
|
|
112
|
+
:::
|
|
113
|
+
|
|
114
|
+
Invoke the local or deployed agent with a prompt that calls a tool. Open its trace detail view in the Langfuse UI and verify the invocation root, agent/model/tool children, and their input/output content. Select the model (generation) observation to check its token usage. Open the trace's session to confirm the AgentCore session ID, then repeat a short request in that session to check flushing and grouping.
|
|
115
|
+
|
|
116
|
+
The application root retains the upstream AWS trace and parent IDs; the Langfuse SDK marks it as the logical application root even though the AWS service parent is not exported to Langfuse.
|
|
117
|
+
|
|
118
|
+
Session IDs between 33 and 200 characters appear unchanged in Langfuse. Longer IDs use their 64-character SHA-256 hex digest as the Langfuse session ID, so repeated requests still appear in the same session. This mapping changes only Langfuse grouping; the AgentCore session ID sent to the application is unchanged. A missing ID or one shorter than 33 characters gets a new UUID for that invocation. The generated client uses UUIDs within these limits.
|
|
119
|
+
|
|
120
|
+
## Generated files and repeat runs
|
|
121
|
+
|
|
122
|
+
The generator adds `langfuse_telemetry.py` and `langfuse_dev.py` beside the agent, a separate `package/<agent>/langfuse_main.py` entrypoint, and a Python exporter test. It wires the existing CDK construct to `langfuse-observability.ts`, copies the deployment entrypoint into the zip, and declares its dependencies. The stock ADOT launcher remains packaged.
|
|
123
|
+
|
|
124
|
+
The Langfuse entrypoint creates one provider before importing the agent. FastAPI's overlapping tracing is disabled only in that process; native Strands spans use the same provider. The Langfuse SDK's public observation API supplies the application root and session attributes. Invocation input/output capture is bounded to 1 MiB each; the root records `content_truncated` when that limit is exceeded.
|
|
125
|
+
|
|
126
|
+
The dependency set uses Langfuse 4.18.0 and ADOT 0.22.0. The vended OpenTelemetry pins match ADOT's requirements, including API/SDK/HTTP exporter 1.45.1, and are held to preserve that compatibility. ADOT and Langfuse remain eligible for the repository's regular dependency updates; check their compatibility and adjust the OpenTelemetry pins when upgrading. Starlette follows FastAPI's dependency requirements.
|
|
127
|
+
|
|
128
|
+
Repeating the generator with the same inputs does not duplicate wiring or overwrite your runtime edits. It still honors your dependency-installation preference, so you can rerun it to retry a failed or deferred installation. Changing the host or secret updates both the local entrypoint and CDK configuration; restart local development, rebuild, and use the [rollback-enabled deployment command](#build-deploy-and-check-a-trace) to apply the change in both environments. If you edit either configuration or customize the local startup commands, the generator asks you to reconcile them before changing options. This prevents an option change from silently replacing custom wiring.
|
|
129
|
+
|
|
130
|
+
An earlier experimental setup without `langfuse_dev.py` must be reverted and regenerated with the updated generator. Preserve and reapply any customizations separately.
|
|
131
|
+
|
|
132
|
+
## Switch back to CloudWatch
|
|
133
|
+
|
|
134
|
+
Revert the dedicated commit containing the Langfuse generator's changes:
|
|
135
|
+
|
|
136
|
+
```sh
|
|
137
|
+
git revert <langfuse-setup-commit>
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
Review the revert for conflicts with subsequent agent changes. Other generators may have added usage-metric tags to the same array in `packages/common/constructs/src/core/app.ts`; preserve those tags when resolving the conflict. Remove the Langfuse tag (`g79`) only if no other agent still uses Langfuse, and preserve shared dependencies needed by remaining integrations.
|
|
141
|
+
|
|
142
|
+
Reinstall workspace dependencies, rebuild, then redeploy using the [rollback-enabled deployment command](#build-deploy-and-check-a-trace). Removing the AppConfig entry also requires a resource replacement; do not use the default express command for this step. Reverting the complete setup restores the stock ADOT entrypoint and local startup commands, and removes the Langfuse wiring, files, dependency additions, runtime settings, and secret-read grant. Restart any running local `dev` process. Invoke the deployed agent with a new session and verify new application traces in CloudWatch.
|
|
143
|
+
|
|
144
|
+
The generator has no rollback flag. Keep unrelated changes out of the setup commit so reverting it does not remove them.
|
|
145
|
+
|
|
146
|
+
The existing secret remains yours to manage. Reverting the integration does not copy, delete, or move historical traces between backends. To enable Langfuse again, run the generator with the host and secret ARN.
|