@aws/nx-plugin 1.0.0-rc.0 → 1.0.0-rc.1
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/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 +10 -10
- 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 +9 -9
- package/src/py/lambda-function/generator.js.map +1 -1
- package/src/py/lambda-function/schema.d.ts +4 -4
- package/src/py/lambda-function/schema.json +7 -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 +8 -8
- 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 +22 -22
- 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 +4 -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 +12 -12
- package/src/ts/lambda-function/generator.js.map +1 -1
- package/src/ts/lambda-function/schema.d.ts +4 -4
- package/src/ts/lambda-function/schema.json +7 -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 +18 -18
- 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 +23 -23
- 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 +27 -27
- package/src/ts/react-website/app/generator.js.map +1 -1
- package/src/ts/react-website/app/schema.d.ts +6 -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 +6 -6
- package/src/ts/website/app/schema.json +13 -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
|
@@ -9,18 +9,18 @@ import {
|
|
|
9
9
|
ProtocolType,
|
|
10
10
|
Runtime,
|
|
11
11
|
RuntimeProps,
|
|
12
|
-
<%_ if (auth === '
|
|
12
|
+
<%_ if (auth === 'cognito') { _%>
|
|
13
13
|
RuntimeAuthorizerConfiguration,
|
|
14
14
|
<%_ } _%>
|
|
15
15
|
} from 'aws-cdk-lib/aws-bedrockagentcore';
|
|
16
|
-
import { <%_ if (serverProtocol !== '
|
|
17
|
-
<%_ if (auth === '
|
|
16
|
+
import { <%_ if (serverProtocol !== 'mcp') { _%>PolicyStatement, <%_ } _%>IGrantable, IPrincipal<%_ if (auth === 'iam') { _%>, Grant<%_ } _%> } from 'aws-cdk-lib/aws-iam';
|
|
17
|
+
<%_ if (auth === 'cognito') { _%>
|
|
18
18
|
import { IUserPool, IUserPoolClient } from 'aws-cdk-lib/aws-cognito';
|
|
19
19
|
<%_ } _%>
|
|
20
20
|
import { RuntimeConfig } from '../../../core/runtime-config.js';
|
|
21
21
|
import { findWorkspaceRoot } from '../../../core/workspace.js';
|
|
22
22
|
|
|
23
|
-
<%_ if (auth === '
|
|
23
|
+
<%_ if (auth === 'iam') { _%>
|
|
24
24
|
export type <%- nameClassName %>Props = Omit<
|
|
25
25
|
RuntimeProps,
|
|
26
26
|
| 'runtimeName'
|
|
@@ -28,7 +28,7 @@ export type <%- nameClassName %>Props = Omit<
|
|
|
28
28
|
| 'agentRuntimeArtifact'
|
|
29
29
|
| 'authorizerConfiguration'
|
|
30
30
|
>;
|
|
31
|
-
<%_ } else if (auth === '
|
|
31
|
+
<%_ } else if (auth === 'cognito') { _%>
|
|
32
32
|
export type <%- nameClassName %>Props = Omit<
|
|
33
33
|
RuntimeProps,
|
|
34
34
|
| 'runtimeName'
|
|
@@ -50,7 +50,7 @@ export class <%- nameClassName %> extends Construct implements IGrantable, IConn
|
|
|
50
50
|
public readonly dockerImage: AgentRuntimeArtifact;
|
|
51
51
|
public readonly agentCoreRuntime: Runtime;
|
|
52
52
|
|
|
53
|
-
constructor(scope: Construct, id: string, props<%_ if (auth !== '
|
|
53
|
+
constructor(scope: Construct, id: string, props<%_ if (auth !== 'cognito') { _%>?<%_ } _%>: <%- nameClassName %>Props) {
|
|
54
54
|
super(scope, id);
|
|
55
55
|
|
|
56
56
|
const rc = RuntimeConfig.ensure(this);
|
|
@@ -65,7 +65,7 @@ export class <%- nameClassName %> extends Construct implements IGrantable, IConn
|
|
|
65
65
|
platform: Platform.LINUX_ARM64,
|
|
66
66
|
});
|
|
67
67
|
|
|
68
|
-
<%_ if (auth === '
|
|
68
|
+
<%_ if (auth === 'cognito') { _%>
|
|
69
69
|
const { identity, ...restProps } = props;
|
|
70
70
|
|
|
71
71
|
<%_ } _%>
|
|
@@ -74,9 +74,9 @@ export class <%- nameClassName %> extends Construct implements IGrantable, IConn
|
|
|
74
74
|
produce: () =>
|
|
75
75
|
Names.uniqueResourceName(this.agentCoreRuntime, { maxLength: 40 }),
|
|
76
76
|
}),
|
|
77
|
-
protocolConfiguration: ProtocolType.<%- serverProtocol %>,
|
|
77
|
+
protocolConfiguration: ProtocolType.<%- serverProtocol.toUpperCase() %>,
|
|
78
78
|
agentRuntimeArtifact: this.dockerImage,
|
|
79
|
-
<%_ if (auth === '
|
|
79
|
+
<%_ if (auth === 'cognito') { _%>
|
|
80
80
|
authorizerConfiguration: RuntimeAuthorizerConfiguration.usingCognito(
|
|
81
81
|
identity.userPool,
|
|
82
82
|
[identity.userPoolClient],
|
|
@@ -87,7 +87,7 @@ export class <%- nameClassName %> extends Construct implements IGrantable, IConn
|
|
|
87
87
|
<%_ } _%>
|
|
88
88
|
environmentVariables: {
|
|
89
89
|
RUNTIME_CONFIG_APP_ID: rc.appConfigApplicationId,
|
|
90
|
-
<%_ if (auth === '
|
|
90
|
+
<%_ if (auth === 'cognito') { _%>
|
|
91
91
|
...restProps?.environmentVariables,
|
|
92
92
|
<%_ } else { _%>
|
|
93
93
|
...props?.environmentVariables,
|
|
@@ -95,7 +95,7 @@ export class <%- nameClassName %> extends Construct implements IGrantable, IConn
|
|
|
95
95
|
},
|
|
96
96
|
});
|
|
97
97
|
|
|
98
|
-
<%_ if (serverProtocol !== '
|
|
98
|
+
<%_ if (serverProtocol !== 'mcp') { _%>
|
|
99
99
|
// Grant access for the agent to invoke bedrock models
|
|
100
100
|
this.agentCoreRuntime.addToRolePolicy(
|
|
101
101
|
new PolicyStatement({
|
|
@@ -132,7 +132,7 @@ export class <%- nameClassName %> extends Construct implements IGrantable, IConn
|
|
|
132
132
|
public get connections(): Connections {
|
|
133
133
|
return this.agentCoreRuntime.connections;
|
|
134
134
|
}
|
|
135
|
-
<%_ if (auth === '
|
|
135
|
+
<%_ if (auth === 'iam') { _%>
|
|
136
136
|
|
|
137
137
|
/**
|
|
138
138
|
* Grants IAM permissions to invoke this agent runtime.
|
|
@@ -146,7 +146,7 @@ export class <%- nameClassName %> extends Construct implements IGrantable, IConn
|
|
|
146
146
|
grantee,
|
|
147
147
|
actions: [
|
|
148
148
|
'bedrock-agentcore:InvokeAgentRuntimeWithWebSocketStream',
|
|
149
|
-
<%_ if (serverProtocol === '
|
|
149
|
+
<%_ if (serverProtocol === 'a2a') { _%>
|
|
150
150
|
'bedrock-agentcore:GetAgentCard',
|
|
151
151
|
<%_ } _%>
|
|
152
152
|
],
|
|
@@ -30,7 +30,7 @@ variable "appconfig_application_arn" {
|
|
|
30
30
|
type = string
|
|
31
31
|
}
|
|
32
32
|
|
|
33
|
-
<%_ if (auth === '
|
|
33
|
+
<%_ if (auth === 'cognito') { _%>
|
|
34
34
|
variable "user_pool_id" {
|
|
35
35
|
description = "ID of the user pool for cognito authentication"
|
|
36
36
|
type = string
|
|
@@ -52,8 +52,8 @@ module "agent_core_runtime" {
|
|
|
52
52
|
source = "../../../core/agent-core"
|
|
53
53
|
agent_runtime_name = "<%= nameClassName %>"
|
|
54
54
|
docker_image_tag = "<%= dockerImageTag %>"
|
|
55
|
-
server_protocol = "<%= serverProtocol %>"
|
|
56
|
-
<%_ if (auth === '
|
|
55
|
+
server_protocol = "<%= serverProtocol.toUpperCase() %>"
|
|
56
|
+
<%_ if (auth === 'cognito') { _%>
|
|
57
57
|
authorizer_configuration = {
|
|
58
58
|
custom_jwt_authorizer = {
|
|
59
59
|
discovery_url = "https://cognito-idp.${local.aws_region}.amazonaws.com/${var.user_pool_id}/.well-known/openid-configuration"
|
|
@@ -73,7 +73,7 @@ module "agent_core_runtime" {
|
|
|
73
73
|
"appconfig:GetLatestConfiguration"
|
|
74
74
|
]
|
|
75
75
|
Resource = ["${var.appconfig_application_arn}/*"]
|
|
76
|
-
}<% if (serverProtocol !== '
|
|
76
|
+
}<% if (serverProtocol !== 'mcp') { %>,
|
|
77
77
|
# Grant access for the agent to invoke bedrock models
|
|
78
78
|
{
|
|
79
79
|
Effect = "Allow"
|
|
@@ -33,7 +33,7 @@ variable "server_protocol" {
|
|
|
33
33
|
default = "HTTP"
|
|
34
34
|
validation {
|
|
35
35
|
condition = contains(["MCP", "HTTP", "A2A"], var.server_protocol)
|
|
36
|
-
error_message = "Protocol type must be either '
|
|
36
|
+
error_message = "Protocol type must be either 'mcp', 'http', or 'a2a'."
|
|
37
37
|
}
|
|
38
38
|
}
|
|
39
39
|
|
|
@@ -267,7 +267,7 @@ resource "aws_iam_role_policy_attachment" "agent_core_policy" {
|
|
|
267
267
|
|
|
268
268
|
# Data source to get container image digest
|
|
269
269
|
data "external" "docker_digest" {
|
|
270
|
-
program = ["sh", "-c", "echo '{\"digest\":\"'$(<%=
|
|
270
|
+
program = ["sh", "-c", "echo '{\"digest\":\"'$(<%= containers %> inspect ${var.docker_image_tag} --format '{{.Id}}')'\"}' "]
|
|
271
271
|
}
|
|
272
272
|
|
|
273
273
|
# Null resource for container image publish
|
|
@@ -281,13 +281,13 @@ resource "null_resource" "docker_publish" {
|
|
|
281
281
|
provisioner "local-exec" {
|
|
282
282
|
command = <<-EOT
|
|
283
283
|
# Get ECR login token
|
|
284
|
-
aws ecr get-login-password --region ${local.aws_region} | <%=
|
|
284
|
+
aws ecr get-login-password --region ${local.aws_region} | <%= containers %> login --username AWS --password-stdin ${self.triggers.repository_url}
|
|
285
285
|
|
|
286
286
|
# Tag the image
|
|
287
|
-
<%=
|
|
287
|
+
<%= containers %> tag ${self.triggers.docker_image_tag} ${self.triggers.repository_url}:latest
|
|
288
288
|
|
|
289
289
|
# Push the image
|
|
290
|
-
<%=
|
|
290
|
+
<%= containers %> push ${self.triggers.repository_url}:latest
|
|
291
291
|
EOT
|
|
292
292
|
}
|
|
293
293
|
|
|
@@ -3,7 +3,7 @@
|
|
|
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
|
interface BackendOptions {
|
|
8
8
|
type: 'trpc' | 'fastapi' | 'smithy';
|
|
9
9
|
integrationPattern: 'isolated' | 'shared';
|
|
@@ -30,9 +30,9 @@ export interface AddApiGatewayConstructOptions {
|
|
|
30
30
|
apiNameKebabCase: string;
|
|
31
31
|
constructType: 'http' | 'rest';
|
|
32
32
|
backend: TrpcBackendOptions | FastApiBackendOptions | SmithyBackendOptions;
|
|
33
|
-
auth: '
|
|
33
|
+
auth: 'iam' | 'cognito' | 'custom';
|
|
34
34
|
}
|
|
35
35
|
export declare const addApiGatewayInfra: (tree: Tree, options: AddApiGatewayConstructOptions & {
|
|
36
|
-
|
|
36
|
+
iac: Iac;
|
|
37
37
|
}) => Promise<void>;
|
|
38
38
|
export {};
|
|
@@ -10,18 +10,16 @@ const shared_constructs_constants_1 = require("../shared-constructs-constants");
|
|
|
10
10
|
const ast_1 = require("../ast");
|
|
11
11
|
const nx_1 = require("../nx");
|
|
12
12
|
const addApiGatewayInfra = async (tree, options) => {
|
|
13
|
-
if (options.
|
|
13
|
+
if (options.iac === 'cdk') {
|
|
14
14
|
await addApiGatewayCdkConstructs(tree, options);
|
|
15
15
|
}
|
|
16
|
-
else if (options.
|
|
16
|
+
else if (options.iac === 'terraform') {
|
|
17
17
|
addApiGatewayTerraformModules(tree, options);
|
|
18
18
|
}
|
|
19
19
|
else {
|
|
20
|
-
throw new Error(`Unsupported
|
|
20
|
+
throw new Error(`Unsupported iac ${options.iac}`);
|
|
21
21
|
}
|
|
22
|
-
(0, devkit_1.updateJson)(tree, (0, devkit_1.joinPathFragments)(shared_constructs_constants_1.PACKAGES_DIR, options.
|
|
23
|
-
? shared_constructs_constants_1.SHARED_CONSTRUCTS_DIR
|
|
24
|
-
: shared_constructs_constants_1.SHARED_TERRAFORM_DIR, 'project.json'), (config) => {
|
|
22
|
+
(0, devkit_1.updateJson)(tree, (0, devkit_1.joinPathFragments)(shared_constructs_constants_1.PACKAGES_DIR, options.iac === 'cdk' ? shared_constructs_constants_1.SHARED_CONSTRUCTS_DIR : shared_constructs_constants_1.SHARED_TERRAFORM_DIR, 'project.json'), (config) => {
|
|
25
23
|
(0, nx_1.addDependencyToTargetIfNotPresent)(config, 'build', `${options.apiProjectName}:build`);
|
|
26
24
|
return config;
|
|
27
25
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api-constructs.js","sourceRoot":"","sources":["../../../../../../packages/nx-plugin/src/utils/api-constructs/api-constructs.ts"],"names":[],"mappings":";;;AAAA;;;GAGG;AACH,uCAOoB;AACpB,gFAIwC;AACxC,gCAAuC;AAEvC,8BAA0D;AAmCnD,MAAM,kBAAkB,GAAG,KAAK,EACrC,IAAU,EACV,
|
|
1
|
+
{"version":3,"file":"api-constructs.js","sourceRoot":"","sources":["../../../../../../packages/nx-plugin/src/utils/api-constructs/api-constructs.ts"],"names":[],"mappings":";;;AAAA;;;GAGG;AACH,uCAOoB;AACpB,gFAI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EAC3E,EAAE,EACF;QACE,iBAAiB,EAAE,0BAAiB,CAAC,YAAY;KAClD,CACF,CAAC;IAEF,yCAAyC;IACzC,IAAA,sBAAa,EACX,IAAI,EACJ,IAAA,0BAAiB,EACf,SAAS,EACT,OAAO,EACP,WAAW,EACX,KAAK,EACL,MAAM,EACN,OAAO,CAAC,aAAa,CACtB,EACD,IAAA,0BAAiB,EAAC,0CAAY,EAAE,kDAAoB,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,CAAC,EAC3E,OAAO,EACP;QACE,iBAAiB,EAAE,0BAAiB,CAAC,YAAY;KAClD,CACF,CAAC;AACJ,CAAC,CAAC"}
|
|
@@ -18,23 +18,23 @@ import {
|
|
|
18
18
|
CorsHttpMethod,
|
|
19
19
|
CfnApi,
|
|
20
20
|
} from 'aws-cdk-lib/aws-apigatewayv2';
|
|
21
|
-
<%_ if (['
|
|
21
|
+
<%_ if (['iam', 'cognito', 'custom'].includes(auth)) { _%>
|
|
22
22
|
import {
|
|
23
|
-
<%_ if (auth === '
|
|
23
|
+
<%_ if (auth === 'iam') { _%>
|
|
24
24
|
HttpIamAuthorizer,
|
|
25
|
-
<%_ } else if (auth === '
|
|
25
|
+
<%_ } else if (auth === 'cognito') { _%>
|
|
26
26
|
HttpUserPoolAuthorizer,
|
|
27
|
-
<%_ } else if (auth === '
|
|
27
|
+
<%_ } else if (auth === 'custom') { _%>
|
|
28
28
|
HttpLambdaAuthorizer,
|
|
29
29
|
HttpLambdaResponseType,
|
|
30
30
|
<%_ } _%>
|
|
31
31
|
} from 'aws-cdk-lib/aws-apigatewayv2-authorizers';
|
|
32
32
|
<%_ } _%>
|
|
33
33
|
import { HttpLambdaIntegration } from 'aws-cdk-lib/aws-apigatewayv2-integrations';
|
|
34
|
-
<%_ if (auth === '
|
|
34
|
+
<%_ if (auth === 'cognito') { _%>
|
|
35
35
|
import { IUserPool, IUserPoolClient } from 'aws-cdk-lib/aws-cognito';
|
|
36
36
|
<%_ } _%>
|
|
37
|
-
<%_ if (auth === '
|
|
37
|
+
<%_ if (auth === 'iam') { _%>
|
|
38
38
|
import { Grant, IGrantable } from 'aws-cdk-lib/aws-iam';
|
|
39
39
|
<%_ } _%>
|
|
40
40
|
import {
|
|
@@ -68,7 +68,7 @@ export interface <%= apiNameClassName %>Props<
|
|
|
68
68
|
* Map of operation names to their API Gateway integrations
|
|
69
69
|
*/
|
|
70
70
|
integrations: TIntegrations;
|
|
71
|
-
<%_ if (auth === '
|
|
71
|
+
<%_ if (auth === 'cognito') { _%>
|
|
72
72
|
/**
|
|
73
73
|
* Identity details for Cognito Authentication
|
|
74
74
|
*/
|
|
@@ -175,7 +175,7 @@ export class <%= apiNameClassName %><
|
|
|
175
175
|
id: string,
|
|
176
176
|
props: <%= apiNameClassName %>Props<TIntegrations>,
|
|
177
177
|
) {
|
|
178
|
-
<%_ if (auth === '
|
|
178
|
+
<%_ if (auth === 'custom') { _%>
|
|
179
179
|
const authorizerFunction = new Function(scope, '<%= apiNameClassName %>AuthorizerFunction', {
|
|
180
180
|
<%_ if (['trpc', 'smithy'].includes(backend.type)) { _%>
|
|
181
181
|
runtime: Runtime.NODEJS_LATEST,
|
|
@@ -218,13 +218,13 @@ export class <%= apiNameClassName %><
|
|
|
218
218
|
'x-amz-security-token',
|
|
219
219
|
],
|
|
220
220
|
},
|
|
221
|
-
<%_ if (auth === '
|
|
221
|
+
<%_ if (auth === 'iam') { _%>
|
|
222
222
|
defaultAuthorizer: new HttpIamAuthorizer(),
|
|
223
|
-
<%_ } else if (auth === '
|
|
223
|
+
<%_ } else if (auth === 'cognito') { _%>
|
|
224
224
|
defaultAuthorizer: new HttpUserPoolAuthorizer('<%= apiNameClassName %>Authorizer', props.identity.userPool, {
|
|
225
225
|
userPoolClients: [props.identity.userPoolClient]
|
|
226
226
|
}),
|
|
227
|
-
<%_ } else if (auth === '
|
|
227
|
+
<%_ } else if (auth === 'custom') { _%>
|
|
228
228
|
defaultAuthorizer: new HttpLambdaAuthorizer('<%= apiNameClassName %>LambdaAuthorizer', authorizerFunction, {
|
|
229
229
|
responseTypes: [HttpLambdaResponseType.SIMPLE],
|
|
230
230
|
}),
|
|
@@ -278,7 +278,7 @@ export class <%= apiNameClassName %><
|
|
|
278
278
|
],
|
|
279
279
|
};
|
|
280
280
|
}
|
|
281
|
-
<%_ if (auth === '
|
|
281
|
+
<%_ if (auth === 'iam') { _%>
|
|
282
282
|
|
|
283
283
|
/**
|
|
284
284
|
* Grants IAM permissions to invoke any method on this API.
|
|
@@ -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,EA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