@aws/nx-plugin 1.0.0-rc.0 → 1.0.0-rc.2
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/generators.json +10 -5
- package/package.json +1 -1
- package/src/connection/generator.js +2 -2
- package/src/connection/generator.js.map +1 -1
- package/src/infra/app/__snapshots__/generator.spec.ts.snap +11 -11
- package/src/infra/app/files/app/src/main.ts.template +2 -2
- package/src/infra/app/generator.js +9 -9
- package/src/infra/app/generator.js.map +1 -1
- package/src/infra/app/schema.d.ts +1 -1
- package/src/infra/app/schema.json +1 -1
- package/src/mcp-server/guide-pipeline.js +8 -10
- package/src/mcp-server/guide-pipeline.js.map +1 -1
- package/src/mcp-server/tools/create-workspace-command.js +1 -1
- package/src/mcp-server/tools/create-workspace-command.js.map +1 -1
- package/src/mcp-server/tools/generator-guide.js +2 -2
- package/src/mcp-server/tools/generator-guide.js.map +1 -1
- package/src/preset/__snapshots__/generator.spec.ts.snap +1 -1
- package/src/preset/generator.d.ts +1 -1
- package/src/preset/generator.js +4 -6
- package/src/preset/generator.js.map +1 -1
- package/src/preset/schema.d.ts +5 -5
- package/src/preset/schema.json +4 -4
- package/src/py/agent/__snapshots__/generator.spec.ts.snap +1 -1
- package/src/py/agent/a2a-connection/generator.js +4 -3
- package/src/py/agent/a2a-connection/generator.js.map +1 -1
- package/src/py/agent/files/deploy/Dockerfile.template +3 -3
- package/src/py/agent/generator.js +23 -23
- package/src/py/agent/generator.js.map +1 -1
- package/src/py/agent/mcp-connection/generator.js +1 -1
- package/src/py/agent/mcp-connection/generator.js.map +1 -1
- package/src/py/agent/react-connection/__snapshots__/generator.spec.ts.snap +3 -3
- package/src/py/agent/react-connection/generator.js +4 -4
- package/src/py/agent/react-connection/generator.js.map +1 -1
- package/src/py/agent/schema.d.ts +8 -8
- package/src/py/agent/schema.json +18 -18
- package/src/py/api/generator.js +2 -2
- package/src/py/api/generator.js.map +1 -1
- package/src/py/api/schema.d.ts +4 -6
- package/src/py/api/schema.json +15 -15
- package/src/py/fast-api/__snapshots__/generator.spec.ts.snap +6 -6
- package/src/py/fast-api/generator.js +50 -38
- package/src/py/fast-api/generator.js.map +1 -1
- package/src/py/fast-api/react/generator.js +1 -1
- package/src/py/fast-api/react/generator.js.map +1 -1
- package/src/py/fast-api/schema.d.ts +4 -6
- package/src/py/fast-api/schema.json +15 -15
- package/src/py/lambda-function/__snapshots__/generator.spec.ts.snap +2 -2
- package/src/py/lambda-function/files/handler/__lambdaFunctionSnakeCase__.py.template +6 -6
- package/src/py/lambda-function/generator.js +23 -20
- package/src/py/lambda-function/generator.js.map +1 -1
- package/src/py/lambda-function/schema.d.ts +7 -4
- package/src/py/lambda-function/schema.json +15 -7
- package/src/py/mcp-server/__snapshots__/generator.spec.ts.snap +1 -1
- package/src/py/mcp-server/generator.js +11 -11
- package/src/py/mcp-server/generator.js.map +1 -1
- package/src/py/mcp-server/schema.d.ts +5 -9
- package/src/py/mcp-server/schema.json +15 -15
- package/src/py/project/generator.js +1 -1
- package/src/py/project/generator.js.map +1 -1
- package/src/py/project/schema.d.ts +1 -1
- package/src/py/project/schema.json +2 -2
- package/src/smithy/project/generator.js +2 -2
- package/src/smithy/project/generator.js.map +1 -1
- package/src/smithy/react-connection/generator.js +1 -1
- package/src/smithy/react-connection/generator.js.map +1 -1
- package/src/smithy/ts/api/__snapshots__/generator.spec.ts.snap +4 -4
- package/src/smithy/ts/api/generator.js +72 -55
- package/src/smithy/ts/api/generator.js.map +1 -1
- package/src/smithy/ts/api/schema.d.ts +4 -6
- package/src/smithy/ts/api/schema.json +15 -15
- package/src/terraform/project/generator.js +1 -1
- package/src/terraform/project/generator.js.map +1 -1
- package/src/trpc/backend/__snapshots__/generator.spec.ts.snap +6 -6
- package/src/trpc/backend/files/src/client/index.ts.template +5 -5
- package/src/trpc/backend/files/src/handler.ts.template +2 -2
- package/src/trpc/backend/generator.js +69 -51
- package/src/trpc/backend/generator.js.map +1 -1
- package/src/trpc/backend/schema.d.ts +4 -4
- package/src/trpc/backend/schema.json +15 -15
- package/src/trpc/react/__snapshots__/generator.spec.ts.snap +3 -3
- package/src/trpc/react/files/src/components/__apiNameClassName__ClientProvider.tsx.template +14 -14
- package/src/trpc/react/generator.js +6 -5
- package/src/trpc/react/generator.js.map +1 -1
- package/src/ts/agent/__snapshots__/generator.spec.ts.snap +1 -1
- package/src/ts/agent/a2a-connection/generator.js +4 -3
- package/src/ts/agent/a2a-connection/generator.js.map +1 -1
- package/src/ts/agent/files/deploy/Dockerfile.template +1 -1
- package/src/ts/agent/generator.js +22 -22
- package/src/ts/agent/generator.js.map +1 -1
- package/src/ts/agent/mcp-connection/generator.js +1 -1
- package/src/ts/agent/mcp-connection/generator.js.map +1 -1
- package/src/ts/agent/react-connection/files/src/components/__agentNameClassName__AgentClientProvider.tsx.template +8 -8
- package/src/ts/agent/react-connection/generator.js +6 -6
- package/src/ts/agent/react-connection/generator.js.map +1 -1
- package/src/ts/agent/react-connection/serve-local.js +2 -2
- package/src/ts/agent/schema.d.ts +8 -8
- package/src/ts/agent/schema.json +18 -18
- package/src/ts/api/generator.js +6 -4
- package/src/ts/api/generator.js.map +1 -1
- package/src/ts/api/schema.d.ts +4 -4
- package/src/ts/api/schema.json +15 -15
- package/src/ts/lambda-function/__snapshots__/generator.spec.ts.snap +2 -2
- package/src/ts/lambda-function/files/handler/__lambdaFunctionKebabCase__.ts.template +10 -10
- package/src/ts/lambda-function/generator.js +33 -28
- package/src/ts/lambda-function/generator.js.map +1 -1
- package/src/ts/lambda-function/schema.d.ts +7 -4
- package/src/ts/lambda-function/schema.json +15 -7
- package/src/ts/mcp-server/__snapshots__/generator.spec.ts.snap +1 -1
- package/src/ts/mcp-server/generator.js +12 -12
- package/src/ts/mcp-server/generator.js.map +1 -1
- package/src/ts/mcp-server/schema.d.ts +5 -9
- package/src/ts/mcp-server/schema.json +15 -15
- package/src/ts/nx-generator/__snapshots__/generator.spec.ts.snap +1 -1
- package/src/ts/nx-generator/files/nx-plugin-for-aws/generator/generator.spec.ts.template +1 -1
- package/src/ts/nx-plugin/generator.js +2 -2
- package/src/ts/nx-plugin/generator.js.map +1 -1
- package/src/ts/rdb/__snapshots__/generator.spec.ts.snap +2 -2
- package/src/ts/rdb/files/prisma.config.ts.template +1 -1
- package/src/ts/rdb/files/scripts/docker-pull.ts.template +1 -1
- package/src/ts/rdb/files/scripts/docker-start.ts.template +3 -3
- package/src/ts/rdb/files/scripts/wait-for-db.ts.template +3 -3
- package/src/ts/rdb/files/src/create-db-user-handler.ts.template +2 -2
- package/src/ts/rdb/files/src/migration-handler.ts.template +2 -2
- package/src/ts/rdb/files/src/prisma.ts.template +2 -2
- package/src/ts/rdb/generator.js +84 -66
- package/src/ts/rdb/generator.js.map +1 -1
- package/src/ts/rdb/schema.d.ts +5 -5
- package/src/ts/rdb/schema.json +13 -13
- package/src/ts/rdb/trpc-connection/files/src/middleware/__rdbNameKebab__.ts.template +1 -1
- package/src/ts/react-website/agui/files/common/src/hooks/useAgui__agentNameClassName__.tsx.template +9 -9
- package/src/ts/react-website/agui/generator.d.ts +2 -2
- package/src/ts/react-website/agui/generator.js +9 -9
- package/src/ts/react-website/agui/generator.js.map +1 -1
- package/src/ts/react-website/app/__snapshots__/generator.spec.ts.snap +27 -25
- package/src/ts/react-website/app/files/app/cloudscape/src/components/AppLayout/index.tsx.template +5 -5
- package/src/ts/react-website/app/files/app/cloudscape/src/main.tsx.template +1 -1
- package/src/ts/react-website/app/files/app/cloudscape/src/styles.css.template +1 -1
- package/src/ts/react-website/app/files/app/none/src/components/AppLayout/index.tsx.template +5 -5
- package/src/ts/react-website/app/files/app/none/src/main.tsx.template +1 -1
- package/src/ts/react-website/app/files/app/none/src/styles.css.template +2 -2
- package/src/ts/react-website/app/files/app/shadcn/src/components/AppLayout/index.tsx.template +6 -6
- package/src/ts/react-website/app/files/app/shadcn/src/main.tsx.template +1 -1
- package/src/ts/react-website/app/generator.d.ts +3 -3
- package/src/ts/react-website/app/generator.js +104 -98
- package/src/ts/react-website/app/generator.js.map +1 -1
- package/src/ts/react-website/app/schema.d.ts +9 -6
- package/src/ts/react-website/app/schema.json +13 -13
- package/src/ts/react-website/cognito-auth/__snapshots__/generator.terraform.spec.ts.snap +3 -3
- package/src/ts/react-website/cognito-auth/__snapshots__/generator.ux-provider.spec.ts.snap +3 -3
- package/src/ts/react-website/cognito-auth/generator.js +9 -9
- package/src/ts/react-website/cognito-auth/generator.js.map +1 -1
- package/src/ts/react-website/cognito-auth/schema.d.ts +2 -2
- package/src/ts/react-website/cognito-auth/schema.json +4 -4
- package/src/ts/website/app/schema.d.ts +8 -6
- package/src/ts/website/app/schema.json +21 -13
- package/src/ts/website/auth/generator.js +1 -1
- package/src/ts/website/auth/generator.js.map +1 -1
- package/src/ts/website/auth/schema.d.ts +2 -2
- package/src/ts/website/auth/schema.json +4 -4
- package/src/utils/agent-connection/agent-connection.js +1 -1
- package/src/utils/agent-connection/agent-connection.js.map +1 -1
- package/src/utils/agent-core-constructs/agent-core-constructs.d.ts +9 -9
- package/src/utils/agent-core-constructs/agent-core-constructs.js +11 -13
- package/src/utils/agent-core-constructs/agent-core-constructs.js.map +1 -1
- package/src/utils/agent-core-constructs/files/cdk/app/agent-core/__nameKebabCase__/__nameKebabCase__.ts.template +13 -13
- package/src/utils/agent-core-constructs/files/terraform/app/agent-core/__nameKebabCase__/__nameKebabCase__.tf.template +4 -4
- package/src/utils/agent-core-constructs/files/terraform/core/agent-core/runtime.tf.template +5 -5
- package/src/utils/api-constructs/api-constructs.d.ts +3 -3
- package/src/utils/api-constructs/api-constructs.js +4 -6
- package/src/utils/api-constructs/api-constructs.js.map +1 -1
- package/src/utils/api-constructs/files/cdk/app/apis/http/__apiNameKebabCase__.ts.template +12 -12
- package/src/utils/api-constructs/files/cdk/app/apis/rest/__apiNameKebabCase__.ts.template +12 -12
- package/src/utils/api-constructs/files/terraform/app/apis/http/__apiNameKebabCase__/__apiNameKebabCase__.tf.template +7 -7
- package/src/utils/api-constructs/files/terraform/app/apis/rest/__apiNameKebabCase__/__apiNameKebabCase__.tf.template +10 -10
- package/src/utils/api-constructs/open-api-metadata.d.ts +3 -3
- package/src/utils/api-constructs/open-api-metadata.js +2 -2
- package/src/utils/api-constructs/open-api-metadata.js.map +1 -1
- package/src/utils/commands.d.ts +1 -1
- package/src/utils/commands.js +2 -2
- package/src/utils/commands.js.map +1 -1
- package/src/utils/config/__snapshots__/utils.spec.ts.snap +6 -6
- package/src/utils/config/index.d.ts +2 -2
- package/src/utils/connection/open-api/files/components/__apiNameClassName__Provider.tsx.template +7 -7
- package/src/utils/connection/open-api/react.d.ts +1 -1
- package/src/utils/connection/open-api/react.js +3 -3
- package/src/utils/containers.d.ts +5 -5
- package/src/utils/containers.js +6 -6
- package/src/utils/containers.js.map +1 -1
- package/src/utils/function-constructs/files/cdk/app/lambda-functions/{__functionNameKebabCase__.ts.template → __nameKebabCase__.ts.template} +1 -1
- package/src/utils/function-constructs/files/terraform/app/lambda-functions/{__functionNameKebabCase__/__functionNameKebabCase__.tf.template → __nameKebabCase__/__nameKebabCase__.tf.template} +7 -7
- package/src/utils/function-constructs/function-constructs.d.ts +4 -4
- package/src/utils/function-constructs/function-constructs.js +5 -7
- package/src/utils/function-constructs/function-constructs.js.map +1 -1
- package/src/utils/iac-providers.d.ts +3 -3
- package/src/utils/iac-providers.js +1 -1
- package/src/utils/iac.d.ts +2 -2
- package/src/utils/iac.js +6 -6
- package/src/utils/iac.js.map +1 -1
- package/src/utils/identity-constructs/identity-constructs.d.ts +2 -2
- package/src/utils/identity-constructs/identity-constructs.js +3 -3
- package/src/utils/identity-constructs/identity-constructs.js.map +1 -1
- package/src/utils/rdb-constructs/files/terraform/app/dbs/__nameKebabCase__/__nameKebabCase__.tf.template +4 -4
- package/src/utils/rdb-constructs/rdb-constructs.d.ts +4 -4
- package/src/utils/rdb-constructs/rdb-constructs.js +4 -6
- package/src/utils/rdb-constructs/rdb-constructs.js.map +1 -1
- package/src/utils/shared-constructs.d.ts +2 -2
- package/src/utils/shared-constructs.js +3 -3
- package/src/utils/shared-constructs.js.map +1 -1
- package/src/utils/website-constructs/website-constructs.d.ts +2 -2
- package/src/utils/website-constructs/website-constructs.js +4 -6
- package/src/utils/website-constructs/website-constructs.js.map +1 -1
|
@@ -19,10 +19,10 @@ import {
|
|
|
19
19
|
<%_ if (['trpc', 'fastapi'].includes(backend.type)) { _%>
|
|
20
20
|
ResponseTransferMode,
|
|
21
21
|
<%_ } _%>
|
|
22
|
-
<%_ if (auth === '
|
|
22
|
+
<%_ if (auth === 'cognito') { _%>
|
|
23
23
|
CognitoUserPoolsAuthorizer,
|
|
24
24
|
<%_ } _%>
|
|
25
|
-
<%_ if (auth === '
|
|
25
|
+
<%_ if (auth === 'custom') { _%>
|
|
26
26
|
TokenAuthorizer,
|
|
27
27
|
<%_ } _%>
|
|
28
28
|
} from 'aws-cdk-lib/aws-apigateway';
|
|
@@ -32,12 +32,12 @@ import {
|
|
|
32
32
|
PolicyStatement,
|
|
33
33
|
Effect,
|
|
34
34
|
AnyPrincipal,
|
|
35
|
-
<%_ if (auth === '
|
|
35
|
+
<%_ if (auth === 'iam') { _%>
|
|
36
36
|
IGrantable,
|
|
37
37
|
Grant,
|
|
38
38
|
<%_ } _%>
|
|
39
39
|
} from 'aws-cdk-lib/aws-iam';
|
|
40
|
-
<%_ if (auth === '
|
|
40
|
+
<%_ if (auth === 'cognito') { _%>
|
|
41
41
|
import { IUserPool } from 'aws-cdk-lib/aws-cognito';
|
|
42
42
|
<%_ } _%>
|
|
43
43
|
import {
|
|
@@ -71,7 +71,7 @@ export interface <%= apiNameClassName %>Props<
|
|
|
71
71
|
* Map of operation names to their API Gateway integrations
|
|
72
72
|
*/
|
|
73
73
|
integrations: TIntegrations;
|
|
74
|
-
<%_ if (auth === '
|
|
74
|
+
<%_ if (auth === 'cognito') { _%>
|
|
75
75
|
/**
|
|
76
76
|
* Identity details for Cognito Authentication
|
|
77
77
|
*/
|
|
@@ -195,7 +195,7 @@ export class <%= apiNameClassName %><
|
|
|
195
195
|
id: string,
|
|
196
196
|
props: <%= apiNameClassName %>Props<TIntegrations>,
|
|
197
197
|
) {
|
|
198
|
-
<%_ if (auth === '
|
|
198
|
+
<%_ if (auth === 'custom') { _%>
|
|
199
199
|
const authorizerFunction = new Function(scope, '<%= apiNameClassName %>AuthorizerFunction', {
|
|
200
200
|
<%_ if (['trpc', 'smithy'].includes(backend.type)) { _%>
|
|
201
201
|
runtime: Runtime.NODEJS_LATEST,
|
|
@@ -228,14 +228,14 @@ export class <%= apiNameClassName %><
|
|
|
228
228
|
super(scope, id, {
|
|
229
229
|
apiName: '<%= apiNameClassName %>',
|
|
230
230
|
defaultMethodOptions: {
|
|
231
|
-
<%_ if (auth === '
|
|
231
|
+
<%_ if (auth === 'iam') { _%>
|
|
232
232
|
authorizationType: AuthorizationType.IAM,
|
|
233
|
-
<%_ } else if (auth === '
|
|
233
|
+
<%_ } else if (auth === 'cognito') { _%>
|
|
234
234
|
authorizationType: AuthorizationType.COGNITO,
|
|
235
235
|
authorizer: new CognitoUserPoolsAuthorizer(scope, '<%= apiNameClassName %>Authorizer', {
|
|
236
236
|
cognitoUserPools: [props.identity.userPool],
|
|
237
237
|
}),
|
|
238
|
-
<%_ } else if (auth === '
|
|
238
|
+
<%_ } else if (auth === 'custom') { _%>
|
|
239
239
|
authorizationType: AuthorizationType.CUSTOM,
|
|
240
240
|
authorizer: new TokenAuthorizer(scope, '<%= apiNameClassName %>TokenAuthorizer', {
|
|
241
241
|
handler: authorizerFunction,
|
|
@@ -247,7 +247,7 @@ export class <%= apiNameClassName %><
|
|
|
247
247
|
},
|
|
248
248
|
policy: new PolicyDocument({
|
|
249
249
|
statements: [
|
|
250
|
-
<%_ if (auth === '
|
|
250
|
+
<%_ if (auth === 'iam') { _%>
|
|
251
251
|
// Open up OPTIONS to allow browsers to make unauthenticated preflight requests
|
|
252
252
|
new PolicyStatement({
|
|
253
253
|
effect: Effect.ALLOW,
|
|
@@ -256,7 +256,7 @@ export class <%= apiNameClassName %><
|
|
|
256
256
|
resources: ['execute-api:/*/OPTIONS/*'],
|
|
257
257
|
}),
|
|
258
258
|
<%_ } else { _%>
|
|
259
|
-
// Allow all callers to invoke the API in the resource policy<% if (auth === '
|
|
259
|
+
// Allow all callers to invoke the API in the resource policy<% if (auth === 'cognito') { %>, since auth is handled by Cognito<% } else if (auth === 'custom') { %>, since auth is handled by the Lambda Authorizer<% } %>
|
|
260
260
|
new PolicyStatement({
|
|
261
261
|
effect: Effect.ALLOW,
|
|
262
262
|
principals: [new AnyPrincipal()],
|
|
@@ -308,7 +308,7 @@ export class <%= apiNameClassName %><
|
|
|
308
308
|
}
|
|
309
309
|
});
|
|
310
310
|
}
|
|
311
|
-
<%_ if (auth === '
|
|
311
|
+
<%_ if (auth === 'iam') { _%>
|
|
312
312
|
|
|
313
313
|
/**
|
|
314
314
|
* Grants IAM permissions to invoke any method on this API.
|
|
@@ -9,7 +9,7 @@ terraform {
|
|
|
9
9
|
}
|
|
10
10
|
}
|
|
11
11
|
|
|
12
|
-
<%_ if (auth === '
|
|
12
|
+
<%_ if (auth === 'cognito') { _%>
|
|
13
13
|
# Authentication Configuration
|
|
14
14
|
variable "user_pool_id" {
|
|
15
15
|
description = "Cognito User Pool ID for authentication"
|
|
@@ -254,7 +254,7 @@ resource "aws_lambda_alias" "live" {
|
|
|
254
254
|
}
|
|
255
255
|
<%_ } _%>
|
|
256
256
|
|
|
257
|
-
<%_ if (auth === '
|
|
257
|
+
<%_ if (auth === 'cognito') { _%>
|
|
258
258
|
# Cognito User Pool Authorizer
|
|
259
259
|
resource "aws_apigatewayv2_authorizer" "cognito_authorizer" {
|
|
260
260
|
api_id = module.http_api.api_id
|
|
@@ -267,7 +267,7 @@ resource "aws_apigatewayv2_authorizer" "cognito_authorizer" {
|
|
|
267
267
|
issuer = "https://cognito-idp.${data.aws_region.current.region}.amazonaws.com/${var.user_pool_id}"
|
|
268
268
|
}
|
|
269
269
|
}
|
|
270
|
-
<%_ } else if (auth === '
|
|
270
|
+
<%_ } else if (auth === 'custom') { _%>
|
|
271
271
|
# Custom Lambda Authorizer
|
|
272
272
|
resource "aws_lambda_function" "authorizer_lambda" {
|
|
273
273
|
#checkov:skip=CKV_AWS_117:Lambda function does not need to be in VPC for this use case
|
|
@@ -407,17 +407,17 @@ resource "aws_apigatewayv2_route" "proxy_routes" {
|
|
|
407
407
|
route_key = "${each.key} /{proxy+}"
|
|
408
408
|
target = "integrations/${aws_apigatewayv2_integration.lambda_integration.id}"
|
|
409
409
|
|
|
410
|
-
<%_ if (auth === '
|
|
410
|
+
<%_ if (auth === 'iam') { _%>
|
|
411
411
|
authorization_type = "AWS_IAM"
|
|
412
|
-
<%_ } else if (auth === '
|
|
412
|
+
<%_ } else if (auth === 'cognito') { _%>
|
|
413
413
|
authorization_type = "JWT"
|
|
414
414
|
authorizer_id = aws_apigatewayv2_authorizer.cognito_authorizer.id
|
|
415
|
-
<%_ } else if (auth === '
|
|
415
|
+
<%_ } else if (auth === 'custom') { _%>
|
|
416
416
|
authorization_type = "CUSTOM"
|
|
417
417
|
authorizer_id = aws_apigatewayv2_authorizer.custom_authorizer.id
|
|
418
418
|
<%_ } _%>
|
|
419
419
|
|
|
420
|
-
depends_on = [aws_apigatewayv2_integration.lambda_integration<% if (auth === '
|
|
420
|
+
depends_on = [aws_apigatewayv2_integration.lambda_integration<% if (auth === 'cognito') { %>, aws_apigatewayv2_authorizer.cognito_authorizer<% } else if (auth === 'custom') { %>, aws_apigatewayv2_authorizer.custom_authorizer<% } %>]
|
|
421
421
|
}
|
|
422
422
|
|
|
423
423
|
# Add API url to runtime config
|
|
@@ -9,7 +9,7 @@ terraform {
|
|
|
9
9
|
}
|
|
10
10
|
}
|
|
11
11
|
|
|
12
|
-
<%_ if (auth === '
|
|
12
|
+
<%_ if (auth === 'cognito') { _%>
|
|
13
13
|
# Authentication Configuration
|
|
14
14
|
variable "user_pool_id" {
|
|
15
15
|
description = "Cognito User Pool ID for authentication"
|
|
@@ -251,7 +251,7 @@ resource "aws_lambda_alias" "live" {
|
|
|
251
251
|
}
|
|
252
252
|
<%_ } _%>
|
|
253
253
|
|
|
254
|
-
<%_ if (auth === '
|
|
254
|
+
<%_ if (auth === 'cognito') { _%>
|
|
255
255
|
# Cognito User Pool Authorizer
|
|
256
256
|
resource "aws_api_gateway_authorizer" "cognito_authorizer" {
|
|
257
257
|
name = "<%- apiNameClassName %>Authorizer-${random_string.suffix.result}"
|
|
@@ -260,7 +260,7 @@ resource "aws_api_gateway_authorizer" "cognito_authorizer" {
|
|
|
260
260
|
provider_arns = ["arn:aws:cognito-idp:${data.aws_region.current.region}:${data.aws_caller_identity.current.account_id}:userpool/${var.user_pool_id}"]
|
|
261
261
|
identity_source = "method.request.header.Authorization"
|
|
262
262
|
}
|
|
263
|
-
<%_ } else if (auth === '
|
|
263
|
+
<%_ } else if (auth === 'custom') { _%>
|
|
264
264
|
# Custom Lambda Authorizer
|
|
265
265
|
resource "aws_lambda_function" "authorizer_lambda" {
|
|
266
266
|
#checkov:skip=CKV_AWS_117:Lambda function does not need to be in VPC for this use case
|
|
@@ -408,12 +408,12 @@ resource "aws_api_gateway_method" "proxy_method" {
|
|
|
408
408
|
resource_id = aws_api_gateway_resource.proxy_resource.id
|
|
409
409
|
http_method = "ANY"
|
|
410
410
|
|
|
411
|
-
<%_ if (auth === '
|
|
411
|
+
<%_ if (auth === 'iam') { _%>
|
|
412
412
|
authorization = "AWS_IAM"
|
|
413
|
-
<%_ } else if (auth === '
|
|
413
|
+
<%_ } else if (auth === 'cognito') { _%>
|
|
414
414
|
authorization = "COGNITO_USER_POOLS"
|
|
415
415
|
authorizer_id = aws_api_gateway_authorizer.cognito_authorizer.id
|
|
416
|
-
<%_ } else if (auth === '
|
|
416
|
+
<%_ } else if (auth === 'custom') { _%>
|
|
417
417
|
authorization = "CUSTOM"
|
|
418
418
|
authorizer_id = aws_api_gateway_authorizer.custom_authorizer.id
|
|
419
419
|
<%_ } _%>
|
|
@@ -422,7 +422,7 @@ resource "aws_api_gateway_method" "proxy_method" {
|
|
|
422
422
|
"method.request.path.proxy" = true
|
|
423
423
|
}
|
|
424
424
|
|
|
425
|
-
depends_on = [<% if (auth === '
|
|
425
|
+
depends_on = [<% if (auth === 'cognito') { %>aws_api_gateway_authorizer.cognito_authorizer<% } else if (auth === 'custom') { %>aws_api_gateway_authorizer.custom_authorizer<% } %>]
|
|
426
426
|
}
|
|
427
427
|
|
|
428
428
|
# OPTIONS method for CORS preflight
|
|
@@ -500,7 +500,7 @@ resource "aws_api_gateway_deployment" "api_deployment" {
|
|
|
500
500
|
aws_api_gateway_integration.options_integration,
|
|
501
501
|
aws_api_gateway_method_response.options_response,
|
|
502
502
|
aws_api_gateway_integration_response.options_integration_response,
|
|
503
|
-
<%_ if (auth === '
|
|
503
|
+
<%_ if (auth === 'custom') { _%>
|
|
504
504
|
aws_api_gateway_authorizer.custom_authorizer,
|
|
505
505
|
<%_ } _%>
|
|
506
506
|
]
|
|
@@ -530,7 +530,7 @@ resource "aws_api_gateway_rest_api_policy" "api_policy" {
|
|
|
530
530
|
policy = jsonencode({
|
|
531
531
|
Version = "2012-10-17"
|
|
532
532
|
Statement = [
|
|
533
|
-
<%_ if (auth === '
|
|
533
|
+
<%_ if (auth === 'iam') { _%>
|
|
534
534
|
{
|
|
535
535
|
# Grant any AWS credentials from the account to call the API
|
|
536
536
|
# Machine to machine fine-grained access can be defined here using more specific principals
|
|
@@ -551,7 +551,7 @@ resource "aws_api_gateway_rest_api_policy" "api_policy" {
|
|
|
551
551
|
}
|
|
552
552
|
<%_ } else { _%>
|
|
553
553
|
{
|
|
554
|
-
# Allow all callers to invoke the API in the resource policy<% if (auth === '
|
|
554
|
+
# Allow all callers to invoke the API in the resource policy<% if (auth === 'cognito') { %>, since auth is handled by Cognito<% } else if (auth === 'custom') { %>, since auth is handled by the Lambda Authorizer<% } %>
|
|
555
555
|
Effect = "Allow"
|
|
556
556
|
Principal = "*"
|
|
557
557
|
Action = "execute-api:Invoke"
|
|
@@ -3,9 +3,9 @@
|
|
|
3
3
|
* SPDX-License-Identifier: Apache-2.0
|
|
4
4
|
*/
|
|
5
5
|
import { Tree } from '@nx/devkit';
|
|
6
|
-
import {
|
|
6
|
+
import { Iac } from '../iac';
|
|
7
7
|
export interface AddOpenApiMetadataGenerateTargetOptions {
|
|
8
|
-
|
|
8
|
+
iac: Iac;
|
|
9
9
|
apiNameKebabCase: string;
|
|
10
10
|
specPath: string;
|
|
11
11
|
specBuildTargetName: string;
|
|
@@ -14,4 +14,4 @@ export interface AddOpenApiMetadataGenerateTargetOptions {
|
|
|
14
14
|
* Adds a generate:<api-name>-metadata target to shared constructs (CDK only)
|
|
15
15
|
* This allows for API CDK constructs to have type-safety for integrations based on an OpenAPI Specification
|
|
16
16
|
*/
|
|
17
|
-
export declare const addSharedConstructsOpenApiMetadataGenerateTarget: (tree: Tree, {
|
|
17
|
+
export declare const addSharedConstructsOpenApiMetadataGenerateTarget: (tree: Tree, { iac, apiNameKebabCase, specPath, specBuildTargetName, }: AddOpenApiMetadataGenerateTargetOptions) => void;
|
|
@@ -13,8 +13,8 @@ const shared_constructs_constants_1 = require("../shared-constructs-constants");
|
|
|
13
13
|
* Adds a generate:<api-name>-metadata target to shared constructs (CDK only)
|
|
14
14
|
* This allows for API CDK constructs to have type-safety for integrations based on an OpenAPI Specification
|
|
15
15
|
*/
|
|
16
|
-
const addSharedConstructsOpenApiMetadataGenerateTarget = (tree, {
|
|
17
|
-
if (
|
|
16
|
+
const addSharedConstructsOpenApiMetadataGenerateTarget = (tree, { iac, apiNameKebabCase, specPath, specBuildTargetName, }) => {
|
|
17
|
+
if (iac !== 'cdk') {
|
|
18
18
|
// For Terraform, we do not support type-safe integration builders, rather only the single lambda
|
|
19
19
|
// router pattern, and therefore do not need to add depenencies on metadata generation.
|
|
20
20
|
return;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"open-api-metadata.js","sourceRoot":"","sources":["../../../../../../packages/nx-plugin/src/utils/api-constructs/open-api-metadata.ts"],"names":[],"mappings":";;;AAAA;;;GAGG;AACH,uCAKoB;AAEpB,gCAAyC;AACzC,8BAA0D;AAC1D,gFAGwC;AASxC;;;GAGG;AACI,MAAM,gDAAgD,GAAG,CAC9D,IAAU,EACV,EACE,
|
|
1
|
+
{"version":3,"file":"open-api-metadata.js","sourceRoot":"","sources":["../../../../../../packages/nx-plugin/src/utils/api-constructs/open-api-metadata.ts"],"names":[],"mappings":";;;AAAA;;;GAGG;AACH,uCAKoB;AAEpB,gCAAyC;AACzC,8BAA0D;AAC1D,gFAGwC;AASxC;;;GAGG;AACI,MAAM,gDAAgD,GAAG,CAC9D,IAAU,EACV,EACE,GAAG,EACH,gBAAgB,EAChB,QAAQ,EACR,mBAAmB,GACqB,EAC1C,EAAE;IACF,IAAI,GAAG,KAAK,KAAK,EAAE,CAAC;QAClB,iGAAiG;QACjG,uFAAuF;QACvF,OAAO;IACT,CAAC;IAED,MAAM,oBAAoB,GAAG,IAAA,0BAAiB,EAAC,WAAW,EAAE,gBAAgB,CAAC,CAAC;IAC9E,MAAM,4BAA4B,GAAG,IAAA,0BAAiB,EACpD,IAAA,0BAAiB,EAAC,0CAAY,EAAE,mDAAqB,CAAC,EACtD,KAAK,EACL,oBAAoB,CACrB,CAAC;IAEF,IAAA,mBAAU,EACR,IAAI,EACJ,IAAA,0BAAiB,EAAC,0CAAY,EAAE,mDAAqB,EAAE,cAAc,CAAC,EACtE,CAAC,MAA4B,EAAE,EAAE;QAC/B,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC;YACpB,MAAM,CAAC,OAAO,GAAG,EAAE,CAAC;QACtB,CAAC;QACD,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,KAAK,EAAE,CAAC;YAC1B,MAAM,CAAC,OAAO,CAAC,KAAK,GAAG,EAAE,CAAC;QAC5B,CAAC;QACD,wFAAwF;QACxF,0CAA0C;QAC1C,MAAM,kBAAkB,GAAG,YAAY,gBAAgB,WAAW,CAAC;QACnE,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,kBAAkB,CAAC,EAAE,CAAC;YACxC,MAAM,CAAC,OAAO,CAAC,kBAAkB,CAAC,GAAG;gBACnC,KAAK,EAAE,IAAI;gBACX,QAAQ,EAAE,iBAAiB;gBAC3B,MAAM,EAAE;oBACN;wBACE,yBAAyB,EAAE,WAAW;qBACvC;iBACF;gBACD,OAAO,EAAE;oBACP,IAAA,0BAAiB,EAAC,iBAAiB,EAAE,4BAA4B,CAAC;iBACnE;gBACD,OAAO,EAAE;oBACP,QAAQ,EAAE;wBACR,+DAA+D,QAAQ,mBAAmB,4BAA4B,oBAAoB;qBAC3I;iBACF;gBACD,SAAS,EAAE,CAAC,mBAAmB,CAAC;aACjC,CAAC;QACJ,CAAC;QACD,IAAA,sCAAiC,EAAC,MAAM,EAAE,SAAS,EAAE,kBAAkB,CAAC,CAAC;QACzE,OAAO,MAAM,CAAC;IAChB,CAAC,CACF,CAAC;IAEF,2CAA2C;IAC3C,sFAAsF;IACtF,IAAA,qBAAe,EACb,IAAI,EACJ,IAAA,0BAAiB,EAAC,0CAAY,EAAE,mDAAqB,CAAC,EACtD,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC,GAAG,QAAQ,EAAE,IAAA,0BAAiB,EAAC,KAAK,EAAE,oBAAoB,CAAC,CAAC,CAC5E,CAAC;AACJ,CAAC,CAAC;AAnEW,QAAA,gDAAgD,oDAmE3D"}
|
package/src/utils/commands.d.ts
CHANGED
|
@@ -44,4 +44,4 @@ export declare const buildInstallCommand: (pm: string, pkg: string, dev: boolean
|
|
|
44
44
|
* The package manager is auto-detected by @aws/create-nx-workspace from the
|
|
45
45
|
* invoking command, so --pm is not needed.
|
|
46
46
|
*/
|
|
47
|
-
export declare const buildCreateNxWorkspaceCommand: (pm: string, workspace: string,
|
|
47
|
+
export declare const buildCreateNxWorkspaceCommand: (pm: string, workspace: string, iac?: "cdk" | "terraform", tag?: string) => string;
|
package/src/utils/commands.js
CHANGED
|
@@ -53,7 +53,7 @@ exports.buildInstallCommand = buildInstallCommand;
|
|
|
53
53
|
* The package manager is auto-detected by @aws/create-nx-workspace from the
|
|
54
54
|
* invoking command, so --pm is not needed.
|
|
55
55
|
*/
|
|
56
|
-
const buildCreateNxWorkspaceCommand = (pm, workspace,
|
|
56
|
+
const buildCreateNxWorkspaceCommand = (pm, workspace, iac, tag) => {
|
|
57
57
|
const createPrefix = exports.PACKAGE_MANAGER_COMMANDS[pm]?.create ?? `${pm} create`;
|
|
58
58
|
const pkgName = tag ? `@aws/nx-workspace@${tag}` : '@aws/nx-workspace';
|
|
59
59
|
const parts = [
|
|
@@ -62,7 +62,7 @@ const buildCreateNxWorkspaceCommand = (pm, workspace, iacProvider, tag) => {
|
|
|
62
62
|
// npm requires '--' to stop interpreting subsequent flags as npm config
|
|
63
63
|
...(pm === 'npm' ? ['--'] : []),
|
|
64
64
|
workspace,
|
|
65
|
-
...(
|
|
65
|
+
...(iac ? [`--iac=${iac}`] : []),
|
|
66
66
|
];
|
|
67
67
|
return parts.join(' ');
|
|
68
68
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"commands.js","sourceRoot":"","sources":["../../../../../packages/nx-plugin/src/utils/commands.ts"],"names":[],"mappings":";;;AAsBa,QAAA,wBAAwB,GAGjC;IACF,GAAG,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,GAAG,EAAE,SAAS,EAAE,MAAM,EAAE,YAAY,EAAE;IAC1D,IAAI,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,aAAa,EAAE;IAC1D,IAAI,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,aAAa,EAAE;IAC1D,GAAG,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,KAAK,EAAE,MAAM,EAAE,YAAY,EAAE;CACxD,CAAC;AAE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K,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AACzB,CAAC,CAAC;AAjBW,QAAA,6BAA6B,iCAiBxC"}
|
|
@@ -4,7 +4,7 @@ exports[`config utils > should add multiple new keys to an empty config 1`] = `
|
|
|
4
4
|
"import { AwsNxPluginConfig } from '@aws/nx-plugin';
|
|
5
5
|
|
|
6
6
|
export default {
|
|
7
|
-
iac: { provider: '
|
|
7
|
+
iac: { provider: 'cdk' },
|
|
8
8
|
tags: ['a', 'b'],
|
|
9
9
|
} satisfies AwsNxPluginConfig;
|
|
10
10
|
"
|
|
@@ -31,7 +31,7 @@ export default {
|
|
|
31
31
|
`;
|
|
32
32
|
|
|
33
33
|
exports[`config utils > should handle config without satisfies clause 1`] = `
|
|
34
|
-
"export default { iac: { provider: '
|
|
34
|
+
"export default { iac: { provider: 'cdk' } };
|
|
35
35
|
"
|
|
36
36
|
`;
|
|
37
37
|
|
|
@@ -44,7 +44,7 @@ export default {
|
|
|
44
44
|
content: { lines: [\`Copyright \${new Date().getFullYear()} Foo Inc.\`] },
|
|
45
45
|
},
|
|
46
46
|
},
|
|
47
|
-
iac: { provider: '
|
|
47
|
+
iac: { provider: 'cdk' },
|
|
48
48
|
} satisfies AwsNxPluginConfig;
|
|
49
49
|
"
|
|
50
50
|
`;
|
|
@@ -59,7 +59,7 @@ export default {
|
|
|
59
59
|
content: { lines: [\`Copyright \${new Date().getFullYear()} Acme\`] },
|
|
60
60
|
},
|
|
61
61
|
},
|
|
62
|
-
iac: { provider: '
|
|
62
|
+
iac: { provider: 'terraform' },
|
|
63
63
|
} satisfies AwsNxPluginConfig;
|
|
64
64
|
"
|
|
65
65
|
`;
|
|
@@ -75,7 +75,7 @@ exports[`config utils > should snapshot merged config with multiple keys 1`] = `
|
|
|
75
75
|
"import { AwsNxPluginConfig } from '@aws/nx-plugin';
|
|
76
76
|
|
|
77
77
|
export default {
|
|
78
|
-
iac: { provider: '
|
|
78
|
+
iac: { provider: 'cdk' },
|
|
79
79
|
tags: ['tag1'],
|
|
80
80
|
} satisfies AwsNxPluginConfig;
|
|
81
81
|
"
|
|
@@ -84,7 +84,7 @@ export default {
|
|
|
84
84
|
exports[`config utils > should snapshot simple iac config 1`] = `
|
|
85
85
|
"import { AwsNxPluginConfig } from '@aws/nx-plugin';
|
|
86
86
|
|
|
87
|
-
export default { iac: { provider: '
|
|
87
|
+
export default { iac: { provider: 'cdk' } } satisfies AwsNxPluginConfig;
|
|
88
88
|
"
|
|
89
89
|
`;
|
|
90
90
|
|
|
@@ -6,8 +6,8 @@ import { LicenseConfig } from '../../license/config-types';
|
|
|
6
6
|
import { IacConfig } from '../iac';
|
|
7
7
|
import { ContainersConfig } from '../containers';
|
|
8
8
|
export * from '../../license/config-types';
|
|
9
|
-
export { IacConfig,
|
|
10
|
-
export { ContainersConfig,
|
|
9
|
+
export { IacConfig, Iac } from '../iac';
|
|
10
|
+
export { ContainersConfig, Containers } from '../containers';
|
|
11
11
|
/**
|
|
12
12
|
* Configuration for the nx plugin
|
|
13
13
|
*/
|
package/src/utils/connection/open-api/files/components/__apiNameClassName__Provider.tsx.template
CHANGED
|
@@ -2,9 +2,9 @@ import { createContext, FC, PropsWithChildren, useMemo } from 'react';
|
|
|
2
2
|
import { <%- apiNameClassName %> } from '../<%- generatedClientDir %>/client.gen';
|
|
3
3
|
import { <%- apiNameClassName %>OptionsProxy } from '../<%- generatedClientDir %>/options-proxy.gen';
|
|
4
4
|
import { useRuntimeConfig } from '../hooks/useRuntimeConfig';
|
|
5
|
-
<%_ if (auth === '
|
|
5
|
+
<%_ if (auth === 'iam') { _%>
|
|
6
6
|
import { useSigV4 } from '../hooks/useSigV4';
|
|
7
|
-
<%_ } else if (auth === '
|
|
7
|
+
<%_ } else if (auth === 'cognito') { _%>
|
|
8
8
|
import { useAuth } from 'react-oidc-context';
|
|
9
9
|
<%_ } _%>
|
|
10
10
|
<%_ if (isAgentRuntime) { _%>
|
|
@@ -32,9 +32,9 @@ const useCreate<%- apiNameClassName %>Client = (): <%- apiNameClassName %> => {
|
|
|
32
32
|
<%_ } else { _%>
|
|
33
33
|
const apiUrl = runtimeConfig.apis.<%- apiNameClassName %>;
|
|
34
34
|
<%_ } _%>
|
|
35
|
-
<%_ if(auth === '
|
|
35
|
+
<%_ if(auth === 'iam') { _%>
|
|
36
36
|
const sigv4Client = useSigV4();
|
|
37
|
-
<%_ } else if (auth === '
|
|
37
|
+
<%_ } else if (auth === 'cognito') { _%>
|
|
38
38
|
const auth = useAuth();
|
|
39
39
|
const user = auth?.user;
|
|
40
40
|
const cognitoClient: typeof fetch = (url, init) => {
|
|
@@ -45,12 +45,12 @@ const useCreate<%- apiNameClassName %>Client = (): <%- apiNameClassName %> => {
|
|
|
45
45
|
<%_ } _%>
|
|
46
46
|
return useMemo(() => new <%- apiNameClassName %>({
|
|
47
47
|
url: apiUrl,
|
|
48
|
-
<%_ if(auth === '
|
|
48
|
+
<%_ if(auth === 'iam') { _%>
|
|
49
49
|
fetch: sigv4Client.fetch,
|
|
50
|
-
<%_ } else if(auth === '
|
|
50
|
+
<%_ } else if(auth === 'cognito') { _%>
|
|
51
51
|
fetch: cognitoClient,
|
|
52
52
|
<%_ } _%>
|
|
53
|
-
}), [apiUrl<% if(auth === '
|
|
53
|
+
}), [apiUrl<% if(auth === 'iam') { %>, sigv4Client<% } else if(auth === 'cognito') { %>, cognitoClient<% } %>])
|
|
54
54
|
};
|
|
55
55
|
|
|
56
56
|
export const <%- apiNameClassName %>Provider: FC<PropsWithChildren> = ({ children }) => {
|
|
@@ -80,7 +80,7 @@ const addOpenApiReactClient = async (tree, { apiName, frontendProjectConfig, bac
|
|
|
80
80
|
project: frontendProjectConfig.name,
|
|
81
81
|
});
|
|
82
82
|
// Add sigv4 fetch
|
|
83
|
-
if (auth === '
|
|
83
|
+
if (auth === 'iam') {
|
|
84
84
|
(0, devkit_1.generateFiles)(tree, (0, devkit_1.joinPathFragments)(__dirname, '../../files/website/hooks/sigv4'), (0, devkit_1.joinPathFragments)(frontendProjectConfig.sourceRoot, 'hooks'), {}, {
|
|
85
85
|
overwriteStrategy: devkit_1.OverwriteStrategy.KeepExisting,
|
|
86
86
|
});
|
|
@@ -121,7 +121,7 @@ const addOpenApiReactClient = async (tree, { apiName, frontendProjectConfig, bac
|
|
|
121
121
|
});
|
|
122
122
|
}
|
|
123
123
|
(0, devkit_1.addDependenciesToPackageJson)(tree, (0, versions_1.withVersions)([
|
|
124
|
-
...(auth === '
|
|
124
|
+
...(auth === 'iam'
|
|
125
125
|
? [
|
|
126
126
|
'oidc-client-ts',
|
|
127
127
|
'react-oidc-context',
|
|
@@ -129,7 +129,7 @@ const addOpenApiReactClient = async (tree, { apiName, frontendProjectConfig, bac
|
|
|
129
129
|
'aws4fetch',
|
|
130
130
|
]
|
|
131
131
|
: []),
|
|
132
|
-
...(auth === '
|
|
132
|
+
...(auth === 'cognito' ? ['react-oidc-context'] : []),
|
|
133
133
|
'@tanstack/react-query',
|
|
134
134
|
'@tanstack/react-query-devtools',
|
|
135
135
|
]), (0, versions_1.withVersions)(['@smithy/types']));
|
|
@@ -4,8 +4,8 @@
|
|
|
4
4
|
*/
|
|
5
5
|
import { Tree } from '@nx/devkit';
|
|
6
6
|
export declare const CONTAINER_ENGINES: readonly ["docker", "finch"];
|
|
7
|
-
export type
|
|
8
|
-
export type
|
|
7
|
+
export type Containers = (typeof CONTAINER_ENGINES)[number];
|
|
8
|
+
export type ContainersOption = Containers | 'inherit';
|
|
9
9
|
/**
|
|
10
10
|
* Configuration for container tooling
|
|
11
11
|
*/
|
|
@@ -13,17 +13,17 @@ export interface ContainersConfig {
|
|
|
13
13
|
/**
|
|
14
14
|
* Container engine used for build/push/login operations
|
|
15
15
|
*/
|
|
16
|
-
engine:
|
|
16
|
+
engine: Containers;
|
|
17
17
|
}
|
|
18
18
|
/**
|
|
19
19
|
* Detect which container engine is available on the host. Prefers docker;
|
|
20
20
|
* falls back to finch when only finch is installed; defaults to docker
|
|
21
21
|
* when neither is found.
|
|
22
22
|
*/
|
|
23
|
-
export declare const
|
|
23
|
+
export declare const inferContainers: () => Containers;
|
|
24
24
|
/**
|
|
25
25
|
* Given a container engine option, resolve the actual engine to use.
|
|
26
26
|
* `Inherit` reads the value from the workspace plugin config, defaulting
|
|
27
27
|
* to docker when nothing has been configured.
|
|
28
28
|
*/
|
|
29
|
-
export declare const
|
|
29
|
+
export declare const resolveContainers: (tree: Tree, option: ContainersOption) => Promise<Containers>;
|
package/src/utils/containers.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.resolveContainers = exports.inferContainers = exports.CONTAINER_ENGINES = void 0;
|
|
4
4
|
const child_process_1 = require("child_process");
|
|
5
5
|
const utils_1 = require("./config/utils");
|
|
6
6
|
exports.CONTAINER_ENGINES = ['docker', 'finch'];
|
|
@@ -19,21 +19,21 @@ const isOnPath = (binary) => {
|
|
|
19
19
|
* falls back to finch when only finch is installed; defaults to docker
|
|
20
20
|
* when neither is found.
|
|
21
21
|
*/
|
|
22
|
-
const
|
|
22
|
+
const inferContainers = () => {
|
|
23
23
|
if (isOnPath('docker'))
|
|
24
24
|
return 'docker';
|
|
25
25
|
if (isOnPath('finch'))
|
|
26
26
|
return 'finch';
|
|
27
27
|
return 'docker';
|
|
28
28
|
};
|
|
29
|
-
exports.
|
|
29
|
+
exports.inferContainers = inferContainers;
|
|
30
30
|
/**
|
|
31
31
|
* Given a container engine option, resolve the actual engine to use.
|
|
32
32
|
* `Inherit` reads the value from the workspace plugin config, defaulting
|
|
33
33
|
* to docker when nothing has been configured.
|
|
34
34
|
*/
|
|
35
|
-
const
|
|
36
|
-
if (option === '
|
|
35
|
+
const resolveContainers = async (tree, option) => {
|
|
36
|
+
if (option === 'inherit') {
|
|
37
37
|
const pluginConfig = await (0, utils_1.readAwsNxPluginConfig)(tree);
|
|
38
38
|
const engine = pluginConfig?.containers?.engine ?? 'docker';
|
|
39
39
|
if (!exports.CONTAINER_ENGINES.includes(engine)) {
|
|
@@ -43,5 +43,5 @@ const resolveContainerEngine = async (tree, option) => {
|
|
|
43
43
|
}
|
|
44
44
|
return option;
|
|
45
45
|
};
|
|
46
|
-
exports.
|
|
46
|
+
exports.resolveContainers = resolveContainers;
|
|
47
47
|
//# sourceMappingURL=containers.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"containers.js","sourceRoot":"","sources":["../../../../../packages/nx-plugin/src/utils/containers.ts"],"names":[],"mappings":";;;AAKA,iDAAyC;AACzC,0CAGwB;AAEX,QAAA,iBAAiB,GAAG,CAAC,QAAQ,EAAE,OAAO,CAAU,CAAC;AAgB9D,MAAM,QAAQ,GAAG,CAAC,MAAc,EAAW,EAAE;IAC3C,IAAI,CAAC;QACH,MAAM,KAAK,GAAG,OAAO,CAAC,QAAQ,KAAK,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,YAAY,CAAC;QACpE,IAAA,wBAAQ,EAAC,GAAG,KAAK,IAAI,MAAM,EAAE,EAAE,EAAE,KAAK,EAAE,QAAQ,EAAE,CAAC,CAAC;QACpD,OAAO,IAAI,CAAC;IACd,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,KAAK,CAAC;IACf,CAAC;AACH,CAAC,CAAC;AAEF;;;;GAIG;AACI,MAAM,
|
|
1
|
+
{"version":3,"file":"containers.js","sourceRoot":"","sources":["../../../../../packages/nx-plugin/src/utils/containers.ts"],"names":[],"mappings":";;;AAKA,iDAAyC;AACzC,0CAGwB;AAEX,QAAA,iBAAiB,GAAG,CAAC,QAAQ,EAAE,OAAO,CAAU,CAAC;AAgB9D,MAAM,QAAQ,GAAG,CAAC,MAAc,EAAW,EAAE;IAC3C,IAAI,CAAC;QACH,MAAM,KAAK,GAAG,OAAO,CAAC,QAAQ,KAAK,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,YAAY,CAAC;QACpE,IAAA,wBAAQ,EAAC,GAAG,KAAK,IAAI,MAAM,EAAE,EAAE,EAAE,KAAK,EAAE,QAAQ,EAAE,CAAC,CAAC;QACpD,OAAO,IAAI,CAAC;IACd,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,KAAK,CAAC;IACf,CAAC;AACH,CAAC,CAAC;AAEF;;;;GAIG;AACI,MAAM,eAAe,GAAG,GAAe,EAAE;IAC9C,IAAI,QAAQ,CAAC,QAAQ,CAAC;QAAE,OAAO,QAAQ,CAAC;IACxC,IAAI,QAAQ,CAAC,OAAO,CAAC;QAAE,OAAO,OAAO,CAAC;IACtC,OAAO,QAAQ,CAAC;AAClB,CAAC,CAAC;AAJW,QAAA,eAAe,mBAI1B;AAEF;;;;GAIG;AACI,MAAM,iBAAiB,GAAG,KAAK,EACpC,IAAU,EACV,MAAwB,EACH,EAAE;IACvB,IAAI,MAAM,KAAK,SAAS,EAAE,CAAC;QACzB,MAAM,YAAY,GAAG,MAAM,IAAA,6BAAqB,EAAC,IAAI,CAAC,CAAC;QACvD,MAAM,MAAM,GAAG,YAAY,EAAE,UAAU,EAAE,MAAM,IAAI,QAAQ,CAAC;QAC5D,IAAI,CAAC,yBAAiB,CAAC,QAAQ,CAAC,MAAM,CAAC,EAAE,CAAC;YACxC,MAAM,IAAI,KAAK,CACb,wBAAwB,sCAA8B,mBAAmB,yBAAiB,CAAC,IAAI,CAC7F,IAAI,CACL,EAAE,CACJ,CAAC;QACJ,CAAC;QACD,OAAO,MAAM,CAAC;IAChB,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC,CAAC;AAjBW,QAAA,iBAAiB,qBAiB5B"}
|
|
@@ -3,7 +3,7 @@ import * as url from 'url';
|
|
|
3
3
|
import { Code, Function, Runtime, Tracing } from 'aws-cdk-lib/aws-lambda';
|
|
4
4
|
import { Duration } from 'aws-cdk-lib';
|
|
5
5
|
|
|
6
|
-
export class <%=
|
|
6
|
+
export class <%= nameClassName %> extends Function {
|
|
7
7
|
constructor(scope: Construct, id: string) {
|
|
8
8
|
super(scope, id, {
|
|
9
9
|
timeout: Duration.seconds(30),
|
|
@@ -53,7 +53,7 @@ resource "random_string" "suffix" {
|
|
|
53
53
|
}
|
|
54
54
|
|
|
55
55
|
resource "aws_iam_role" "lambda_role" {
|
|
56
|
-
name = "<%-
|
|
56
|
+
name = "<%- nameKebabCase %>-role-${random_string.suffix.result}"
|
|
57
57
|
|
|
58
58
|
assume_role_policy = jsonencode({
|
|
59
59
|
Version = "2012-10-17"
|
|
@@ -73,8 +73,8 @@ resource "aws_iam_role" "lambda_role" {
|
|
|
73
73
|
}
|
|
74
74
|
|
|
75
75
|
resource "aws_iam_policy" "lambda_policy" {
|
|
76
|
-
name = "<%-
|
|
77
|
-
description = "Policy for <%-
|
|
76
|
+
name = "<%- nameKebabCase %>-policy-${random_string.suffix.result}"
|
|
77
|
+
description = "Policy for <%- nameKebabCase %> Lambda function"
|
|
78
78
|
|
|
79
79
|
policy = jsonencode({
|
|
80
80
|
Version = "2012-10-17"
|
|
@@ -88,7 +88,7 @@ resource "aws_iam_policy" "lambda_policy" {
|
|
|
88
88
|
"logs:PutLogEvents"
|
|
89
89
|
]
|
|
90
90
|
Resource = [
|
|
91
|
-
"arn:aws:logs:${local.aws_region}:${local.aws_account_id}:log-group:/aws/lambda/<%-
|
|
91
|
+
"arn:aws:logs:${local.aws_region}:${local.aws_account_id}:log-group:/aws/lambda/<%- nameKebabCase %>-${random_string.suffix.result}:*"
|
|
92
92
|
]
|
|
93
93
|
},
|
|
94
94
|
{
|
|
@@ -115,12 +115,12 @@ resource "aws_iam_role_policy_attachment" "lambda_policy_attachment" {
|
|
|
115
115
|
data "archive_file" "lambda_zip" {
|
|
116
116
|
type = "zip"
|
|
117
117
|
source_dir = "${path.module}/../../../../../../../<%- bundlePathFromRoot %>"
|
|
118
|
-
output_path = "${path.module}/../../../../../../../dist/packages/common/terraform/lambda-functions/<%-
|
|
118
|
+
output_path = "${path.module}/../../../../../../../dist/packages/common/terraform/lambda-functions/<%- nameKebabCase %>/lambda.zip"
|
|
119
119
|
}
|
|
120
120
|
|
|
121
121
|
resource "aws_s3_object" "lambda_zip" {
|
|
122
122
|
bucket = var.asset_bucket_name
|
|
123
|
-
key = "lambdas/<%-
|
|
123
|
+
key = "lambdas/<%- nameKebabCase %>/${data.archive_file.lambda_zip.output_sha256}.zip"
|
|
124
124
|
source = data.archive_file.lambda_zip.output_path
|
|
125
125
|
source_hash = data.archive_file.lambda_zip.output_base64sha256
|
|
126
126
|
etag = data.archive_file.lambda_zip.output_md5
|
|
@@ -135,7 +135,7 @@ resource "aws_lambda_function" "lambda_function" {
|
|
|
135
135
|
s3_bucket = aws_s3_object.lambda_zip.bucket
|
|
136
136
|
s3_key = aws_s3_object.lambda_zip.key
|
|
137
137
|
s3_object_version = aws_s3_object.lambda_zip.version_id
|
|
138
|
-
function_name = "<%-
|
|
138
|
+
function_name = "<%- nameKebabCase %>-${random_string.suffix.result}"
|
|
139
139
|
role = aws_iam_role.lambda_role.arn
|
|
140
140
|
handler = "<%- handler %>"
|
|
141
141
|
source_code_hash = data.archive_file.lambda_zip.output_base64sha256
|
|
@@ -3,11 +3,11 @@
|
|
|
3
3
|
* SPDX-License-Identifier: Apache-2.0
|
|
4
4
|
*/
|
|
5
5
|
import { Tree } from '@nx/devkit';
|
|
6
|
-
import {
|
|
6
|
+
import { Iac } from '../iac';
|
|
7
7
|
export interface AddLambdaFunctionConstructOptions {
|
|
8
8
|
functionProjectName: string;
|
|
9
|
-
|
|
10
|
-
|
|
9
|
+
nameClassName: string;
|
|
10
|
+
nameKebabCase: string;
|
|
11
11
|
bundlePathFromRoot: string;
|
|
12
12
|
handler: string;
|
|
13
13
|
runtime: 'node' | 'python';
|
|
@@ -16,5 +16,5 @@ export interface AddLambdaFunctionConstructOptions {
|
|
|
16
16
|
* Add infrastructure for a lambda function
|
|
17
17
|
*/
|
|
18
18
|
export declare const addLambdaFunctionInfra: (tree: Tree, options: AddLambdaFunctionConstructOptions & {
|
|
19
|
-
|
|
19
|
+
iac: Iac;
|
|
20
20
|
}) => Promise<void>;
|