@aws/nx-plugin-mcp 1.0.0-rc.34 → 1.0.0-rc.36

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.
@@ -71,6 +71,7 @@ The generated agent construct implements `IGrantable` and `IConnectable`, so you
71
71
  <Fragment slot="cdk">
72
72
 
73
73
  ```ts title="packages/infra/src/stacks/application-stack.ts"
74
+ import { SecurityGroup } from 'aws-cdk-lib/aws-ec2';
74
75
  import { RuntimeNetworkConfiguration } from 'aws-cdk-lib/aws-bedrockagentcore';
75
76
  import { MyDatabase } from ':my-scope/common-constructs';
76
77
 
@@ -80,6 +81,9 @@ const myAgent = new MyAgent(this, 'MyAgent', {
80
81
  networkConfiguration: RuntimeNetworkConfiguration.usingVpc(this, {
81
82
  vpc,
82
83
  vpcSubnets: { subnetType: SubnetType.PRIVATE_WITH_EGRESS },
84
+ securityGroups: [
85
+ new SecurityGroup(this, 'MyAgentSecurityGroup', { vpc, allowAllOutbound: true }),
86
+ ],
83
87
  }),
84
88
  });
85
89
 
@@ -89,24 +93,25 @@ db.grantConnect(myAgent);
89
93
 
90
94
  `allowDefaultPortFrom` opens the security group rule so the agent runtime can reach the database port. `grantConnect` grants IAM `rds-db:connect` permission to the agent's execution role.
91
95
 
96
+
92
97
  </Fragment>
93
98
  <Fragment slot="terraform">
94
99
 
95
- Run the agent inside the same VPC as the database, grant it `rds-db:connect` via `additional_iam_policy_statements`, and open the network path with a pair of security group rules:
100
+ Run the agent inside the same VPC as the database, grant it `rds-db:connect` via `additional_iam_policy_statements`, and open the network path with a pair of security group rules. The `aws_vpc.main` and `aws_subnet` resources are defined in the database deployment guide:
96
101
 
97
102
  ```hcl title="packages/infra/src/main.tf"
98
103
  module "my_database" {
99
104
  source = "../../common/terraform/src/app/dbs/my-database"
100
- vpc_id = module.vpc.vpc_id
101
- database_subnet_ids = module.vpc.private_isolated_subnet_ids
102
- lambda_subnet_ids = module.vpc.private_subnet_ids
105
+ vpc_id = aws_vpc.main.id
106
+ database_subnet_ids = aws_subnet.database[*].id
107
+ lambda_subnet_ids = aws_subnet.private[*].id
103
108
  }
104
109
 
