@aws/nx-plugin-mcp 1.0.0-rc.7 → 1.0.0-rc.71
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 +12317 -10933
- package/docs/get_started/building-with-ai.mdx +116 -0
- package/docs/get_started/concepts.mdx +67 -0
- package/docs/get_started/existing-project.mdx +180 -0
- package/docs/get_started/graph-builder.mdx +39 -0
- package/docs/get_started/quick-start.mdx +277 -0
- package/docs/get_started/tutorials/contribute-generator.mdx +408 -0
- package/docs/get_started/tutorials/dungeon-game/1.mdx +1301 -0
- package/docs/get_started/tutorials/dungeon-game/2.mdx +237 -0
- package/docs/get_started/tutorials/dungeon-game/3.mdx +76 -0
- package/docs/get_started/tutorials/dungeon-game/4.mdx +164 -0
- package/docs/get_started/tutorials/dungeon-game/overview.mdx +145 -0
- package/docs/get_started/tutorials/dungeon-game/wrap-up.mdx +41 -0
- package/docs/get_started/tutorials/existing-project.mdx +4 -0
- package/docs/get_started/upgrading.mdx +147 -0
- package/docs/guides/agentcore-gateway.mdx +490 -0
- package/docs/guides/agentcore-harness.mdx +275 -0
- package/docs/guides/astro-docs.mdx +8 -0
- package/docs/guides/connection/agentcore-gateway-agent.mdx +222 -0
- package/docs/guides/connection/agentcore-gateway-gateway.mdx +154 -0
- package/docs/guides/connection/agentcore-gateway-mcp.mdx +134 -0
- package/docs/guides/connection/py-agent-a2a.mdx +48 -16
- package/docs/guides/connection/py-agent-dynamodb.mdx +116 -0
- package/docs/guides/connection/py-agent-gateway.mdx +178 -0
- package/docs/guides/connection/py-agent-mcp.mdx +43 -14
- package/docs/guides/connection/py-agent-rdb.mdx +178 -0
- package/docs/guides/connection/py-fast-api-dynamodb.mdx +56 -0
- package/docs/guides/connection/py-fast-api-rdb.mdx +184 -0
- package/docs/guides/connection/py-mcp-server-dynamodb.mdx +116 -0
- package/docs/guides/connection/py-mcp-server-rdb.mdx +187 -0
- package/docs/guides/connection/react-agentcore-gateway.mdx +112 -0
- package/docs/guides/connection/react-agui.mdx +13 -13
- package/docs/guides/connection/react-fastapi.mdx +38 -2
- package/docs/guides/connection/react-py-agent.mdx +9 -15
- package/docs/guides/connection/react-smithy.mdx +3 -3
- package/docs/guides/connection/react-trpc.mdx +1 -1
- package/docs/guides/connection/react-ts-agent.mdx +8 -8
- package/docs/guides/connection/smithy-dynamodb.mdx +5 -5
- package/docs/guides/connection/smithy-rdb.mdx +9 -9
- package/docs/guides/connection/trpc-dynamodb.mdx +5 -5
- package/docs/guides/connection/trpc-rdb.mdx +6 -6
- package/docs/guides/connection/ts-agent-a2a.mdx +14 -11
- package/docs/guides/connection/ts-agent-dynamodb.mdx +5 -5
- package/docs/guides/connection/ts-agent-gateway.mdx +143 -0
- package/docs/guides/connection/ts-agent-mcp.mdx +12 -9
- package/docs/guides/connection/ts-agent-rdb.mdx +70 -25
- package/docs/guides/connection/ts-mcp-server-dynamodb.mdx +5 -5
- package/docs/guides/connection/ts-mcp-server-rdb.mdx +68 -18
- package/docs/guides/connection.mdx +122 -5
- package/docs/guides/docker-bundling.mdx +69 -12
- package/docs/guides/fastapi.mdx +249 -9
- package/docs/guides/local-development.mdx +87 -0
- package/docs/guides/nx-generator.mdx +4 -3
- package/docs/guides/nx-migration.mdx +165 -0
- package/docs/guides/py-agent.mdx +264 -49
- package/docs/guides/py-dynamodb.mdx +476 -0
- package/docs/guides/py-mcp-server.mdx +61 -2
- package/docs/guides/py-rdb.mdx +265 -0
- package/docs/guides/python-lambda-function.mdx +1 -1
- package/docs/guides/react-website-auth.mdx +65 -4
- package/docs/guides/react-website.mdx +149 -30
- package/docs/guides/runtime-config.mdx +1 -1
- package/docs/guides/security.mdx +75 -0
- package/docs/guides/smithy-project.mdx +167 -0
- package/docs/guides/terraform-project.mdx +2 -2
- package/docs/guides/trpc.mdx +53 -16
- package/docs/guides/ts-agent.mdx +183 -10
- package/docs/guides/ts-dcr-proxy.mdx +569 -0
- package/docs/guides/ts-dynamodb.mdx +66 -242
- package/docs/guides/ts-lambda-function.mdx +1 -1
- package/docs/guides/ts-mcp-server.mdx +109 -29
- package/docs/guides/ts-nx-plugin.mdx +3 -3
- package/docs/guides/ts-rdb.mdx +113 -467
- package/docs/guides/ts-smithy-api.mdx +258 -18
- package/docs/guides/typescript-infrastructure.mdx +46 -24
- package/docs/guides/typescript-project.mdx +134 -27
- package/docs/guides/workspace.mdx +10 -3
- package/docs/snippets/agent/architecture.mdx +1 -1
- package/docs/snippets/agent/bedrock-deployment.mdx +9 -5
- package/docs/snippets/agent/runtime-arn.mdx +23 -2
- package/docs/snippets/agent/securing-your-agent.mdx +39 -0
- package/docs/snippets/api/access-logging.mdx +33 -0
- package/docs/snippets/api/cors-configuration-cdk-note.mdx +1 -1
- package/docs/snippets/api/cors-configuration-terraform-note.mdx +1 -1
- package/docs/snippets/api/type-safe-api-integrations.mdx +33 -2
- package/docs/snippets/api/waf-configuration.mdx +3 -3
- package/docs/snippets/connection/a2a-infrastructure.mdx +1 -1
- package/docs/snippets/connection/dynamodb-local-development.mdx +2 -2
- package/docs/snippets/connection/lambda-dynamodb-access.mdx +1 -1
- package/docs/snippets/connection/py-dynamodb-local-development.mdx +7 -0
- package/docs/snippets/connection/py-lambda-rdb-ssl-requirements.mdx +7 -0
- package/docs/snippets/connection/rdb-api-infrastructure.mdx +51 -19
- package/docs/snippets/dynamodb/deploying-table.mdx +166 -0
- package/docs/snippets/dynamodb/gsi-config.mdx +38 -0
- package/docs/snippets/dynamodb/infrastructure.mdx +33 -0
- package/docs/snippets/dynamodb/local-dev-start.mdx +13 -0
- package/docs/snippets/dynamodb/local-dev-windows.mdx +15 -0
- package/docs/snippets/lambda-function/deploying-your-function.mdx +3 -3
- package/docs/snippets/mcp/architecture.mdx +1 -1
- package/docs/snippets/mcp/bedrock-deployment.mdx +9 -5
- package/docs/snippets/mcp/config.mdx +3 -2
- package/docs/snippets/pdk-migration/example/01-migrate-api.mdx +7 -5
- package/docs/snippets/pdk-migration/example/02-migrate-website.mdx +29 -10
- package/docs/snippets/pdk-migration/example/03-migrate-infra.mdx +4 -4
- package/docs/snippets/pdk-migration/faq/type-safe-api.mdx +5 -111
- package/docs/snippets/prerequisites.mdx +1 -4
- package/docs/snippets/rdb/architecture.mdx +38 -0
- package/docs/snippets/rdb/cluster-instances.mdx +31 -0
- package/docs/snippets/rdb/deletion-protection.mdx +34 -0
- package/docs/snippets/rdb/deploying.mdx +187 -0
- package/docs/snippets/rdb/encryption-key-rotation.mdx +30 -0
- package/docs/snippets/rdb/engine-version.mdx +63 -0
- package/docs/snippets/rdb/infrastructure.mdx +35 -0
- package/docs/snippets/rdb/logging-mysql.mdx +5 -0
- package/docs/snippets/rdb/logging-postgres.mdx +5 -0
- package/docs/snippets/rdb/performance-insights.mdx +34 -0
- package/docs/snippets/rdb/rds-proxy.mdx +50 -0
- package/docs/snippets/rdb/removal-policy.mdx +57 -0
- package/docs/snippets/rdb/serverless-capacity.mdx +32 -0
- package/docs/snippets/recommended-prerequisites.mdx +10 -0
- package/docs/snippets/required-prerequisites.mdx +1 -4
- package/docs/snippets/runtime-config-app-id-note.mdx +8 -0
- package/docs/snippets/shared-constructs.mdx +1 -1
- package/docs/snippets/trivy-image-scan.mdx +37 -0
- package/generators.json +152 -10
- package/package.json +1 -1
- package/src/agentcore-gateway/agent-connection/schema.json +31 -0
- package/src/agentcore-gateway/gateway-connection/schema.json +31 -0
- package/src/agentcore-gateway/mcp-connection/schema.json +31 -0
- package/src/agentcore-gateway/react-connection/schema.json +31 -0
- package/src/agentcore-gateway/schema.json +72 -0
- package/src/agentcore-harness/schema.json +53 -0
- package/src/connection/schema.json +5 -0
- package/src/infra/app/schema.json +5 -0
- package/src/init/schema.json +35 -0
- package/src/internal/test-matrix/schema.json +21 -0
- package/src/license/schema.json +5 -0
- package/src/preset/schema.json +16 -5
- package/src/py/agent/a2a-connection/schema.json +5 -0
- package/src/py/agent/gateway-connection/schema.json +31 -0
- package/src/py/agent/mcp-connection/schema.json +5 -0
- package/src/py/agent/react-connection/schema.json +5 -0
- package/src/py/agent/schema.json +15 -1
- package/src/py/api/schema.json +5 -0
- package/src/py/dynamodb/agent-connection/schema.json +27 -0
- package/src/py/dynamodb/fast-api-connection/schema.json +23 -0
- package/src/py/dynamodb/mcp-server-connection/schema.json +27 -0
- package/src/py/dynamodb/schema.json +76 -0
- package/src/py/fast-api/react/schema.json +5 -0
- package/src/py/fast-api/schema.json +6 -0
- package/src/py/lambda-function/schema.json +5 -0
- package/src/py/mcp-server/schema.json +6 -0
- package/src/py/project/schema.json +5 -0
- package/src/py/rdb/agent-connection/schema.json +27 -0
- package/src/py/rdb/fast-api-connection/schema.json +23 -0
- package/src/py/rdb/mcp-server-connection/schema.json +27 -0
- package/src/py/rdb/schema.json +78 -0
- package/src/smithy/project/schema.json +28 -1
- package/src/smithy/react-connection/schema.json +5 -0
- package/src/smithy/ts/api/schema.json +6 -0
- package/src/terraform/project/schema.json +5 -0
- package/src/trpc/backend/schema.json +6 -0
- package/src/trpc/react/schema.json +5 -0
- package/src/ts/agent/a2a-connection/schema.json +5 -0
- package/src/ts/agent/gateway-connection/schema.json +31 -0
- package/src/ts/agent/mcp-connection/schema.json +5 -0
- package/src/ts/agent/react-connection/schema.json +5 -0
- package/src/ts/agent/schema.json +14 -0
- package/src/ts/api/schema.json +5 -0
- package/src/ts/astro-docs/schema.json +3 -3
- package/src/ts/dcr-proxy/schema.json +44 -0
- package/src/ts/docs/schema.json +3 -3
- package/src/ts/dynamodb/agent-connection/schema.json +5 -0
- package/src/ts/dynamodb/mcp-server-connection/schema.json +5 -0
- package/src/ts/dynamodb/schema.json +26 -2
- package/src/ts/dynamodb/smithy-connection/schema.json +5 -0
- package/src/ts/dynamodb/trpc-connection/schema.json +5 -0
- package/src/ts/lambda-function/schema.json +5 -0
- package/src/ts/lib/schema.json +5 -0
- package/src/ts/mcp-server/schema.json +6 -0
- package/src/ts/nx-generator/schema.json +5 -0
- package/src/ts/nx-migration/schema.json +63 -0
- package/src/ts/nx-plugin/schema.json +5 -0
- package/src/ts/rdb/agent-connection/schema.json +5 -0
- package/src/ts/rdb/mcp-server-connection/schema.json +5 -0
- package/src/ts/rdb/schema.json +7 -1
- package/src/ts/rdb/smithy-connection/schema.json +5 -0
- package/src/ts/rdb/trpc-connection/schema.json +5 -0
- package/src/ts/react-website/app/schema.json +12 -6
- package/src/ts/react-website/cognito-auth/schema.json +5 -0
- package/src/ts/react-website/runtime-config/schema.json +5 -0
- package/src/ts/website/app/schema.json +11 -6
- package/src/ts/website/auth/schema.json +5 -0
- /package/docs/snippets/connection/{lambda-rdb-ssl-requirements.mdx → ts-lambda-rdb-ssl-requirements.mdx} +0 -0
- /package/docs/snippets/connection/{mcp-server-rdb-ssl-requirements.mdx → ts-mcp-server-rdb-ssl-requirements.mdx} +0 -0
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
---
|
|
2
2
|
title: React Website
|
|
3
3
|
description: Reference documentation for a React Website
|
|
4
|
-
generator: ts#
|
|
4
|
+
generator: ts#website
|
|
5
5
|
when:
|
|
6
6
|
framework:
|
|
7
7
|
- react
|
|
8
8
|
---
|
|
9
|
-
import { FileTree, Steps } from '@astrojs/starlight/components';
|
|
9
|
+
import { FileTree, Steps, CardGrid } from '@astrojs/starlight/components';
|
|
10
|
+
import Astro from '@astrojs/react';
|
|
11
|
+
import ConnectionCard from '@components/connection-card.astro';
|
|
10
12
|
import Link from '@components/link.astro';
|
|
11
13
|
import RunGenerator from '@components/run-generator.astro';
|
|
12
14
|
import GeneratorParameters from '@components/generator-parameters.astro';
|
|
@@ -16,12 +18,12 @@ import Infrastructure from '@components/infrastructure.astro';
|
|
|
16
18
|
import Snippet from '@components/snippet.astro';
|
|
17
19
|
import OptionFilter from '@components/option-filter.astro';
|
|
18
20
|
|
|
19
|
-
This generator creates a new [React](https://react.dev/) website with [
|
|
21
|
+
This generator creates a new [React](https://react.dev/) website with [shadcn/ui](https://ui.shadcn.com/) configured by default, along with the AWS CDK or Terraform infrastructure to deploy your website to the cloud as a static website hosted in [S3](https://aws.amazon.com/s3/), served by [CloudFront](https://aws.amazon.com/cloudfront/) and protected by [WAF](https://aws.amazon.com/waf/).
|
|
20
22
|
|
|
21
23
|
The generated application uses [Vite](https://vite.dev/) as the build tool and bundler. It uses [TanStack Router](https://tanstack.com/router/v1) for type-safe routing.
|
|
22
24
|
|
|
23
25
|
:::note[UX Provider]
|
|
24
|
-
The default `
|
|
26
|
+
The default `ux` is [shadcn/ui](https://ui.shadcn.com/). You can also select [Cloudscape](http://cloudscape.design/) or `none` (bring your own component library).
|
|
25
27
|
:::
|
|
26
28
|
|
|
27
29
|
## Usage
|
|
@@ -30,7 +32,7 @@ The default `uxProvider` is [Cloudscape](http://cloudscape.design/). You can als
|
|
|
30
32
|
|
|
31
33
|
You can generate a new React Website in two ways:
|
|
32
34
|
|
|
33
|
-
<RunGenerator generator="ts#website" />
|
|
35
|
+
<RunGenerator generator="ts#website" requiredParameters={{ framework: 'react' }} />
|
|
34
36
|
|
|
35
37
|
### Options
|
|
36
38
|
|
|
@@ -57,6 +59,7 @@ The generator will create the following project structure in the `<directory>/<n
|
|
|
57
59
|
- tsconfig.json Base TypeScript configuration for source and tests
|
|
58
60
|
- tsconfig.app.json TypeScript configuration for source code
|
|
59
61
|
- tsconfig.spec.json TypeScript configuration for tests
|
|
62
|
+
- package.json Project manifest defining the project's package name and dependencies
|
|
60
63
|
</FileTree>
|
|
61
64
|
|
|
62
65
|
:::note[Without TanStack Router]
|
|
@@ -67,7 +70,7 @@ If you opted not to use [TanStack Router](https://tanstack.com/router/v1), you w
|
|
|
67
70
|
|
|
68
71
|
<Snippet name="shared-constructs" />
|
|
69
72
|
|
|
70
|
-
The generator creates infrastructure as code for deploying your website based on your selected `
|
|
73
|
+
The generator creates infrastructure as code for deploying your website based on your selected `iac`:
|
|
71
74
|
|
|
72
75
|
<Infrastructure>
|
|
73
76
|
<Fragment slot="cdk">
|
|
@@ -126,6 +129,57 @@ waf -> cloudfront
|
|
|
126
129
|
cloudfront -> s3
|
|
127
130
|
```
|
|
128
131
|
|
|
132
|
+
#### Security Headers
|
|
133
|
+
|
|
134
|
+
The CloudFront distribution applies a response headers policy that sets `Strict-Transport-Security`, `X-Content-Type-Options`, `X-Frame-Options: DENY`, `Referrer-Policy` and a `Content-Security-Policy` on all responses.
|
|
135
|
+
|
|
136
|
+
A default `Content-Security-Policy` is enforced. It restricts scripts and framing to mitigate XSS and clickjacking, while permitting HTTPS and WSS connections so the website can call AWS service endpoints (such as API Gateway, Cognito and Bedrock AgentCore) whose URLs are only known at deploy time. To adjust the policy (for example to tighten `connect-src` to your specific origins), edit the `content_security_policy` value in your generated `static-website.ts` (CDK) or `static-website.tf` (Terraform).
|
|
137
|
+
|
|
138
|
+
`runtime-config.json` is served with `Cache-Control: no-cache` so that browsers always fetch the latest configuration after a redeploy, rather than using a stale cached copy.
|
|
139
|
+
|
|
140
|
+
#### Custom Domain & TLS
|
|
141
|
+
|
|
142
|
+
By default the distribution uses the default CloudFront domain name (`*.cloudfront.net`) and its default certificate, which does not support enforcing a minimum TLS version of 1.2. To serve your website from your own domain, supply an [ACM certificate](https://docs.aws.amazon.com/acm/latest/userguide/acm-overview.html) (which must reside in `us-east-1` for use with CloudFront) and your domain names — a minimum TLS version of 1.2 is then enforced for viewers:
|
|
143
|
+
|
|
144
|
+
<Infrastructure>
|
|
145
|
+
<Fragment slot="cdk">
|
|
146
|
+
Pass the `certificate` and `domainNames` props through in your generated website construct in `packages/common/constructs/src/app/static-websites`:
|
|
147
|
+
|
|
148
|
+
```ts {6-8}
|
|
149
|
+
export class MyWebsite extends StaticWebsite {
|
|
150
|
+
constructor(scope: Construct, id: string) {
|
|
151
|
+
super(scope, id, {
|
|
152
|
+
websiteName: 'MyWebsite',
|
|
153
|
+
websiteFilePath: ...,
|
|
154
|
+
domainNames: ['www.example.com'],
|
|
155
|
+
certificate: Certificate.fromCertificateArn(scope, 'Cert',
|
|
156
|
+
'arn:aws:acm:us-east-1:123456789012:certificate/...'),
|
|
157
|
+
});
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
```
|
|
161
|
+
</Fragment>
|
|
162
|
+
<Fragment slot="terraform">
|
|
163
|
+
Set the `custom_domain_names` and `acm_certificate_arn` variables in your generated website module in `packages/common/terraform/src/app/static-websites`:
|
|
164
|
+
|
|
165
|
+
```hcl {5-6}
|
|
166
|
+
module "static_website" {
|
|
167
|
+
source = "../../../core/static-website"
|
|
168
|
+
website_name = "my-website"
|
|
169
|
+
website_file_path = ...
|
|
170
|
+
custom_domain_names = ["www.example.com"]
|
|
171
|
+
acm_certificate_arn = "arn:aws:acm:us-east-1:123456789012:certificate/..."
|
|
172
|
+
|
|
173
|
+
providers = {
|
|
174
|
+
aws.us_east_1 = aws.us_east_1
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
```
|
|
178
|
+
</Fragment>
|
|
179
|
+
</Infrastructure>
|
|
180
|
+
|
|
181
|
+
You will also need to create DNS records (for example in Route 53) pointing your domain at the CloudFront distribution.
|
|
182
|
+
|
|
129
183
|
## Implementing your React Website
|
|
130
184
|
|
|
131
185
|
The [React documentation](https://react.dev/learn) is a good place to start to learn the basics of building with React.
|
|
@@ -185,14 +239,14 @@ Configuration from your infrastructure is provided to your website via <Link hre
|
|
|
185
239
|
|
|
186
240
|
<Infrastructure>
|
|
187
241
|
<Fragment slot="cdk">
|
|
188
|
-
The `RuntimeConfig` CDK construct can be used to add and retrieve configuration in your CDK infrastructure. The CDK constructs generated by `@aws/nx-plugin` generators (such as <Link path="guides/trpc">`ts#
|
|
242
|
+
The `RuntimeConfig` CDK construct can be used to add and retrieve configuration in your CDK infrastructure. The CDK constructs generated by `@aws/nx-plugin` generators (such as <Link path="guides/trpc">`ts#api`</Link> and <Link path="guides/fastapi">`py#api`</Link>) will automatically add appropriate values to the `RuntimeConfig`.
|
|
189
243
|
|
|
190
244
|
Your website CDK construct will deploy the `connection` namespace of the runtime configuration as a `runtime-config.json` file to the root of your S3 bucket.
|
|
191
245
|
|
|
192
246
|
```ts title="packages/infra/src/stacks/application-stack.ts"
|
|
193
247
|
import { Stack } from 'aws-cdk-lib';
|
|
194
248
|
import { Construct } from 'constructs';
|
|
195
|
-
import { MyWebsite, MyApi } from '
|
|
249
|
+
import { MyWebsite, MyApi } from '@my-scope/common-constructs';
|
|
196
250
|
|
|
197
251
|
export class ApplicationStack extends Stack {
|
|
198
252
|
constructor(scope: Construct, id: string) {
|
|
@@ -214,11 +268,11 @@ With CDK, the website construct can be declared at any point in your stack. Runt
|
|
|
214
268
|
:::
|
|
215
269
|
</Fragment>
|
|
216
270
|
<Fragment slot="terraform">
|
|
217
|
-
With Terraform, runtime configuration is managed through the runtime-config modules. The Terraform modules generated by `@aws/nx-plugin` generators (such as <Link path="guides/trpc">`ts#
|
|
271
|
+
With Terraform, runtime configuration is managed through the runtime-config modules. The Terraform modules generated by `@aws/nx-plugin` generators (such as <Link path="guides/trpc">`ts#api`</Link> and <Link path="guides/fastapi">`py#api`</Link>) will automatically add appropriate values to the runtime configuration.
|
|
218
272
|
|
|
219
273
|
Your website Terraform module will deploy the `connection` namespace of the runtime configuration as a `runtime-config.json` file to the root of your S3 bucket.
|
|
220
274
|
|
|
221
|
-
```hcl title="packages/infra/src/main.tf" {
|
|
275
|
+
```hcl title="packages/infra/src/main.tf" {20-21}
|
|
222
276
|
module "asset_bucket" {
|
|
223
277
|
source = "../../common/terraform/src/core/asset-bucket"
|
|
224
278
|
}
|
|
@@ -272,26 +326,30 @@ For details on how runtime configuration is stored in AWS AppConfig and how serv
|
|
|
272
326
|
|
|
273
327
|
When running the [local development server](#local-development-server), you will need a `runtime-config.json` file in your `public` directory in order for your local website to know the backend URLs, identity configuration, etc.
|
|
274
328
|
|
|
275
|
-
Your website project is configured with a `load
|
|
329
|
+
Your website project is configured with a `load-runtime-config` target which you can use to pull down the `runtime-config.json` file from a deployed application:
|
|
276
330
|
|
|
277
|
-
<NxCommands commands={['
|
|
331
|
+
<NxCommands commands={['load-runtime-config <my-website>']} />
|
|
278
332
|
|
|
279
333
|
:::note[Custom Stage Names]
|
|
280
334
|
<Infrastructure>
|
|
281
335
|
<Fragment slot="cdk">
|
|
282
|
-
If you change the prefix for your stage names in your infrastructure project's `src/main.ts`, you will need to update the `load
|
|
336
|
+
If you change the prefix for your stage names in your infrastructure project's `src/main.ts`, you will need to update the `load-runtime-config` target in your website's `project.json` file accordingly.
|
|
283
337
|
|
|
284
|
-
Additionally it's worth noting that the `load
|
|
338
|
+
Additionally it's worth noting that the `load-runtime-config` target assumes a single stage of your application is deployed to the environment you have AWS credentials for. You will need to adjust the command if you deploy multiple stages to the same account and region.
|
|
285
339
|
</Fragment>
|
|
286
340
|
<Fragment slot="terraform">
|
|
287
|
-
For Terraform projects, the `load
|
|
341
|
+
For Terraform projects, the `load-runtime-config` target copies the `runtime-config.json` file that was created after your most recent local `terraform apply`.
|
|
288
342
|
</Fragment>
|
|
289
343
|
</Infrastructure>
|
|
290
344
|
:::
|
|
291
345
|
|
|
292
346
|
## Local Development Server
|
|
293
347
|
|
|
294
|
-
|
|
348
|
+
The canonical command for local development is `dev`, which starts your website (and any local servers for APIs you've connected it to) with one command:
|
|
349
|
+
|
|
350
|
+
<NxCommands commands={['dev <my-website>']} />
|
|
351
|
+
|
|
352
|
+
The `serve` target is also available for when you need to control how much of your application runs locally versus pointing at deployed AWS infrastructure. For a broader overview of local development across connected projects, including how `dev` behaves for projects with multiple components, see the <Link path="guides/local-development">Local Development</Link> guide.
|
|
295
353
|
|
|
296
354
|
### Serve Target
|
|
297
355
|
|
|
@@ -303,46 +361,50 @@ You can run this target with the following command:
|
|
|
303
361
|
|
|
304
362
|
This target is useful for working on website changes while pointing to "real" deployed APIs and other infrastructure.
|
|
305
363
|
|
|
306
|
-
###
|
|
364
|
+
### Dev Target
|
|
307
365
|
|
|
308
|
-
The `
|
|
366
|
+
The `dev` target starts a local development server for your website (with [Vite `MODE`](https://vite.dev/guide/env-and-mode) set to `local-dev`), as well as starting any local servers for APIs you have connected your website to via the <Link path="/guides/connection">Connection generator</Link>.
|
|
309
367
|
|
|
310
368
|
When your local website server is run via this target, `runtime-config.json` is automatically overridden to point to your locally running API urls.
|
|
311
369
|
|
|
312
370
|
You can run this target with the following command:
|
|
313
371
|
|
|
314
|
-
<NxCommands commands={['
|
|
372
|
+
<NxCommands commands={['dev <my-website>']} />
|
|
315
373
|
|
|
316
374
|
This target is useful when you are working across your website and API and wish to quickly iterate without deploying your infrastructure.
|
|
317
375
|
|
|
318
|
-
:::note[`dev` script]
|
|
319
|
-
|
|
376
|
+
:::note[Workspace `dev` script]
|
|
377
|
+
Your workspace's root `package.json` includes a `dev` script that runs the `dev` target for every project that has one:
|
|
320
378
|
|
|
321
379
|
<PackageManagerShortCommand commands={["dev"]} />
|
|
322
380
|
|
|
323
|
-
This
|
|
381
|
+
This starts the local development server for your website (and any other projects with a `dev` target) in one command. To run just this website, use its own `dev` target (e.g. `nx dev <my-website>`).
|
|
324
382
|
:::
|
|
325
383
|
|
|
326
384
|
:::warning[Mock Authentication]
|
|
327
385
|
When run in this mode and no `runtime-config.json` is present, if you have configured Cognito Authentication (via the <Link path="/guides/react-website-auth">`ts#website#auth` generator</Link>), login will be skipped and requests to your local servers will not include authentication headers.
|
|
328
386
|
|
|
329
|
-
To enable login and authentication for `
|
|
387
|
+
To enable login and authentication for `dev`, deploy your infrastructure and load runtime config.
|
|
330
388
|
:::
|
|
331
389
|
|
|
332
|
-
:::tip[
|
|
333
|
-
When running with `
|
|
390
|
+
:::tip[Dev Behavior]
|
|
391
|
+
When running with `dev`, you can specify any environment variables required by your APIs to point to other deployed AWS resources, for example:
|
|
334
392
|
|
|
335
|
-
<NxCommands env={{DYNAMODB_TABLE_NAME: 'xxxxx'}} commands={['
|
|
393
|
+
<NxCommands env={{DYNAMODB_TABLE_NAME: 'xxxxx'}} commands={['dev <my-website>']} />
|
|
336
394
|
|
|
337
395
|
Note that your local API servers will run with the AWS credentials you have configured locally.
|
|
338
396
|
:::
|
|
339
397
|
|
|
340
398
|
## Building
|
|
341
399
|
|
|
342
|
-
You can build your website using the `build` target. This
|
|
400
|
+
You can build your website using the `build` target. This runs the `bundle`, `compile`, `test` and `lint` targets, type-checking, bundling, testing and linting your website.
|
|
343
401
|
|
|
344
402
|
<NxCommands commands={['build <my-website>']} />
|
|
345
403
|
|
|
404
|
+
The `bundle` target uses Vite to create a production bundle in the root `dist/packages/<my-website>/bundle` directory. This is the deployable artifact consumed by your website infrastructure. You can run it on its own:
|
|
405
|
+
|
|
406
|
+
<NxCommands commands={['bundle <my-website>']} />
|
|
407
|
+
|
|
346
408
|
## Testing
|
|
347
409
|
|
|
348
410
|
Testing your website is much like writing tests in a standard TypeScript project, so please refer to the <Link path="guides/typescript-project#testing">TypeScript project guide</Link> for more details.
|
|
@@ -355,7 +417,7 @@ You can run your tests using the `test` target:
|
|
|
355
417
|
|
|
356
418
|
## Deploying Your Website
|
|
357
419
|
|
|
358
|
-
The React website generator creates CDK or Terraform infrastructure as code based on your selected `
|
|
420
|
+
The React website generator creates CDK or Terraform infrastructure as code based on your selected `iac`. You can use this to deploy your website.
|
|
359
421
|
|
|
360
422
|
<Infrastructure>
|
|
361
423
|
<Fragment slot="cdk">
|
|
@@ -366,7 +428,7 @@ You can use the CDK construct generated for you in `packages/common/constructs`
|
|
|
366
428
|
```ts title="packages/infra/src/stacks/application-stack.ts" {3, 9}
|
|
367
429
|
import { Stack } from 'aws-cdk-lib';
|
|
368
430
|
import { Construct } from 'constructs';
|
|
369
|
-
import { MyWebsite } from '
|
|
431
|
+
import { MyWebsite } from '@my-scope/common-constructs';
|
|
370
432
|
|
|
371
433
|
export class ApplicationStack extends Stack {
|
|
372
434
|
constructor(scope: Construct, id: string) {
|
|
@@ -386,7 +448,7 @@ This sets up:
|
|
|
386
448
|
5. Automatic deployment of website files and runtime configuration
|
|
387
449
|
</Fragment>
|
|
388
450
|
<Fragment slot="terraform">
|
|
389
|
-
To deploy your website, we recommend using the <Link path="guides/terraform-
|
|
451
|
+
To deploy your website, we recommend using the <Link path="/guides/terraform-project">`terraform#project` generator</Link> to create a Terraform project.
|
|
390
452
|
|
|
391
453
|
You can use the Terraform module generated for you in `packages/common/terraform` to deploy your website.
|
|
392
454
|
|
|
@@ -422,3 +484,60 @@ provider "aws" {
|
|
|
422
484
|
</Fragment>
|
|
423
485
|
</Infrastructure>
|
|
424
486
|
|
|
487
|
+
## Connections
|
|
488
|
+
|
|
489
|
+
Use the <Link path="guides/connection">`connection`</Link> generator to integrate this project with others in your workspace. The following connections involve this project:
|
|
490
|
+
|
|
491
|
+
<CardGrid>
|
|
492
|
+
<ConnectionCard
|
|
493
|
+
title="React to tRPC"
|
|
494
|
+
description="Call a tRPC API from a React website"
|
|
495
|
+
href={`/nx-plugin-for-aws/${Astro.currentLocale || 'en'}/guides/connection/react-trpc`}
|
|
496
|
+
source="react"
|
|
497
|
+
target="trpc"
|
|
498
|
+
/>
|
|
499
|
+
<ConnectionCard
|
|
500
|
+
title="React to FastAPI"
|
|
501
|
+
description="Call a Python FastAPI from a React website"
|
|
502
|
+
href={`/nx-plugin-for-aws/${Astro.currentLocale || 'en'}/guides/connection/react-fastapi`}
|
|
503
|
+
source="react"
|
|
504
|
+
target="fastapi"
|
|
505
|
+
/>
|
|
506
|
+
<ConnectionCard
|
|
507
|
+
title="React to Smithy API"
|
|
508
|
+
description="Call a Smithy API from a React website"
|
|
509
|
+
href={`/nx-plugin-for-aws/${Astro.currentLocale || 'en'}/guides/connection/react-smithy`}
|
|
510
|
+
source="react"
|
|
511
|
+
target="smithy"
|
|
512
|
+
/>
|
|
513
|
+
<ConnectionCard
|
|
514
|
+
title="React to Python Agent"
|
|
515
|
+
description="Call a Python Agent from a React website"
|
|
516
|
+
href={`/nx-plugin-for-aws/${Astro.currentLocale || 'en'}/guides/connection/react-py-agent`}
|
|
517
|
+
source="react"
|
|
518
|
+
target="strands"
|
|
519
|
+
targetBadge="python"
|
|
520
|
+
/>
|
|
521
|
+
<ConnectionCard
|
|
522
|
+
title="React to TypeScript Agent"
|
|
523
|
+
description="Call a TypeScript Agent from a React website"
|
|
524
|
+
href={`/nx-plugin-for-aws/${Astro.currentLocale || 'en'}/guides/connection/react-ts-agent`}
|
|
525
|
+
source="react"
|
|
526
|
+
target="strands"
|
|
527
|
+
targetBadge="typescript"
|
|
528
|
+
/>
|
|
529
|
+
<ConnectionCard
|
|
530
|
+
title="React to AG-UI Agent"
|
|
531
|
+
description="Call an Agent exposing the AG-UI protocol from a React website via CopilotKit"
|
|
532
|
+
href={`/nx-plugin-for-aws/${Astro.currentLocale || 'en'}/guides/connection/react-agui`}
|
|
533
|
+
source="react"
|
|
534
|
+
target="copilotkit"
|
|
535
|
+
/>
|
|
536
|
+
<ConnectionCard
|
|
537
|
+
title="React Website to AgentCore Gateway"
|
|
538
|
+
description="Connect a React website to agents through an AgentCore Gateway"
|
|
539
|
+
href={`/nx-plugin-for-aws/${Astro.currentLocale || 'en'}/guides/connection/react-agentcore-gateway`}
|
|
540
|
+
source="react"
|
|
541
|
+
target="agentcore"
|
|
542
|
+
/>
|
|
543
|
+
</CardGrid>
|
|
@@ -70,7 +70,7 @@ Generated constructs automatically write relevant configuration to the `connecti
|
|
|
70
70
|
The `RuntimeConfig` CDK construct is a stage-scoped singleton. Use `set()` to write a key into a namespace:
|
|
71
71
|
|
|
72
72
|
```ts title="packages/infra/src/stacks/application-stack.ts"
|
|
73
|
-
import { RuntimeConfig } from '
|
|
73
|
+
import { RuntimeConfig } from '@my-scope/common-constructs';
|
|
74
74
|
|
|
75
75
|
const rc = RuntimeConfig.ensure(this);
|
|
76
76
|
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Security
|
|
3
|
+
description: Security features included in projects generated by the Nx Plugin for AWS
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
import Link from '@components/link.astro';
|
|
7
|
+
|
|
8
|
+
:::caution[Reporting Security Issues]
|
|
9
|
+
To report a potential security issue in the Nx Plugin for AWS itself, please refer to [SECURITY.md](https://github.com/awslabs/nx-plugin-for-aws/blob/main/SECURITY.md) — do not create a public GitHub issue.
|
|
10
|
+
:::
|
|
11
|
+
|
|
12
|
+
## Security Controls
|
|
13
|
+
|
|
14
|
+
Projects scaffolded by the Nx Plugin for AWS include a number of security controls out of the box. This page provides an overview of those controls and links to the relevant guides for more detail.
|
|
15
|
+
|
|
16
|
+
### Infrastructure Scanning
|
|
17
|
+
|
|
18
|
+
Infrastructure projects are configured with [Checkov](https://www.checkov.io/) as part of the `build` target, so insecure infrastructure configuration fails the build:
|
|
19
|
+
|
|
20
|
+
- CDK projects synthesize CloudFormation templates which are scanned by Checkov. See <Link path="/guides/typescript-infrastructure#security-testing">Security Testing</Link> for details.
|
|
21
|
+
- Terraform projects run Checkov directly against your Terraform code. See <Link path="/guides/terraform-project">Terraform Projects</Link>.
|
|
22
|
+
|
|
23
|
+
Where vended infrastructure suppresses a Checkov rule, the suppression is scoped to the specific resource and annotated with a justification. The shared `suppressRules` helper requires a reason for every suppression, and we recommend following the same practice in your own code. See <Link path="/guides/typescript-infrastructure#suppressing-checkov-checks">Suppressing Checkov Checks</Link>.
|
|
24
|
+
|
|
25
|
+
### Container Image Scanning
|
|
26
|
+
|
|
27
|
+
Projects which build container images (for example agents, MCP servers, and database migration images) include a `trivy` target which scans images for HIGH and CRITICAL vulnerabilities, exiting non-zero on findings. See <Link path="/guides/docker-bundling">Docker Bundling</Link> for details, including how to suppress findings with a `.trivyignore` file.
|
|
28
|
+
|
|
29
|
+
### Credential Scanning
|
|
30
|
+
|
|
31
|
+
Workspaces include [git-secrets](https://github.com/awslabs/git-secrets) pre-commit hooks which scan staged files for AWS credential patterns, preventing accidental commits of access keys and other sensitive values. See the <Link path="/guides/workspace#git-secrets">Git Secrets</Link> section of the workspace guide.
|
|
32
|
+
|
|
33
|
+
### Authentication
|
|
34
|
+
|
|
35
|
+
APIs, agents, and MCP servers use AWS IAM (SigV4) authentication by default:
|
|
36
|
+
|
|
37
|
+
- <Link path="/guides/trpc">tRPC</Link>, <Link path="/guides/fastapi">FastAPI</Link>, and <Link path="/guides/ts-smithy-api">Smithy</Link> APIs default to IAM authentication, with Cognito and custom authorizers available as options. The vended custom authorizer stub denies requests by default.
|
|
38
|
+
- <Link path="/guides/ts-agent">Agents</Link> and <Link path="/guides/ts-mcp-server">MCP servers</Link> deployed to Amazon Bedrock AgentCore Runtime use IAM (SigV4) authentication by default, with JWT-based Cognito authentication as an option.
|
|
39
|
+
- The <Link path="/guides/react-website-auth">website auth generator</Link> vends an Amazon Cognito user pool with multi-factor authentication (MFA) required, a strong password policy, and deletion protection enabled.
|
|
40
|
+
|
|
41
|
+
### Encryption
|
|
42
|
+
|
|
43
|
+
Vended infrastructure encrypts data in transit and at rest:
|
|
44
|
+
|
|
45
|
+
- Websites are served via CloudFront with HTTP redirected to HTTPS, and a response headers policy including HTTP Strict Transport Security (HSTS), a Content Security Policy, and other <Link path="/guides/react-website#security-headers">security headers</Link>. A WAF with AWS managed rules is associated with the distribution.
|
|
46
|
+
- S3 buckets block all public access, enforce SSL-only access via bucket policies, are encrypted (KMS with key rotation for website content), and deliver server access logs to CloudWatch log groups encrypted with customer-managed KMS keys, where they can be queried with Logs Insights and alarmed on.
|
|
47
|
+
- API access logs are written to CloudWatch log groups encrypted with customer-managed KMS keys with rotation enabled.
|
|
48
|
+
- <Link path="/guides/ts-rdb">Aurora databases</Link> enable storage encryption with a customer-managed KMS key, generate credentials in AWS Secrets Manager (never hardcoded), and support automatic credential rotation.
|
|
49
|
+
|
|
50
|
+
### Least Privilege
|
|
51
|
+
|
|
52
|
+
Vended CDK constructs and Terraform modules follow least privilege:
|
|
53
|
+
|
|
54
|
+
- Constructs expose `grant*` methods (for example `grantInvokeAccess` on APIs and agents, `grantConnect` on databases) so consumers grant only the access they need.
|
|
55
|
+
- IAM policies in vended infrastructure are scoped to specific resources and actions. Where a wildcard resource is required by the AWS service (for example `ecr:GetAuthorizationToken`), it is limited to those actions and scoped with conditions where supported.
|
|
56
|
+
|
|
57
|
+
### Dependency Licensing
|
|
58
|
+
|
|
59
|
+
The <Link path="/guides/license">license generator</Link> configures automated license header management and dependency license checking against an allowlist of approved licenses, helping you catch problematic transitive dependencies before they ship.
|
|
60
|
+
|
|
61
|
+
## Responsibility
|
|
62
|
+
|
|
63
|
+
Security and compliance is a shared responsibility. AWS describes this through the [Shared Responsibility Model](https://aws.amazon.com/compliance/shared-responsibility-model/), which distinguishes between security *of* the cloud (the responsibility of AWS) and security *in* the cloud (your responsibility as the customer).
|
|
64
|
+
|
|
65
|
+
The Nx Plugin for AWS helps you address parts of your side of that model. Its generators vend secure foundations and encode AWS best practices within the scope of the code they produce — the controls described above. This reduces the effort required to build securely, but it does not transfer ownership of security to the plugin.
|
|
66
|
+
|
|
67
|
+
**You own the code that is generated into your workspace and remain responsible for its security.** Once vended, generated code is yours to modify, extend, and operate, and it must be treated the same as any other code you author.
|
|
68
|
+
|
|
69
|
+
In particular:
|
|
70
|
+
|
|
71
|
+
- **The scope of the plugin is limited to its generators.** The plugin has no knowledge of your application's business logic, data classification, threat model, or regulatory obligations, and cannot make decisions that depend on them.
|
|
72
|
+
- **Authentication is configured, but authorization is not.** APIs are protected with authentication by default (for example IAM/SigV4), but the plugin cannot determine *which* authenticated principals should be permitted to perform *which* operations on *which* resources. Fine-grained authorization depends on your business logic and must be designed, implemented, and tested by you.
|
|
73
|
+
- **Generated code is a starting point, not a finished product.** As you add functionality, you introduce security considerations the plugin cannot anticipate — input validation, data handling, secrets management, dependency choices, and integrations with other systems.
|
|
74
|
+
|
|
75
|
+
Accordingly, you should review generated code and the applications you build on top of it in line with your own organisation's security policies, standards, and review processes, and subject them to the same threat modelling, security testing, and approval gates you apply to any production workload. The controls vended by the plugin are intended to complement those processes, not to replace them.
|
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Smithy Projects
|
|
3
|
+
description: Reference documentation for the Smithy project generator
|
|
4
|
+
generator: smithy#project
|
|
5
|
+
---
|
|
6
|
+
import { FileTree, Steps } from '@astrojs/starlight/components';
|
|
7
|
+
import RunGenerator from '@components/run-generator.astro';
|
|
8
|
+
import Link from '@components/link.astro';
|
|
9
|
+
import GeneratorParameters from '@components/generator-parameters.astro';
|
|
10
|
+
import NxCommands from '@components/nx-commands.astro';
|
|
11
|
+
import OptionFilter from '@components/option-filter.astro';
|
|
12
|
+
|
|
13
|
+
[Smithy](https://smithy.io/) is an interface definition language for describing services and the data they exchange. The Smithy project generator creates a project containing a Smithy model.
|
|
14
|
+
|
|
15
|
+
There are two kinds of Smithy project:
|
|
16
|
+
|
|
17
|
+
- **Service** (`--type=service`) — a model which defines a service and its operations. This is what the <Link path="guides/ts-smithy-api">`ts#api --framework=smithy` generator</Link> creates for you alongside a TypeScript implementation.
|
|
18
|
+
- **Shape library** (`--type=shapes`) — a model which defines reusable shapes but no service. Connect a shape library to your Smithy projects to share shapes between them, rather than duplicating the definitions in each.
|
|
19
|
+
|
|
20
|
+
:::tip
|
|
21
|
+
If you want an API with an implementation, use the <Link path="guides/ts-smithy-api">`ts#api` generator</Link> instead. It creates a Smithy model project _and_ a TypeScript server which implements it.
|
|
22
|
+
:::
|
|
23
|
+
|
|
24
|
+
## Usage
|
|
25
|
+
|
|
26
|
+
### Generate a Smithy Project
|
|
27
|
+
|
|
28
|
+
<RunGenerator generator="smithy#project" requiredParameters={{ name: 'my-shapes' }} />
|
|
29
|
+
|
|
30
|
+
### Options
|
|
31
|
+
|
|
32
|
+
<GeneratorParameters generator="smithy#project" />
|
|
33
|
+
|
|
34
|
+
## Generator Output
|
|
35
|
+
|
|
36
|
+
<OptionFilter when={{ type: 'shapes' }} description="Shape library: a model with no service">
|
|
37
|
+
|
|
38
|
+
### Shape Library
|
|
39
|
+
|
|
40
|
+
<FileTree>
|
|
41
|
+
|
|
42
|
+
- my-shapes
|
|
43
|
+
- src
|
|
44
|
+
- main.smithy Your shared shape definitions
|
|
45
|
+
- smithy-build.json Smithy build configuration
|
|
46
|
+
- project.json Project configuration and build targets
|
|
47
|
+
|
|
48
|
+
</FileTree>
|
|
49
|
+
|
|
50
|
+
A shape library defines shapes and nothing else:
|
|
51
|
+
|
|
52
|
+
```smithy
|
|
53
|
+
$version: "2.0"
|
|
54
|
+
|
|
55
|
+
namespace com.example
|
|
56
|
+
|
|
57
|
+
structure Customer {
|
|
58
|
+
@required
|
|
59
|
+
id: String
|
|
60
|
+
|
|
61
|
+
name: String
|
|
62
|
+
email: String
|
|
63
|
+
}
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
Since a shape library has no service, its `smithy-build.json` configures no code generation — building it validates the model and assembles it into a single JSON model file at `dist/<my-shapes>/build/model.json`.
|
|
67
|
+
|
|
68
|
+
</OptionFilter>
|
|
69
|
+
|
|
70
|
+
<OptionFilter when={{ type: 'service' }} description="Service: a model which defines a service and its operations">
|
|
71
|
+
|
|
72
|
+
### Service
|
|
73
|
+
|
|
74
|
+
<FileTree>
|
|
75
|
+
|
|
76
|
+
- my-service
|
|
77
|
+
- src
|
|
78
|
+
- main.smithy Your service definition
|
|
79
|
+
- operations
|
|
80
|
+
- echo.smithy An example operation
|
|
81
|
+
- smithy-build.json Smithy build configuration, including code generation
|
|
82
|
+
- ssdk.rolldown.config.mjs Bundles the generated TypeScript Server SDK
|
|
83
|
+
- project.json Project configuration and build targets
|
|
84
|
+
|
|
85
|
+
</FileTree>
|
|
86
|
+
|
|
87
|
+
A service model defines a service shape and the operations it exposes:
|
|
88
|
+
|
|
89
|
+
```smithy
|
|
90
|
+
$version: "2.0"
|
|
91
|
+
|
|
92
|
+
namespace com.example
|
|
93
|
+
|
|
94
|
+
use aws.protocols#restJson1
|
|
95
|
+
|
|
96
|
+
@title("MyService")
|
|
97
|
+
@restJson1
|
|
98
|
+
service MyService {
|
|
99
|
+
version: "1.0.0"
|
|
100
|
+
operations: [
|
|
101
|
+
Echo
|
|
102
|
+
]
|
|
103
|
+
}
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
Building a service project generates an OpenAPI specification and a TypeScript Server SDK into `dist/<my-service>/build/`.
|
|
107
|
+
|
|
108
|
+
</OptionFilter>
|
|
109
|
+
|
|
110
|
+
## Building
|
|
111
|
+
|
|
112
|
+
Smithy projects build with the [Smithy CLI](https://smithy.io/2.0/guides/smithy-cli/index.html), which validates your model:
|
|
113
|
+
|
|
114
|
+
<NxCommands commands={['build my-shapes']} />
|
|
115
|
+
|
|
116
|
+
On macOS and Linux the CLI is resolved by [mise](https://mise.jdx.dev/), which the build fetches on demand, so there is nothing to install — it downloads and caches the pinned version the first time you build. On Windows it is a prerequisite you install yourself — see <Link path="guides/ts-smithy-api#building-on-windows">Building on Windows</Link>.
|
|
117
|
+
|
|
118
|
+
## Depending on a Shape Library
|
|
119
|
+
|
|
120
|
+
Building a shape library writes an assembled model to `dist/<my-shapes>/build/model.json`. This single file contains every shape the library defines, along with any it depends on, so a consumer only ever declares the libraries it references directly.
|
|
121
|
+
|
|
122
|
+
To depend on a shape library from another Smithy project, make two changes to the consuming project:
|
|
123
|
+
|
|
124
|
+
<Steps>
|
|
125
|
+
|
|
126
|
+
1. Add the library's built model to `imports` in the consuming project's `smithy-build.json`. Paths are relative to that file, so the number of `../` segments matches how deeply the consuming project is nested — three for `packages/my-api/model` below:
|
|
127
|
+
|
|
128
|
+
```json ins={4}
|
|
129
|
+
{
|
|
130
|
+
"version": "1.0",
|
|
131
|
+
"sources": ["src/"],
|
|
132
|
+
"imports": ["../../../dist/packages/my-shapes/build/model.json"],
|
|
133
|
+
...
|
|
134
|
+
}
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
2. Add the library's `build` target as a dependency of the consuming project's `compile` target in its `project.json`, so the model exists before the consumer builds:
|
|
138
|
+
|
|
139
|
+
```json ins={4}
|
|
140
|
+
{
|
|
141
|
+
"targets": {
|
|
142
|
+
"compile": {
|
|
143
|
+
"dependsOn": ["@my-scope/my-shapes:build"],
|
|
144
|
+
...
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
</Steps>
|
|
151
|
+
|
|
152
|
+
Your model can now reference the library's shapes with `use`:
|
|
153
|
+
|
|
154
|
+
```smithy
|
|
155
|
+
$version: "2.0"
|
|
156
|
+
|
|
157
|
+
namespace com.example.api
|
|
158
|
+
|
|
159
|
+
use com.example.shared#Customer
|
|
160
|
+
|
|
161
|
+
structure GetCustomerOutput {
|
|
162
|
+
@required
|
|
163
|
+
customer: Customer
|
|
164
|
+
}
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
Shape libraries can depend on other shape libraries the same way. Since each library's built model already contains its own dependencies, you only need to repeat these steps for the libraries you reference directly. A library reached by more than one path is resolved once — Smithy ignores duplicate but equivalent shape definitions.
|
|
@@ -84,7 +84,7 @@ Application projects include full deployment capabilities with remote state mana
|
|
|
84
84
|
|
|
85
85
|
You can start writing your Terraform infrastructure inside `src/main.tf`, for example:
|
|
86
86
|
|
|
87
|
-
```diff title="src/main.tf" {
|
|
87
|
+
```diff title="src/main.tf" {16-19}
|
|
88
88
|
-locals {
|
|
89
89
|
- account_id = data.aws_caller_identity.current.account_id
|
|
90
90
|
- aws_region = data.aws_region.current.id
|
|
@@ -108,7 +108,7 @@ You can start writing your Terraform infrastructure inside `src/main.tf`, for ex
|
|
|
108
108
|
|
|
109
109
|
### Cross project dependencies
|
|
110
110
|
|
|
111
|
-
If you wanted to execute a module from a
|
|
111
|
+
If you wanted to execute a module from a separate project (lib), you could do so as follows:
|
|
112
112
|
|
|
113
113
|
```
|
|
114
114
|
module "lib_module" {
|