105
110
  module "my_agent" {
106
111
  source = "../../common/terraform/src/app/agents/my-agent"
107
112
  enable_vpc = true
108
- vpc_id = module.vpc.vpc_id
109
- subnet_ids = module.vpc.private_subnet_ids
113
+ vpc_id = aws_vpc.main.id
114
+ subnet_ids = aws_subnet.private[*].id
110
115
 
111
116
  appconfig_application_id = module.runtime_config_appconfig.application_id
112
117
  appconfig_application_arn = module.runtime_config_appconfig.application_arn
@@ -123,6 +128,7 @@ module "my_agent" {
123
128
  }
124
129
 
125
130
  resource "aws_vpc_security_group_ingress_rule" "agent_to_database" {
131
+ description = "Allow the agent runtime to connect to the database"
126
132
  security_group_id = module.my_database.security_group_id
127
133
  referenced_security_group_id = module.my_agent.security_group_id
128
134
  from_port = module.my_database.cluster_port
@@ -131,6 +137,7 @@ resource "aws_vpc_security_group_ingress_rule" "agent_to_database" {
131
137
  }
132
138
 
133
139
  resource "aws_vpc_security_group_egress_rule" "agent_to_database" {
140
+ description = "Allow outbound traffic from the agent runtime to the database"
134
141
  security_group_id = module.my_agent.security_group_id
135
142
  referenced_security_group_id = module.my_database.security_group_id
136
143
  from_port = module.my_database.cluster_port
@@ -139,7 +146,16 @@ resource "aws_vpc_security_group_egress_rule" "agent_to_database" {
139
146
  }
140
147
  ```
141
148
 
142
- `appconfig_application_id`/`appconfig_application_arn` come from the shared <Link path="guides/runtime-config">runtime configuration</Link> AppConfig application declared once in your root module, not from the database module.
149
+ `appconfig_application_id`/`appconfig_application_arn` come from the shared <Link path="guides/runtime-config">runtime configuration</Link> AppConfig application declared once in your root module, not from the database module. Include the `database` namespace when instantiating it so the database module's runtime configuration entry is deployed:
150
+
151
+ ```hcl title="packages/infra/src/main.tf"
152
+ module "runtime_config_appconfig" {
153
+ source = "../../common/terraform/src/core/runtime-config/appconfig"
154
+
155
+ application_name = "my-app-runtime-config"
156
+ namespaces = ["connection", "agentcore", "database"]
157
+ }
158
+ ```
143
159
 
144
160
  </Fragment>
145
161
  </Infrastructure>
@@ -112,19 +112,24 @@ This example grants every handler in your API access, but if only some handlers
112
112
 
113
113
  Deploy the API into the same VPC as the database, grant it `rds-db:connect` via `additional_iam_policy_statements`, and open the network path with a pair of security group rules:
114
114
 
115
+ The example below references the VPC resources from the <Link path="guides/py-rdb">Python Relational Database</Link> deployment guide: `aws_subnet.database` subnets have no internet route, while `aws_subnet.private` subnets have NAT egress.
116
+
115
117
  ```hcl title="packages/infra/src/main.tf"
116
118
  module "my_database" {
117
119
  source = "../../common/terraform/src/app/dbs/my-database"
118
- vpc_id = module.vpc.vpc_id
119
- database_subnet_ids = module.vpc.private_isolated_subnet_ids
120
- lambda_subnet_ids = module.vpc.private_subnet_ids
120
+ vpc_id = aws_vpc.main.id
121
+ database_subnet_ids = aws_subnet.database[*].id
122
+ lambda_subnet_ids = aws_subnet.private[*].id
121
123
  }
122
124
 
123
125
  module "api" {
124
- source = "..."
126
+ source = "../../common/terraform/src/app/apis/my-api"
125
127
  enable_vpc = true
126
- vpc_id = module.vpc.vpc_id
127
- subnet_ids = module.vpc.private_subnet_ids
128
+ vpc_id = aws_vpc.main.id
129
+ subnet_ids = aws_subnet.private[*].id
130
+
131
+ appconfig_application_id = module.runtime_config_appconfig.application_id
132
+ appconfig_application_arn = module.runtime_config_appconfig.application_arn
128
133
 
129
134
  additional_iam_policy_statements = [
130
135
  {
@@ -135,13 +140,10 @@ module "api" {
135
140
  ]
136
141
  }
137
142
  ]
138
-
139
- env = {
140
- RUNTIME_CONFIG_APP_ID = module.runtime_config_appconfig.application_id
141
- }
142
143
  }
143
144
 
144
145
  resource "aws_vpc_security_group_ingress_rule" "api_to_database" {
146
+ description = "Allow the API Lambda functions to connect to the database"
145
147
  security_group_id = module.my_database.security_group_id
146
148
  referenced_security_group_id = module.api.security_group_id
147
149
  from_port = module.my_database.cluster_port
@@ -150,6 +152,7 @@ resource "aws_vpc_security_group_ingress_rule" "api_to_database" {
150
152
  }
151
153
 
152
154
  resource "aws_vpc_security_group_egress_rule" "api_to_database" {
155
+ description = "Allow outbound traffic from the API Lambda functions to the database"
153
156
  security_group_id = module.api.security_group_id
154
157
  referenced_security_group_id = module.my_database.security_group_id
155
158
  from_port = module.my_database.cluster_port
@@ -158,7 +161,18 @@ resource "aws_vpc_security_group_egress_rule" "api_to_database" {
158
161
  }
159
162
  ```
160
163
 
161
- Deploy the API Lambda functions into **private subnets with egress**, not private isolated subnets. `RUNTIME_CONFIG_APP_ID` should point at the shared <Link path="guides/runtime-config">runtime configuration</Link> AppConfig application, not an output of the database module.
164
+ Deploy the API Lambda functions into **private subnets with egress**, not private isolated subnets. `appconfig_application_id`/`appconfig_application_arn` come from the shared <Link path="guides/runtime-config">runtime configuration</Link> AppConfig application declared once in your root module, not from the database module — passing them sets `RUNTIME_CONFIG_APP_ID` on the Lambda functions and grants them read access to the application.
165
+
166
+ The AppConfig application must expose the `database` namespace so the database module's runtime configuration entry is deployed. Include it in the `namespaces` when instantiating the `runtime-config/appconfig` module:
167
+
168
+ ```hcl title="packages/infra/src/main.tf"
169
+ module "runtime_config_appconfig" {
170
+ source = "../../common/terraform/src/core/runtime-config/appconfig"
171
+
172
+ application_name = "my-app-runtime-config"
173
+ namespaces = ["connection", "agentcore", "database"]
174
+ }
175
+ ```
162
176
 
163
177
  </Fragment>
164
178
  </Infrastructure>
@@ -80,6 +80,7 @@ The generated MCP server construct implements `IGrantable` and `IConnectable`, s
80
80
  <Fragment slot="cdk">
81
81
 
82
82
  ```ts title="packages/infra/src/stacks/application-stack.ts"
83
+ import { SecurityGroup } from 'aws-cdk-lib/aws-ec2';
83
84
  import { RuntimeNetworkConfiguration } from 'aws-cdk-lib/aws-bedrockagentcore';
84
85
  import { MyDatabase } from ':my-scope/common-constructs';
85
86
 
@@ -89,6 +90,9 @@ const myMcpServer = new MyMcpServer(this, 'MyMcpServer', {
89
90
  networkConfiguration: RuntimeNetworkConfiguration.usingVpc(this, {
90
91
  vpc,
91
92
  vpcSubnets: { subnetType: SubnetType.PRIVATE_WITH_EGRESS },
93
+ securityGroups: [
94
+ new SecurityGroup(this, 'MyMcpServerSecurityGroup', { vpc, allowAllOutbound: true }),
95
+ ],
92
96
  }),
93
97
  });
94
98
 
@@ -98,24 +102,25 @@ db.grantConnect(myMcpServer);
98
102
 
99
103
  `allowDefaultPortFrom` opens the security group rule so the MCP server runtime can reach the database port. `grantConnect` grants IAM `rds-db:connect` permission to the server's execution role.
100
104
 
105
+
101
106
  </Fragment>
102
107
  <Fragment slot="terraform">
103
108
 
104
- Run the MCP server inside the same VPC as the database, grant it `rds-db:connect` via `additional_iam_policy_statements`, and open the network path with a pair of security group rules:
109
+ Run the MCP server inside the same VPC as the database, grant it `rds-db:connect` via `additional_iam_policy_statements`, and open the network path with a pair of security group rules. The `aws_vpc.main` and `aws_subnet` resources are defined in the database deployment guide:
105
110
 
106
111
  ```hcl title="packages/infra/src/main.tf"
107
112
  module "my_database" {
108
113
  source = "../../common/terraform/src/app/dbs/my-database"
109
- vpc_id = module.vpc.vpc_id
110
- database_subnet_ids = module.vpc.private_isolated_subnet_ids
111
- lambda_subnet_ids = module.vpc.private_subnet_ids
114
+ vpc_id = aws_vpc.main.id
115
+ database_subnet_ids = aws_subnet.database[*].id
116
+ lambda_subnet_ids = aws_subnet.private[*].id
112
117
  }
113
118
 
114
119
  module "my_mcp_server" {
115
120
  source = "../../common/terraform/src/app/mcp-servers/my-mcp-server"
116
121
  enable_vpc = true
117
- vpc_id = module.vpc.vpc_id
118
- subnet_ids = module.vpc.private_subnet_ids
122
+ vpc_id = aws_vpc.main.id
123
+ subnet_ids = aws_subnet.private[*].id
119
124
 
120
125
  appconfig_application_id = module.runtime_config_appconfig.application_id
121
126
  appconfig_application_arn = module.runtime_config_appconfig.application_arn
@@ -132,6 +137,7 @@ module "my_mcp_server" {
132
137
  }
133
138
 
134
139
  resource "aws_vpc_security_group_ingress_rule" "mcp_server_to_database" {
140
+ description = "Allow the MCP server runtime to connect to the database"
135
141
  security_group_id = module.my_database.security_group_id
136
142
  referenced_security_group_id = module.my_mcp_server.security_group_id
137
143
  from_port = module.my_database.cluster_port
@@ -140,6 +146,7 @@ resource "aws_vpc_security_group_ingress_rule" "mcp_server_to_database" {
140
146
  }
141
147
 
142
148
  resource "aws_vpc_security_group_egress_rule" "mcp_server_to_database" {
149
+ description = "Allow outbound traffic from the MCP server runtime to the database"
143
150
  security_group_id = module.my_mcp_server.security_group_id
144
151
  referenced_security_group_id = module.my_database.security_group_id
145
152
  from_port = module.my_database.cluster_port
@@ -148,7 +155,16 @@ resource "aws_vpc_security_group_egress_rule" "mcp_server_to_database" {
148
155
  }
149
156
  ```
150
157
 
151
- `appconfig_application_id`/`appconfig_application_arn` come from the shared <Link path="guides/runtime-config">runtime configuration</Link> AppConfig application declared once in your root module, not from the database module.
158
+ `appconfig_application_id`/`appconfig_application_arn` come from the shared <Link path="guides/runtime-config">runtime configuration</Link> AppConfig application declared once in your root module, not from the database module. Include the `database` namespace when instantiating it so the database module's runtime configuration entry is deployed:
159
+
160
+ ```hcl title="packages/infra/src/main.tf"
161
+ module "runtime_config_appconfig" {
162
+ source = "../../common/terraform/src/core/runtime-config/appconfig"
163
+
164
+ application_name = "my-app-runtime-config"
165
+ namespaces = ["connection", "agentcore", "database"]
166
+ }
167
+ ```
152
168
 
153
169
  </Fragment>
154
170
  </Infrastructure>
@@ -86,6 +86,7 @@ The generated agent construct implements `IGrantable` and `IConnectable`, so you
86
86
  <Fragment slot="cdk">
87
87
 
88
88
  ```ts title="packages/infra/src/stacks/application-stack.ts"
89
+ import { SecurityGroup } from 'aws-cdk-lib/aws-ec2';
89
90
  import { RuntimeNetworkConfiguration } from 'aws-cdk-lib/aws-bedrockagentcore';
90
91
  import { MyDatabase } from ':my-scope/common-constructs';
91
92
 
@@ -95,6 +96,9 @@ const myAgent = new MyAgent(this, 'MyAgent', {
95
96
  networkConfiguration: RuntimeNetworkConfiguration.usingVpc(this, {
96
97
  vpc,
97
98
  vpcSubnets: { subnetType: SubnetType.PRIVATE_WITH_EGRESS },
99
+ securityGroups: [
100
+ new SecurityGroup(this, 'MyAgentSecurityGroup', { vpc, allowAllOutbound: true }),
101
+ ],
98
102
  }),
99
103
  });
100
104
 
@@ -104,24 +108,25 @@ db.grantConnect(myAgent);
104
108
 
105
109
  `allowDefaultPortFrom` opens the security group rule so the agent runtime can reach the database port. `grantConnect` grants IAM `rds-db:connect` permission to the agent's execution role.
106
110
 
111
+
107
112
  </Fragment>
108
113
  <Fragment slot="terraform">
109
114
 
110
- Run the agent inside the same VPC as the database, grant it `rds-db:connect` via `additional_iam_policy_statements`, and open the network path with a pair of security group rules:
115
+ Run the agent inside the same VPC as the database, grant it `rds-db:connect` via `additional_iam_policy_statements`, and open the network path with a pair of security group rules. The `aws_vpc.main` and `aws_subnet` resources are defined in the database deployment guide:
111
116
 
112
117
  ```hcl title="packages/infra/src/main.tf"
113
118
  module "my_database" {
114
119
  source = "../../common/terraform/src/app/dbs/my-database"
115
- vpc_id = module.vpc.vpc_id
116
- database_subnet_ids = module.vpc.private_isolated_subnet_ids
117
- lambda_subnet_ids = module.vpc.private_subnet_ids
120
+ vpc_id = aws_vpc.main.id
121
+ database_subnet_ids = aws_subnet.database[*].id
122
+ lambda_subnet_ids = aws_subnet.private[*].id
118
123
  }
119
124
 
120
125
  module "my_agent" {
121
126
  source = "../../common/terraform/src/app/agents/my-agent"
122
127
  enable_vpc = true
123
- vpc_id = module.vpc.vpc_id
124
- subnet_ids = module.vpc.private_subnet_ids
128
+ vpc_id = aws_vpc.main.id
129
+ subnet_ids = aws_subnet.private[*].id
125
130
 
126
131
  appconfig_application_id = module.runtime_config_appconfig.application_id
127
132
  appconfig_application_arn = module.runtime_config_appconfig.application_arn
@@ -138,6 +143,7 @@ module "my_agent" {
138
143
  }
139
144
 
140
145
  resource "aws_vpc_security_group_ingress_rule" "agent_to_database" {
146
+ description = "Allow the agent runtime to connect to the database"
141
147
  security_group_id = module.my_database.security_group_id
142
148
  referenced_security_group_id = module.my_agent.security_group_id
143
149
  from_port = module.my_database.cluster_port
@@ -146,6 +152,7 @@ resource "aws_vpc_security_group_ingress_rule" "agent_to_database" {
146
152
  }
147
153
 
148
154
  resource "aws_vpc_security_group_egress_rule" "agent_to_database" {
155
+ description = "Allow outbound traffic from the agent runtime to the database"
149
156
  security_group_id = module.my_agent.security_group_id
150
157
  referenced_security_group_id = module.my_database.security_group_id
151
158
  from_port = module.my_database.cluster_port
@@ -154,7 +161,16 @@ resource "aws_vpc_security_group_egress_rule" "agent_to_database" {
154
161
  }
155
162
  ```
156
163
 
157
- `appconfig_application_id`/`appconfig_application_arn` come from the shared <Link path="guides/runtime-config">runtime configuration</Link> AppConfig application declared once in your root module, not from the database module.
164
+ `appconfig_application_id`/`appconfig_application_arn` come from the shared <Link path="guides/runtime-config">runtime configuration</Link> AppConfig application declared once in your root module, not from the database module. Include the `database` namespace when instantiating it so the database module's runtime configuration entry is deployed:
165
+
166
+ ```hcl title="packages/infra/src/main.tf"
167
+ module "runtime_config_appconfig" {
168
+ source = "../../common/terraform/src/core/runtime-config/appconfig"
169
+
170
+ application_name = "my-app-runtime-config"
171
+ namespaces = ["connection", "agentcore", "database"]
172
+ }
173
+ ```
158
174
 
159
175
  </Fragment>
160
176
  </Infrastructure>
@@ -85,6 +85,7 @@ The generated MCP server construct implements `IGrantable` and `IConnectable`, s
85
85
  <Fragment slot="cdk">
86
86
 
87
87
  ```ts title="packages/infra/src/stacks/application-stack.ts"
88
+ import { SecurityGroup } from 'aws-cdk-lib/aws-ec2';
88
89
  import { RuntimeNetworkConfiguration } from 'aws-cdk-lib/aws-bedrockagentcore';
89
90
  import { MyDatabase } from ':my-scope/common-constructs';
90
91
 
@@ -94,6 +95,9 @@ const myMcpServer = new MyMcpServer(this, 'MyMcpServer', {
94
95
  networkConfiguration: RuntimeNetworkConfiguration.usingVpc(this, {
95
96
  vpc,
96
97
  vpcSubnets: { subnetType: SubnetType.PRIVATE_WITH_EGRESS },
98
+ securityGroups: [
99
+ new SecurityGroup(this, 'MyMcpServerSecurityGroup', { vpc, allowAllOutbound: true }),
100
+ ],
97
101
  }),
98
102
  });
99
103
 
@@ -103,24 +107,25 @@ db.grantConnect(myMcpServer);
103
107
 
104
108
  `allowDefaultPortFrom` opens the security group rule so the MCP server runtime can reach the database port. `grantConnect` grants IAM `rds-db:connect` permission to the server's execution role.
105
109
 
110
+
106
111
  </Fragment>
107
112
  <Fragment slot="terraform">
108
113
 
109
- Run the MCP server inside the same VPC as the database, grant it `rds-db:connect` via `additional_iam_policy_statements`, and open the network path with a pair of security group rules:
114
+ Run the MCP server inside the same VPC as the database, grant it `rds-db:connect` via `additional_iam_policy_statements`, and open the network path with a pair of security group rules. The `aws_vpc.main` and `aws_subnet` resources are defined in the database deployment guide:
110
115
 
111
116
  ```hcl title="packages/infra/src/main.tf"
112
117
  module "my_database" {
113
118
  source = "../../common/terraform/src/app/dbs/my-database"
114
- vpc_id = module.vpc.vpc_id
115
- database_subnet_ids = module.vpc.private_isolated_subnet_ids
116
- lambda_subnet_ids = module.vpc.private_subnet_ids
119
+ vpc_id = aws_vpc.main.id
120
+ database_subnet_ids = aws_subnet.database[*].id
121
+ lambda_subnet_ids = aws_subnet.private[*].id
117
122
  }
118
123
 
119
124
  module "my_mcp_server" {
120
125
  source = "../../common/terraform/src/app/mcp-servers/my-mcp-server"
121
126
  enable_vpc = true
122
- vpc_id = module.vpc.vpc_id
123
- subnet_ids = module.vpc.private_subnet_ids
127
+ vpc_id = aws_vpc.main.id
128
+ subnet_ids = aws_subnet.private[*].id
124
129
 
125
130
  appconfig_application_id = module.runtime_config_appconfig.application_id
126
131
  appconfig_application_arn = module.runtime_config_appconfig.application_arn
@@ -137,6 +142,7 @@ module "my_mcp_server" {
137
142
  }
138
143
 
139
144
  resource "aws_vpc_security_group_ingress_rule" "mcp_server_to_database" {
145
+ description = "Allow the MCP server runtime to connect to the database"
140
146
  security_group_id = module.my_database.security_group_id
141
147
  referenced_security_group_id = module.my_mcp_server.security_group_id
142
148
  from_port = module.my_database.cluster_port
@@ -145,6 +151,7 @@ resource "aws_vpc_security_group_ingress_rule" "mcp_server_to_database" {
145
151
  }
146
152
 
147
153
  resource "aws_vpc_security_group_egress_rule" "mcp_server_to_database" {
154
+ description = "Allow outbound traffic from the MCP server runtime to the database"
148
155
  security_group_id = module.my_mcp_server.security_group_id
149
156
  referenced_security_group_id = module.my_database.security_group_id
150
157
  from_port = module.my_database.cluster_port
@@ -153,7 +160,16 @@ resource "aws_vpc_security_group_egress_rule" "mcp_server_to_database" {
153
160
  }
154
161
  ```
155
162
 
156
- `appconfig_application_id`/`appconfig_application_arn` come from the shared <Link path="guides/runtime-config">runtime configuration</Link> AppConfig application declared once in your root module, not from the database module.
163
+ `appconfig_application_id`/`appconfig_application_arn` come from the shared <Link path="guides/runtime-config">runtime configuration</Link> AppConfig application declared once in your root module, not from the database module. Include the `database` namespace when instantiating it so the database module's runtime configuration entry is deployed:
164
+
165
+ ```hcl title="packages/infra/src/main.tf"
166
+ module "runtime_config_appconfig" {
167
+ source = "../../common/terraform/src/core/runtime-config/appconfig"
168
+
169
+ application_name = "my-app-runtime-config"
170
+ namespaces = ["connection", "agentcore", "database"]
171
+ }
172
+ ```
157
173
 
158
174
  </Fragment>
159
175
  </Infrastructure>
@@ -1,5 +1,5 @@
1
1
  ---
2
- title: py#dynamodb
2
+ title: Python DynamoDB
3
3
  description: Create a Python DynamoDB project
4
4
  generator: py#dynamodb
5
5
  ---
@@ -40,21 +40,24 @@ This example grants every handler in your API access, but if only some handlers
40
40
  </Fragment>
41
41
  <Fragment slot="terraform">
42
42
 
43
- Deploy the API into the same VPC as the database, grant it `rds-db:connect` via `additional_iam_policy_statements`, and open the network path with a pair of security group rules:
43
+ Deploy the API into the same VPC as the database, grant it `rds-db:connect` via `additional_iam_policy_statements`, and open the network path with a pair of security group rules. The `aws_vpc.main` and `aws_subnet` resources are defined in the database deployment guide:
44
44
 
45
45
  ```hcl title="packages/infra/src/main.tf"
46
46
  module "my_database" {
47
47
  source = "../../common/terraform/src/app/dbs/my-database"
48
- vpc_id = module.vpc.vpc_id
49
- database_subnet_ids = module.vpc.private_isolated_subnet_ids
50
- lambda_subnet_ids = module.vpc.private_subnet_ids
48
+ vpc_id = aws_vpc.main.id
49
+ database_subnet_ids = aws_subnet.database[*].id
50
+ lambda_subnet_ids = aws_subnet.private[*].id
51
51
  }
52
52
 
53
53
  module "api" {
54
- source = "..."
54
+ source = "../../common/terraform/src/app/apis/my-api"
55
55
  enable_vpc = true
56
- vpc_id = module.vpc.vpc_id
57
- subnet_ids = module.vpc.private_subnet_ids
56
+ vpc_id = aws_vpc.main.id
57
+ subnet_ids = aws_subnet.private[*].id
58
+
59
+ appconfig_application_id = module.runtime_config_appconfig.application_id
60
+ appconfig_application_arn = module.runtime_config_appconfig.application_arn
58
61
 
59
62
  additional_iam_policy_statements = [
60
63
  {
@@ -65,13 +68,10 @@ module "api" {
65
68
  ]
66
69
  }
67
70
  ]
68
-
69
- env = {
70
- RUNTIME_CONFIG_APP_ID = module.runtime_config_appconfig.application_id
71
- }
72
71
  }
73
72
 
74
73
  resource "aws_vpc_security_group_ingress_rule" "api_to_database" {
74
+ description = "Allow the API Lambda functions to connect to the database"
75
75
  security_group_id = module.my_database.security_group_id
76
76
  referenced_security_group_id = module.api.security_group_id
77
77
  from_port = module.my_database.cluster_port
@@ -80,6 +80,7 @@ resource "aws_vpc_security_group_ingress_rule" "api_to_database" {
80
80
  }
81
81
 
82
82
  resource "aws_vpc_security_group_egress_rule" "api_to_database" {
83
+ description = "Allow outbound traffic from the API Lambda functions to the database"
83
84
  security_group_id = module.api.security_group_id
84
85
  referenced_security_group_id = module.my_database.security_group_id
85
86
  from_port = module.my_database.cluster_port
@@ -88,7 +89,16 @@ resource "aws_vpc_security_group_egress_rule" "api_to_database" {
88
89
  }
89
90
  ```
90
91
 
91
- Deploy the API Lambda functions into **private subnets with egress**, not private isolated subnets. `RUNTIME_CONFIG_APP_ID` should point at the shared <Link path="guides/runtime-config">runtime configuration</Link> AppConfig application, not an output of the database module.
92
+ Deploy the API Lambda functions into **private subnets with egress**, not private isolated subnets. `appconfig_application_id`/`appconfig_application_arn` come from the shared <Link path="guides/runtime-config">runtime configuration</Link> AppConfig application declared once in your root module, not from the database module — passing them sets `RUNTIME_CONFIG_APP_ID` on the Lambda functions and grants them read access to the application. Include the `database` namespace when instantiating it so the database module's runtime configuration entry is deployed:
93
+
94
+ ```hcl title="packages/infra/src/main.tf"
95
+ module "runtime_config_appconfig" {
96
+ source = "../../common/terraform/src/core/runtime-config/appconfig"
97
+
98
+ application_name = "my-app-runtime-config"
99
+ namespaces = ["connection", "agentcore", "database"]
100
+ }
101
+ ```
92
102
 
93
103
  </Fragment>
94
104
  </Infrastructure>
@@ -2,7 +2,6 @@
2
2
  title: Deploying your DynamoDB Table
3
3
  ---
4
4
  import Infrastructure from '@components/infrastructure.astro';
5
- import Snippet from '@components/snippet.astro';
6
5
 
7
6
  The DynamoDB generator creates CDK or Terraform infrastructure based on your selected `iac`.
8
7
 
@@ -51,10 +50,6 @@ This provisions a DynamoDB table with:
51
50
  </Fragment>
52
51
  </Infrastructure>
53
52
 
54
- ### Granting Access
55
-
56
- <Snippet name="connection/lambda-dynamodb-access" />
57
-
58
53
  ### Deletion Protection
59
54
 
60
55
  Deletion protection is enabled by default to prevent accidental table deletion.
@@ -3,6 +3,7 @@ title: Deploying your Relational Database
3
3
  ---
4
4
  import Infrastructure from '@components/infrastructure.astro';
5
5
  import Link from '@components/link.astro';
6
+ import Drawer from '@components/drawer.astro';
6
7
 
7
8
  The relational database generator creates CDK or Terraform infrastructure based on your selected `iacProvider`.
8
9
 
@@ -40,9 +41,10 @@ The Terraform module is created in `common/terraform`. Example usage:
40
41
  module "my_database" {
41
42
  source = "../../common/terraform/src/app/dbs/my-database"
42
43
 
43
- vpc_id = module.vpc.vpc_id
44
- database_subnet_ids = module.vpc.private_isolated_subnet_ids
45
- lambda_subnet_ids = module.vpc.private_subnet_ids
44
+ # Database subnets have no internet route; Lambda subnets need NAT egress.
45
+ vpc_id = aws_vpc.main.id
46
+ database_subnet_ids = aws_subnet.database[*].id
47
+ lambda_subnet_ids = aws_subnet.private[*].id
46
48
 
47
49
  tags = local.common_tags
48
50
  }
@@ -50,6 +52,17 @@ module "my_database" {
50
52
 
51
53
  This provisions an Aurora cluster with RDS Proxy, admin credentials, create-db-user Lambda, runtime config registration, migration Lambda, and container registry resources.
52
54
 
55
+ The database module registers its connection details under the `database` runtime configuration namespace. Include this namespace when instantiating the shared runtime configuration AppConfig application:
56
+
57
+ ```hcl title="packages/infra/src/main.tf"
58
+ module "runtime_config_appconfig" {
59
+ source = "../../common/terraform/src/core/runtime-config/appconfig"
60
+
61
+ application_name = "my-app-runtime-config"
62
+ namespaces = ["connection", "agentcore", "database"]
63
+ }
64
+ ```
65
+
53
66
  The generated infrastructure creates two database users:
54
67
  - **Admin user** - Created during cluster provisioning with credentials stored in AWS Secrets Manager
55
68
  - **Application user** - Created via a Lambda function with IAM authentication enabled and DML privileges (SELECT, INSERT, UPDATE, DELETE) on the application database
@@ -60,6 +73,8 @@ The application user is automatically created with a random name and IAM authent
60
73
 
61
74
  Your VPC should include public subnets, private subnets with egress, and private isolated subnets. The database can run in private isolated subnets, while application Lambda functions should run in private subnets with egress so they can reach AWS services such as AppConfig.
62
75
 
76
+ <Drawer title="Example VPC configuration" trigger="Click here for an example VPC configuration.">
77
+
63
78
  <Infrastructure>
64
79
  <Fragment slot="cdk">
65
80
 
@@ -86,22 +101,87 @@ const vpc = new Vpc(this, 'Vpc', {
86
101
  <Fragment slot="terraform">
87
102
 
88
103
  ```hcl title="packages/infra/src/main.tf"
89
- module "vpc" {
90
- source = "terraform-aws-modules/vpc/aws"
91
- version = "~> 6.0"
92
-
93
- name = "app"
94
- ...
95
- public_subnet_names = ["public"]
96
- private_subnet_names = ["private_with_egress"]
97
- intra_subnet_names = ["private_isolated"]
98
-
99
- enable_nat_gateway = true
100
- single_nat_gateway = true
104
+ data "aws_availability_zones" "available" {
105
+ state = "available"
106
+ }
107
+
108
+ resource "aws_vpc" "main" {
109
+ cidr_block = "10.0.0.0/16"
110
+ enable_dns_hostnames = true
111
+ enable_dns_support = true
112
+ }
113
+
114
+ # Isolated subnets for the database: no route to the internet
115
+ resource "aws_subnet" "database" {
116
+ count = 2
117
+ vpc_id = aws_vpc.main.id
118
+ cidr_block = cidrsubnet(aws_vpc.main.cidr_block, 8, count.index)
119
+ availability_zone = data.aws_availability_zones.available.names[count.index]
120
+ }
121
+
122
+ # Private subnets with NAT egress for Lambda functions and runtimes,
123
+ # so they can reach AWS services such as AppConfig
124
+ resource "aws_subnet" "private" {
125
+ count = 2
126
+ vpc_id = aws_vpc.main.id
127
+ cidr_block = cidrsubnet(aws_vpc.main.cidr_block, 8, count.index + 2)
128
+ availability_zone = data.aws_availability_zones.available.names[count.index]
129
+ }
130
+
131
+ # Public subnet hosting the NAT gateway
132
+ resource "aws_subnet" "public" {
133
+ vpc_id = aws_vpc.main.id
134
+ cidr_block = cidrsubnet(aws_vpc.main.cidr_block, 8, 4)
135
+ availability_zone = data.aws_availability_zones.available.names[0]
136
+ }
137
+
138
+ resource "aws_internet_gateway" "main" {
139
+ vpc_id = aws_vpc.main.id
140
+ }
141
+
142
+ resource "aws_route_table" "public" {
143
+ vpc_id = aws_vpc.main.id
144
+
145
+ route {
146
+ cidr_block = "0.0.0.0/0"
147
+ gateway_id = aws_internet_gateway.main.id
148
+ }
149
+ }
150
+
151
+ resource "aws_route_table_association" "public" {
152
+ subnet_id = aws_subnet.public.id
153
+ route_table_id = aws_route_table.public.id
154
+ }
155
+
156
+ resource "aws_eip" "nat" {
157
+ domain = "vpc"
158
+ }
159
+
160
+ resource "aws_nat_gateway" "main" {
161
+ allocation_id = aws_eip.nat.id
162
+ subnet_id = aws_subnet.public.id
163
+ depends_on = [aws_internet_gateway.main]
164
+ }
165
+
166
+ resource "aws_route_table" "private" {
167
+ vpc_id = aws_vpc.main.id
168
+
169
+ route {
170
+ cidr_block = "0.0.0.0/0"
171
+ nat_gateway_id = aws_nat_gateway.main.id
172
+ }
173
+ }
174
+
175
+ resource "aws_route_table_association" "private" {
176
+ count = 2
177
+ subnet_id = aws_subnet.private[count.index].id
178
+ route_table_id = aws_route_table.private.id
101
179
  }
102
180
  ```
103
181
 
104
182
  </Fragment>
105
183
  </Infrastructure>
106
184
 
185
+ </Drawer>
186
+
107
187
  Use the <Link path="guides/connection">`connection`</Link> generator to connect a project to this database — see the connection guide for the relevant compute type (e.g. FastAPI, MCP server, agent) for the infrastructure wiring required to reach it.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aws/nx-plugin-mcp",
3
- "version": "1.0.0-rc.34",
3
+ "version": "1.0.0-rc.36",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/awslabs/nx-plugin-for-aws.git",