@aws/nx-plugin 0.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +63 -0
- package/generators.json +52 -0
- package/package.json +27 -0
- package/src/cloudscape-website/app/README.md +253 -0
- package/src/cloudscape-website/app/__snapshots__/generator.spec.ts.snap +539 -0
- package/src/cloudscape-website/app/files/app/src/config.ts.template +4 -0
- package/src/cloudscape-website/app/files/app/src/layouts/App/index.tsx.template +132 -0
- package/src/cloudscape-website/app/files/app/src/layouts/App/navitems.ts.template +8 -0
- package/src/cloudscape-website/app/files/app/src/layouts/Routes/index.tsx.template +18 -0
- package/src/cloudscape-website/app/files/app/src/main.tsx.template +22 -0
- package/src/cloudscape-website/app/files/app/src/pages/Home/index.tsx.template +25 -0
- package/src/cloudscape-website/app/files/common/constructs/src/__websiteNameKebabCase__/cloudfront-web-acl.ts.template +317 -0
- package/src/cloudscape-website/app/files/common/constructs/src/__websiteNameKebabCase__/index.ts.template +4 -0
- package/src/cloudscape-website/app/files/common/constructs/src/__websiteNameKebabCase__/static-website.ts.template +237 -0
- package/src/cloudscape-website/app/files/common/constructs/src/__websiteNameKebabCase__/webacl_event_handler/index.ts.template +301 -0
- package/src/cloudscape-website/app/files/e2e/cypress/src/e2e/app.cy.ts.template +13 -0
- package/src/cloudscape-website/app/files/e2e/cypress/src/support/app.po.ts.template +1 -0
- package/src/cloudscape-website/app/files/e2e/playwright/src/example.spec.ts.template +6 -0
- package/src/cloudscape-website/app/generator.d.ts +4 -0
- package/src/cloudscape-website/app/generator.js +177 -0
- package/src/cloudscape-website/app/generator.js.map +1 -0
- package/src/cloudscape-website/app/schema.d.js +6 -0
- package/src/cloudscape-website/app/schema.d.js.map +1 -0
- package/src/cloudscape-website/app/schema.d.ts +35 -0
- package/src/cloudscape-website/app/schema.json +189 -0
- package/src/cloudscape-website/cognito-auth/README.md +172 -0
- package/src/cloudscape-website/cognito-auth/__snapshots__/generator.spec.ts.snap +238 -0
- package/src/cloudscape-website/cognito-auth/files/app/components/CognitoAuth/index.tsx.template +50 -0
- package/src/cloudscape-website/cognito-auth/files/common/constructs/src/identity/index.ts.template +4 -0
- package/src/cloudscape-website/cognito-auth/files/common/constructs/src/identity/user-identity.ts.template +69 -0
- package/src/cloudscape-website/cognito-auth/files/common/constructs/src/identity/userpool-with-mfa.ts.template +70 -0
- package/src/cloudscape-website/cognito-auth/generator.d.ts +4 -0
- package/src/cloudscape-website/cognito-auth/generator.js +100 -0
- package/src/cloudscape-website/cognito-auth/generator.js.map +1 -0
- package/src/cloudscape-website/cognito-auth/schema.d.js +6 -0
- package/src/cloudscape-website/cognito-auth/schema.d.js.map +1 -0
- package/src/cloudscape-website/cognito-auth/schema.d.ts +4 -0
- package/src/cloudscape-website/cognito-auth/schema.json +36 -0
- package/src/cloudscape-website/runtime-config/__snapshots__/generator.spec.ts.snap +112 -0
- package/src/cloudscape-website/runtime-config/files/app/components/RuntimeConfig/index.tsx.template +46 -0
- package/src/cloudscape-website/runtime-config/generator.d.ts +4 -0
- package/src/cloudscape-website/runtime-config/generator.js +74 -0
- package/src/cloudscape-website/runtime-config/generator.js.map +1 -0
- package/src/cloudscape-website/runtime-config/schema.d.js +6 -0
- package/src/cloudscape-website/runtime-config/schema.d.js.map +1 -0
- package/src/cloudscape-website/runtime-config/schema.d.ts +3 -0
- package/src/cloudscape-website/runtime-config/schema.json +19 -0
- package/src/gitlab/files/.gitlab-ci.yml.template +26 -0
- package/src/gitlab/generator.d.ts +4 -0
- package/src/gitlab/generator.js +26 -0
- package/src/gitlab/generator.js.map +1 -0
- package/src/gitlab/schema.d.js +6 -0
- package/src/gitlab/schema.d.js.map +1 -0
- package/src/gitlab/schema.d.ts +5 -0
- package/src/gitlab/schema.json +52 -0
- package/src/index.d.ts +0 -0
- package/src/index.js +3 -0
- package/src/index.js.map +1 -0
- package/src/infra/app/README.md +175 -0
- package/src/infra/app/__snapshots__/generator.spec.ts.snap +864 -0
- package/src/infra/app/files/cdk.json +67 -0
- package/src/infra/app/files/src/main.ts.template +37 -0
- package/src/infra/app/files/src/stacks/application-stack.ts.template +10 -0
- package/src/infra/app/generator.d.ts +4 -0
- package/src/infra/app/generator.js +75 -0
- package/src/infra/app/generator.js.map +1 -0
- package/src/infra/app/schema.d.js +6 -0
- package/src/infra/app/schema.d.js.map +1 -0
- package/src/infra/app/schema.d.ts +6 -0
- package/src/infra/app/schema.json +35 -0
- package/src/trpc/backend/README.md +549 -0
- package/src/trpc/backend/__snapshots__/generator.spec.ts.snap +110 -0
- package/src/trpc/backend/files/backend/src/index.ts.template +1 -0
- package/src/trpc/backend/files/backend/src/lambdas/index.ts.template +1 -0
- package/src/trpc/backend/files/backend/src/lambdas/middleware.ts.template +146 -0
- package/src/trpc/backend/files/backend/src/lambdas/router.ts.template +36 -0
- package/src/trpc/backend/files/common/constructs/src/__apiNameKebabCase__/index.ts.template +64 -0
- package/src/trpc/backend/files/schema/src/index.ts.template +7 -0
- package/src/trpc/backend/generator.d.ts +4 -0
- package/src/trpc/backend/generator.js +128 -0
- package/src/trpc/backend/generator.js.map +1 -0
- package/src/trpc/backend/schema.d.js +6 -0
- package/src/trpc/backend/schema.d.js.map +1 -0
- package/src/trpc/backend/schema.d.ts +8 -0
- package/src/trpc/backend/schema.json +44 -0
- package/src/trpc/react/README.md +320 -0
- package/src/trpc/react/__snapshots__/generator.spec.ts.snap +98 -0
- package/src/trpc/react/files/src/components/TRPCClientProvider/index.tsx.template +34 -0
- package/src/trpc/react/files/src/hooks/useTrpc.tsx.template +5 -0
- package/src/trpc/react/generator.d.ts +4 -0
- package/src/trpc/react/generator.js +81 -0
- package/src/trpc/react/generator.js.map +1 -0
- package/src/trpc/react/schema.d.js +6 -0
- package/src/trpc/react/schema.d.js.map +1 -0
- package/src/trpc/react/schema.d.ts +5 -0
- package/src/trpc/react/schema.json +32 -0
- package/src/ts/cjs-to-esm/generator.d.ts +8 -0
- package/src/ts/cjs-to-esm/generator.js +201 -0
- package/src/ts/cjs-to-esm/generator.js.map +1 -0
- package/src/ts/cjs-to-esm/schema.d.js +6 -0
- package/src/ts/cjs-to-esm/schema.d.js.map +1 -0
- package/src/ts/cjs-to-esm/schema.d.ts +5 -0
- package/src/ts/cjs-to-esm/schema.json +28 -0
- package/src/ts/lib/README.md +149 -0
- package/src/ts/lib/__snapshots__/generator.spec.ts.snap +260 -0
- package/src/ts/lib/eslint.d.ts +3 -0
- package/src/ts/lib/eslint.js +41 -0
- package/src/ts/lib/eslint.js.map +1 -0
- package/src/ts/lib/files/src/index.ts.template +3 -0
- package/src/ts/lib/generator.d.ts +21 -0
- package/src/ts/lib/generator.js +61 -0
- package/src/ts/lib/generator.js.map +1 -0
- package/src/ts/lib/schema.d.js +6 -0
- package/src/ts/lib/schema.d.js.map +1 -0
- package/src/ts/lib/schema.d.ts +13 -0
- package/src/ts/lib/schema.json +46 -0
- package/src/ts/lib/ts-project-utils.d.ts +6 -0
- package/src/ts/lib/ts-project-utils.js +107 -0
- package/src/ts/lib/ts-project-utils.js.map +1 -0
- package/src/ts/lib/types.d.ts +10 -0
- package/src/ts/lib/types.js +6 -0
- package/src/ts/lib/types.js.map +1 -0
- package/src/ts/lib/vitest.d.ts +3 -0
- package/src/ts/lib/vitest.js +67 -0
- package/src/ts/lib/vitest.js.map +1 -0
- package/src/utils/files/common/constructs/src/index.ts.template +1 -0
- package/src/utils/files/common/constructs/src/runtime-config/index.ts.template +1 -0
- package/src/utils/files/common/constructs/src/runtime-config/runtime-config.ts.template +33 -0
- package/src/utils/files/common/types/src/index.ts.template +1 -0
- package/src/utils/files/common/types/src/runtime-config.ts.template +13 -0
- package/src/utils/npm-scope.d.ts +7 -0
- package/src/utils/npm-scope.js +37 -0
- package/src/utils/npm-scope.js.map +1 -0
- package/src/utils/paths.d.ts +3 -0
- package/src/utils/paths.js +32 -0
- package/src/utils/paths.js.map +1 -0
- package/src/utils/shared-constructs.d.ts +7 -0
- package/src/utils/shared-constructs.js +72 -0
- package/src/utils/shared-constructs.js.map +1 -0
- package/src/utils/versions.d.ts +31 -0
- package/src/utils/versions.js +49 -0
- package/src/utils/versions.js.map +1 -0
|
@@ -0,0 +1,864 @@
|
|
|
1
|
+
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
|
|
2
|
+
|
|
3
|
+
exports[`infra generator > should add required dependencies to package.json > dependencies 1`] = `
|
|
4
|
+
{
|
|
5
|
+
"@aws/pdk": "^0.25.7",
|
|
6
|
+
"aws-cdk": "^2.166.0",
|
|
7
|
+
"aws-cdk-lib": "^2.166.0",
|
|
8
|
+
"constructs": "^10.4.2",
|
|
9
|
+
"esbuild": "^0.24.0",
|
|
10
|
+
"source-map-support": "^0.5.21",
|
|
11
|
+
}
|
|
12
|
+
`;
|
|
13
|
+
|
|
14
|
+
exports[`infra generator > should add required dependencies to package.json > dev-dependencies 1`] = `
|
|
15
|
+
{
|
|
16
|
+
"@nx/eslint": "20.0.10",
|
|
17
|
+
"@nx/eslint-plugin": "20.0.10",
|
|
18
|
+
"@typescript-eslint/eslint-plugin": "^7.16.0",
|
|
19
|
+
"@typescript-eslint/parser": "^7.16.0",
|
|
20
|
+
"eslint": "~8.57.0",
|
|
21
|
+
"eslint-config-prettier": "^9.0.0",
|
|
22
|
+
"tsx": "^4.19.2",
|
|
23
|
+
}
|
|
24
|
+
`;
|
|
25
|
+
|
|
26
|
+
exports[`infra generator > should add required dependencies to package.json > package-json 1`] = `
|
|
27
|
+
{
|
|
28
|
+
"dependencies": {
|
|
29
|
+
"@aws/pdk": "^0.25.7",
|
|
30
|
+
"aws-cdk": "^2.166.0",
|
|
31
|
+
"aws-cdk-lib": "^2.166.0",
|
|
32
|
+
"constructs": "^10.4.2",
|
|
33
|
+
"esbuild": "^0.24.0",
|
|
34
|
+
"source-map-support": "^0.5.21",
|
|
35
|
+
},
|
|
36
|
+
"devDependencies": {
|
|
37
|
+
"@nx/eslint": "20.0.10",
|
|
38
|
+
"@nx/eslint-plugin": "20.0.10",
|
|
39
|
+
"@typescript-eslint/eslint-plugin": "^7.16.0",
|
|
40
|
+
"@typescript-eslint/parser": "^7.16.0",
|
|
41
|
+
"eslint": "~8.57.0",
|
|
42
|
+
"eslint-config-prettier": "^9.0.0",
|
|
43
|
+
"tsx": "^4.19.2",
|
|
44
|
+
},
|
|
45
|
+
"name": "@proj/source",
|
|
46
|
+
"type": "module",
|
|
47
|
+
}
|
|
48
|
+
`;
|
|
49
|
+
|
|
50
|
+
exports[`infra generator > should configure project.json with correct targets > build-target 1`] = `
|
|
51
|
+
{
|
|
52
|
+
"cache": true,
|
|
53
|
+
"dependsOn": [
|
|
54
|
+
"^build",
|
|
55
|
+
],
|
|
56
|
+
"executor": "nx:run-commands",
|
|
57
|
+
"options": {
|
|
58
|
+
"command": "cdk synth",
|
|
59
|
+
"cwd": "packages/test",
|
|
60
|
+
},
|
|
61
|
+
"outputs": [
|
|
62
|
+
"{workspaceRoot}/dist/packages/test/cdk.out",
|
|
63
|
+
],
|
|
64
|
+
}
|
|
65
|
+
`;
|
|
66
|
+
|
|
67
|
+
exports[`infra generator > should configure project.json with correct targets > deploy-target 1`] = `
|
|
68
|
+
{
|
|
69
|
+
"executor": "nx:run-commands",
|
|
70
|
+
"options": {
|
|
71
|
+
"command": "cdk deploy --require-approval=never --app ../../dist/packages/test/cdk.out",
|
|
72
|
+
"cwd": "packages/test",
|
|
73
|
+
},
|
|
74
|
+
}
|
|
75
|
+
`;
|
|
76
|
+
|
|
77
|
+
exports[`infra generator > should configure project.json with correct targets > project-configuration 1`] = `
|
|
78
|
+
{
|
|
79
|
+
"$schema": "../../node_modules/nx/schemas/project-schema.json",
|
|
80
|
+
"name": "@proj/test",
|
|
81
|
+
"projectType": "application",
|
|
82
|
+
"root": "packages/test",
|
|
83
|
+
"sourceRoot": "packages/test/src",
|
|
84
|
+
"tags": [],
|
|
85
|
+
"targets": {
|
|
86
|
+
"build": {
|
|
87
|
+
"cache": true,
|
|
88
|
+
"dependsOn": [
|
|
89
|
+
"^build",
|
|
90
|
+
],
|
|
91
|
+
"executor": "nx:run-commands",
|
|
92
|
+
"options": {
|
|
93
|
+
"command": "cdk synth",
|
|
94
|
+
"cwd": "packages/test",
|
|
95
|
+
},
|
|
96
|
+
"outputs": [
|
|
97
|
+
"{workspaceRoot}/dist/packages/test/cdk.out",
|
|
98
|
+
],
|
|
99
|
+
},
|
|
100
|
+
"compile": {
|
|
101
|
+
"executor": "@nx/js:tsc",
|
|
102
|
+
"options": {
|
|
103
|
+
"assets": [
|
|
104
|
+
"packages/test/*.md",
|
|
105
|
+
],
|
|
106
|
+
"main": "packages/test/src/index.ts",
|
|
107
|
+
"outputPath": "dist/packages/test",
|
|
108
|
+
"tsConfig": "packages/test/tsconfig.lib.json",
|
|
109
|
+
},
|
|
110
|
+
"outputs": [
|
|
111
|
+
"{options.outputPath}",
|
|
112
|
+
],
|
|
113
|
+
},
|
|
114
|
+
"deploy": {
|
|
115
|
+
"executor": "nx:run-commands",
|
|
116
|
+
"options": {
|
|
117
|
+
"command": "cdk deploy --require-approval=never --app ../../dist/packages/test/cdk.out",
|
|
118
|
+
"cwd": "packages/test",
|
|
119
|
+
},
|
|
120
|
+
},
|
|
121
|
+
"lint": {
|
|
122
|
+
"executor": "@nx/eslint:lint",
|
|
123
|
+
},
|
|
124
|
+
"test": {
|
|
125
|
+
"executor": "@nx/jest:jest",
|
|
126
|
+
"options": {
|
|
127
|
+
"jestConfig": "packages/test/jest.config.ts",
|
|
128
|
+
},
|
|
129
|
+
"outputs": [
|
|
130
|
+
"{workspaceRoot}/coverage/{projectRoot}",
|
|
131
|
+
],
|
|
132
|
+
},
|
|
133
|
+
},
|
|
134
|
+
}
|
|
135
|
+
`;
|
|
136
|
+
|
|
137
|
+
exports[`infra generator > should generate consistent file content across runs > consistent-files 1`] = `
|
|
138
|
+
{
|
|
139
|
+
"cdk.json": "{
|
|
140
|
+
"app": "tsx src/main.ts",
|
|
141
|
+
"output": "../../dist/packages/test/cdk.out",
|
|
142
|
+
"watch": {
|
|
143
|
+
"include": ["**"],
|
|
144
|
+
"exclude": [
|
|
145
|
+
"README.md",
|
|
146
|
+
"cdk*.json",
|
|
147
|
+
"**/*.d.ts",
|
|
148
|
+
"**/*.js",
|
|
149
|
+
"tsconfig.json",
|
|
150
|
+
"package*.json",
|
|
151
|
+
"yarn.lock",
|
|
152
|
+
"node_modules",
|
|
153
|
+
"test"
|
|
154
|
+
]
|
|
155
|
+
},
|
|
156
|
+
"context": {
|
|
157
|
+
"@aws-cdk/aws-lambda:recognizeLayerVersion": true,
|
|
158
|
+
"@aws-cdk/core:checkSecretUsage": true,
|
|
159
|
+
"@aws-cdk/core:target-partitions": ["aws", "aws-cn"],
|
|
160
|
+
"@aws-cdk-containers/ecs-service-extensions:enableDefaultLogDriver": true,
|
|
161
|
+
"@aws-cdk/aws-ec2:uniqueImdsv2TemplateName": true,
|
|
162
|
+
"@aws-cdk/aws-ecs:arnFormatIncludesClusterName": true,
|
|
163
|
+
"@aws-cdk/aws-iam:minimizePolicies": true,
|
|
164
|
+
"@aws-cdk/core:validateSnapshotRemovalPolicy": true,
|
|
165
|
+
"@aws-cdk/aws-codepipeline:crossAccountKeyAliasStackSafeResourceName": true,
|
|
166
|
+
"@aws-cdk/aws-s3:createDefaultLoggingPolicy": true,
|
|
167
|
+
"@aws-cdk/aws-sns-subscriptions:restrictSqsDescryption": true,
|
|
168
|
+
"@aws-cdk/aws-apigateway:disableCloudWatchRole": true,
|
|
169
|
+
"@aws-cdk/core:enablePartitionLiterals": true,
|
|
170
|
+
"@aws-cdk/aws-events:eventsTargetQueueSameAccount": true,
|
|
171
|
+
"@aws-cdk/aws-ecs:disableExplicitDeploymentControllerForCircuitBreaker": true,
|
|
172
|
+
"@aws-cdk/aws-iam:importedRoleStackSafeDefaultPolicyName": true,
|
|
173
|
+
"@aws-cdk/aws-s3:serverAccessLogsUseBucketPolicy": true,
|
|
174
|
+
"@aws-cdk/aws-route53-patters:useCertificate": true,
|
|
175
|
+
"@aws-cdk/customresources:installLatestAwsSdkDefault": false,
|
|
176
|
+
"@aws-cdk/aws-rds:databaseProxyUniqueResourceName": true,
|
|
177
|
+
"@aws-cdk/aws-codedeploy:removeAlarmsFromDeploymentGroup": true,
|
|
178
|
+
"@aws-cdk/aws-apigateway:authorizerChangeDeploymentLogicalId": true,
|
|
179
|
+
"@aws-cdk/aws-ec2:launchTemplateDefaultUserData": true,
|
|
180
|
+
"@aws-cdk/aws-secretsmanager:useAttachedSecretResourcePolicyForSecretTargetAttachments": true,
|
|
181
|
+
"@aws-cdk/aws-redshift:columnId": true,
|
|
182
|
+
"@aws-cdk/aws-stepfunctions-tasks:enableEmrServicePolicyV2": true,
|
|
183
|
+
"@aws-cdk/aws-ec2:restrictDefaultSecurityGroup": true,
|
|
184
|
+
"@aws-cdk/aws-apigateway:requestValidatorUniqueId": true,
|
|
185
|
+
"@aws-cdk/aws-kms:aliasNameRef": true,
|
|
186
|
+
"@aws-cdk/aws-autoscaling:generateLaunchTemplateInsteadOfLaunchConfig": true,
|
|
187
|
+
"@aws-cdk/core:includePrefixInUniqueNameGeneration": true,
|
|
188
|
+
"@aws-cdk/aws-efs:denyAnonymousAccess": true,
|
|
189
|
+
"@aws-cdk/aws-opensearchservice:enableOpensearchMultiAzWithStandby": true,
|
|
190
|
+
"@aws-cdk/aws-lambda-nodejs:useLatestRuntimeVersion": true,
|
|
191
|
+
"@aws-cdk/aws-efs:mountTargetOrderInsensitiveLogicalId": true,
|
|
192
|
+
"@aws-cdk/aws-rds:auroraClusterChangeScopeOfInstanceParameterGroupWithEachParameters": true,
|
|
193
|
+
"@aws-cdk/aws-appsync:useArnForSourceApiAssociationIdentifier": true,
|
|
194
|
+
"@aws-cdk/aws-rds:preventRenderingDeprecatedCredentials": true,
|
|
195
|
+
"@aws-cdk/aws-codepipeline-actions:useNewDefaultBranchForCodeCommitSource": true,
|
|
196
|
+
"@aws-cdk/aws-cloudwatch-actions:changeLambdaPermissionLogicalIdForLambdaAction": true,
|
|
197
|
+
"@aws-cdk/aws-codepipeline:crossAccountKeysDefaultValueToFalse": true,
|
|
198
|
+
"@aws-cdk/aws-codepipeline:defaultPipelineTypeToV2": true,
|
|
199
|
+
"@aws-cdk/aws-kms:reduceCrossAccountRegionPolicyScope": true,
|
|
200
|
+
"@aws-cdk/aws-eks:nodegroupNameAttribute": true,
|
|
201
|
+
"@aws-cdk/aws-ec2:ebsDefaultGp3Volume": true,
|
|
202
|
+
"@aws-cdk/aws-ecs:removeDefaultDeploymentAlarm": true,
|
|
203
|
+
"@aws-cdk/custom-resources:logApiResponseDataPropertyTrueDefault": false
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
",
|
|
207
|
+
"src/main.ts": "import { CdkGraph, FilterPreset, Filters } from '@aws/pdk/cdk-graph';
|
|
208
|
+
import { CdkGraphDiagramPlugin } from '@aws/pdk/cdk-graph-plugin-diagram';
|
|
209
|
+
import { CdkGraphThreatComposerPlugin } from '@aws/pdk/cdk-graph-plugin-threat-composer';
|
|
210
|
+
import { AwsPrototypingChecks, PDKNag } from '@aws/pdk/pdk-nag';
|
|
211
|
+
import { ApplicationStack } from './stacks/application-stack.js';
|
|
212
|
+
|
|
213
|
+
/* eslint-disable @typescript-eslint/no-floating-promises */
|
|
214
|
+
(async () => {
|
|
215
|
+
const app = PDKNag.app({
|
|
216
|
+
nagPacks: [new AwsPrototypingChecks()],
|
|
217
|
+
});
|
|
218
|
+
|
|
219
|
+
// Use this to deploy your own sandbox environment (assumes your CLI credentials)
|
|
220
|
+
new ApplicationStack(app, 'test-sandbox', {
|
|
221
|
+
env: {
|
|
222
|
+
account: process.env.CDK_DEFAULT_ACCOUNT,
|
|
223
|
+
region: process.env.CDK_DEFAULT_REGION,
|
|
224
|
+
},
|
|
225
|
+
});
|
|
226
|
+
|
|
227
|
+
const graph = new CdkGraph(app, {
|
|
228
|
+
plugins: [
|
|
229
|
+
new CdkGraphDiagramPlugin({
|
|
230
|
+
defaults: {
|
|
231
|
+
filterPlan: {
|
|
232
|
+
preset: FilterPreset.COMPACT,
|
|
233
|
+
filters: [{ store: Filters.pruneCustomResources() }],
|
|
234
|
+
},
|
|
235
|
+
},
|
|
236
|
+
}),
|
|
237
|
+
new CdkGraphThreatComposerPlugin(),
|
|
238
|
+
],
|
|
239
|
+
});
|
|
240
|
+
|
|
241
|
+
app.synth();
|
|
242
|
+
await graph.report();
|
|
243
|
+
})();
|
|
244
|
+
",
|
|
245
|
+
"src/stacks/application-stack.ts": "import * as cdk from 'aws-cdk-lib';
|
|
246
|
+
import { Construct } from 'constructs';
|
|
247
|
+
|
|
248
|
+
export class ApplicationStack extends cdk.Stack {
|
|
249
|
+
constructor(scope: Construct, id: string, props?: cdk.StackProps) {
|
|
250
|
+
super(scope, id, props);
|
|
251
|
+
|
|
252
|
+
// The code that defines your stack goes here
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
",
|
|
256
|
+
}
|
|
257
|
+
`;
|
|
258
|
+
|
|
259
|
+
exports[`infra generator > should generate files with correct content > application-stack-ts 1`] = `
|
|
260
|
+
"import * as cdk from 'aws-cdk-lib';
|
|
261
|
+
import { Construct } from 'constructs';
|
|
262
|
+
|
|
263
|
+
export class ApplicationStack extends cdk.Stack {
|
|
264
|
+
constructor(scope: Construct, id: string, props?: cdk.StackProps) {
|
|
265
|
+
super(scope, id, props);
|
|
266
|
+
|
|
267
|
+
// The code that defines your stack goes here
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
"
|
|
271
|
+
`;
|
|
272
|
+
|
|
273
|
+
exports[`infra generator > should generate files with correct content > cdk-json 1`] = `
|
|
274
|
+
"{
|
|
275
|
+
"app": "tsx src/main.ts",
|
|
276
|
+
"output": "../../dist/packages/test/cdk.out",
|
|
277
|
+
"watch": {
|
|
278
|
+
"include": ["**"],
|
|
279
|
+
"exclude": [
|
|
280
|
+
"README.md",
|
|
281
|
+
"cdk*.json",
|
|
282
|
+
"**/*.d.ts",
|
|
283
|
+
"**/*.js",
|
|
284
|
+
"tsconfig.json",
|
|
285
|
+
"package*.json",
|
|
286
|
+
"yarn.lock",
|
|
287
|
+
"node_modules",
|
|
288
|
+
"test"
|
|
289
|
+
]
|
|
290
|
+
},
|
|
291
|
+
"context": {
|
|
292
|
+
"@aws-cdk/aws-lambda:recognizeLayerVersion": true,
|
|
293
|
+
"@aws-cdk/core:checkSecretUsage": true,
|
|
294
|
+
"@aws-cdk/core:target-partitions": ["aws", "aws-cn"],
|
|
295
|
+
"@aws-cdk-containers/ecs-service-extensions:enableDefaultLogDriver": true,
|
|
296
|
+
"@aws-cdk/aws-ec2:uniqueImdsv2TemplateName": true,
|
|
297
|
+
"@aws-cdk/aws-ecs:arnFormatIncludesClusterName": true,
|
|
298
|
+
"@aws-cdk/aws-iam:minimizePolicies": true,
|
|
299
|
+
"@aws-cdk/core:validateSnapshotRemovalPolicy": true,
|
|
300
|
+
"@aws-cdk/aws-codepipeline:crossAccountKeyAliasStackSafeResourceName": true,
|
|
301
|
+
"@aws-cdk/aws-s3:createDefaultLoggingPolicy": true,
|
|
302
|
+
"@aws-cdk/aws-sns-subscriptions:restrictSqsDescryption": true,
|
|
303
|
+
"@aws-cdk/aws-apigateway:disableCloudWatchRole": true,
|
|
304
|
+
"@aws-cdk/core:enablePartitionLiterals": true,
|
|
305
|
+
"@aws-cdk/aws-events:eventsTargetQueueSameAccount": true,
|
|
306
|
+
"@aws-cdk/aws-ecs:disableExplicitDeploymentControllerForCircuitBreaker": true,
|
|
307
|
+
"@aws-cdk/aws-iam:importedRoleStackSafeDefaultPolicyName": true,
|
|
308
|
+
"@aws-cdk/aws-s3:serverAccessLogsUseBucketPolicy": true,
|
|
309
|
+
"@aws-cdk/aws-route53-patters:useCertificate": true,
|
|
310
|
+
"@aws-cdk/customresources:installLatestAwsSdkDefault": false,
|
|
311
|
+
"@aws-cdk/aws-rds:databaseProxyUniqueResourceName": true,
|
|
312
|
+
"@aws-cdk/aws-codedeploy:removeAlarmsFromDeploymentGroup": true,
|
|
313
|
+
"@aws-cdk/aws-apigateway:authorizerChangeDeploymentLogicalId": true,
|
|
314
|
+
"@aws-cdk/aws-ec2:launchTemplateDefaultUserData": true,
|
|
315
|
+
"@aws-cdk/aws-secretsmanager:useAttachedSecretResourcePolicyForSecretTargetAttachments": true,
|
|
316
|
+
"@aws-cdk/aws-redshift:columnId": true,
|
|
317
|
+
"@aws-cdk/aws-stepfunctions-tasks:enableEmrServicePolicyV2": true,
|
|
318
|
+
"@aws-cdk/aws-ec2:restrictDefaultSecurityGroup": true,
|
|
319
|
+
"@aws-cdk/aws-apigateway:requestValidatorUniqueId": true,
|
|
320
|
+
"@aws-cdk/aws-kms:aliasNameRef": true,
|
|
321
|
+
"@aws-cdk/aws-autoscaling:generateLaunchTemplateInsteadOfLaunchConfig": true,
|
|
322
|
+
"@aws-cdk/core:includePrefixInUniqueNameGeneration": true,
|
|
323
|
+
"@aws-cdk/aws-efs:denyAnonymousAccess": true,
|
|
324
|
+
"@aws-cdk/aws-opensearchservice:enableOpensearchMultiAzWithStandby": true,
|
|
325
|
+
"@aws-cdk/aws-lambda-nodejs:useLatestRuntimeVersion": true,
|
|
326
|
+
"@aws-cdk/aws-efs:mountTargetOrderInsensitiveLogicalId": true,
|
|
327
|
+
"@aws-cdk/aws-rds:auroraClusterChangeScopeOfInstanceParameterGroupWithEachParameters": true,
|
|
328
|
+
"@aws-cdk/aws-appsync:useArnForSourceApiAssociationIdentifier": true,
|
|
329
|
+
"@aws-cdk/aws-rds:preventRenderingDeprecatedCredentials": true,
|
|
330
|
+
"@aws-cdk/aws-codepipeline-actions:useNewDefaultBranchForCodeCommitSource": true,
|
|
331
|
+
"@aws-cdk/aws-cloudwatch-actions:changeLambdaPermissionLogicalIdForLambdaAction": true,
|
|
332
|
+
"@aws-cdk/aws-codepipeline:crossAccountKeysDefaultValueToFalse": true,
|
|
333
|
+
"@aws-cdk/aws-codepipeline:defaultPipelineTypeToV2": true,
|
|
334
|
+
"@aws-cdk/aws-kms:reduceCrossAccountRegionPolicyScope": true,
|
|
335
|
+
"@aws-cdk/aws-eks:nodegroupNameAttribute": true,
|
|
336
|
+
"@aws-cdk/aws-ec2:ebsDefaultGp3Volume": true,
|
|
337
|
+
"@aws-cdk/aws-ecs:removeDefaultDeploymentAlarm": true,
|
|
338
|
+
"@aws-cdk/custom-resources:logApiResponseDataPropertyTrueDefault": false
|
|
339
|
+
}
|
|
340
|
+
}
|
|
341
|
+
"
|
|
342
|
+
`;
|
|
343
|
+
|
|
344
|
+
exports[`infra generator > should generate files with correct content > main-ts 1`] = `
|
|
345
|
+
"import { CdkGraph, FilterPreset, Filters } from '@aws/pdk/cdk-graph';
|
|
346
|
+
import { CdkGraphDiagramPlugin } from '@aws/pdk/cdk-graph-plugin-diagram';
|
|
347
|
+
import { CdkGraphThreatComposerPlugin } from '@aws/pdk/cdk-graph-plugin-threat-composer';
|
|
348
|
+
import { AwsPrototypingChecks, PDKNag } from '@aws/pdk/pdk-nag';
|
|
349
|
+
import { ApplicationStack } from './stacks/application-stack.js';
|
|
350
|
+
|
|
351
|
+
/* eslint-disable @typescript-eslint/no-floating-promises */
|
|
352
|
+
(async () => {
|
|
353
|
+
const app = PDKNag.app({
|
|
354
|
+
nagPacks: [new AwsPrototypingChecks()],
|
|
355
|
+
});
|
|
356
|
+
|
|
357
|
+
// Use this to deploy your own sandbox environment (assumes your CLI credentials)
|
|
358
|
+
new ApplicationStack(app, 'test-sandbox', {
|
|
359
|
+
env: {
|
|
360
|
+
account: process.env.CDK_DEFAULT_ACCOUNT,
|
|
361
|
+
region: process.env.CDK_DEFAULT_REGION,
|
|
362
|
+
},
|
|
363
|
+
});
|
|
364
|
+
|
|
365
|
+
const graph = new CdkGraph(app, {
|
|
366
|
+
plugins: [
|
|
367
|
+
new CdkGraphDiagramPlugin({
|
|
368
|
+
defaults: {
|
|
369
|
+
filterPlan: {
|
|
370
|
+
preset: FilterPreset.COMPACT,
|
|
371
|
+
filters: [{ store: Filters.pruneCustomResources() }],
|
|
372
|
+
},
|
|
373
|
+
},
|
|
374
|
+
}),
|
|
375
|
+
new CdkGraphThreatComposerPlugin(),
|
|
376
|
+
],
|
|
377
|
+
});
|
|
378
|
+
|
|
379
|
+
app.synth();
|
|
380
|
+
await graph.report();
|
|
381
|
+
})();
|
|
382
|
+
"
|
|
383
|
+
`;
|
|
384
|
+
|
|
385
|
+
exports[`infra generator > should generate files with correct content > project-structure 1`] = `
|
|
386
|
+
{
|
|
387
|
+
"cdk.json": "{
|
|
388
|
+
"app": "tsx src/main.ts",
|
|
389
|
+
"output": "../../dist/packages/test/cdk.out",
|
|
390
|
+
"watch": {
|
|
391
|
+
"include": ["**"],
|
|
392
|
+
"exclude": [
|
|
393
|
+
"README.md",
|
|
394
|
+
"cdk*.json",
|
|
395
|
+
"**/*.d.ts",
|
|
396
|
+
"**/*.js",
|
|
397
|
+
"tsconfig.json",
|
|
398
|
+
"package*.json",
|
|
399
|
+
"yarn.lock",
|
|
400
|
+
"node_modules",
|
|
401
|
+
"test"
|
|
402
|
+
]
|
|
403
|
+
},
|
|
404
|
+
"context": {
|
|
405
|
+
"@aws-cdk/aws-lambda:recognizeLayerVersion": true,
|
|
406
|
+
"@aws-cdk/core:checkSecretUsage": true,
|
|
407
|
+
"@aws-cdk/core:target-partitions": ["aws", "aws-cn"],
|
|
408
|
+
"@aws-cdk-containers/ecs-service-extensions:enableDefaultLogDriver": true,
|
|
409
|
+
"@aws-cdk/aws-ec2:uniqueImdsv2TemplateName": true,
|
|
410
|
+
"@aws-cdk/aws-ecs:arnFormatIncludesClusterName": true,
|
|
411
|
+
"@aws-cdk/aws-iam:minimizePolicies": true,
|
|
412
|
+
"@aws-cdk/core:validateSnapshotRemovalPolicy": true,
|
|
413
|
+
"@aws-cdk/aws-codepipeline:crossAccountKeyAliasStackSafeResourceName": true,
|
|
414
|
+
"@aws-cdk/aws-s3:createDefaultLoggingPolicy": true,
|
|
415
|
+
"@aws-cdk/aws-sns-subscriptions:restrictSqsDescryption": true,
|
|
416
|
+
"@aws-cdk/aws-apigateway:disableCloudWatchRole": true,
|
|
417
|
+
"@aws-cdk/core:enablePartitionLiterals": true,
|
|
418
|
+
"@aws-cdk/aws-events:eventsTargetQueueSameAccount": true,
|
|
419
|
+
"@aws-cdk/aws-ecs:disableExplicitDeploymentControllerForCircuitBreaker": true,
|
|
420
|
+
"@aws-cdk/aws-iam:importedRoleStackSafeDefaultPolicyName": true,
|
|
421
|
+
"@aws-cdk/aws-s3:serverAccessLogsUseBucketPolicy": true,
|
|
422
|
+
"@aws-cdk/aws-route53-patters:useCertificate": true,
|
|
423
|
+
"@aws-cdk/customresources:installLatestAwsSdkDefault": false,
|
|
424
|
+
"@aws-cdk/aws-rds:databaseProxyUniqueResourceName": true,
|
|
425
|
+
"@aws-cdk/aws-codedeploy:removeAlarmsFromDeploymentGroup": true,
|
|
426
|
+
"@aws-cdk/aws-apigateway:authorizerChangeDeploymentLogicalId": true,
|
|
427
|
+
"@aws-cdk/aws-ec2:launchTemplateDefaultUserData": true,
|
|
428
|
+
"@aws-cdk/aws-secretsmanager:useAttachedSecretResourcePolicyForSecretTargetAttachments": true,
|
|
429
|
+
"@aws-cdk/aws-redshift:columnId": true,
|
|
430
|
+
"@aws-cdk/aws-stepfunctions-tasks:enableEmrServicePolicyV2": true,
|
|
431
|
+
"@aws-cdk/aws-ec2:restrictDefaultSecurityGroup": true,
|
|
432
|
+
"@aws-cdk/aws-apigateway:requestValidatorUniqueId": true,
|
|
433
|
+
"@aws-cdk/aws-kms:aliasNameRef": true,
|
|
434
|
+
"@aws-cdk/aws-autoscaling:generateLaunchTemplateInsteadOfLaunchConfig": true,
|
|
435
|
+
"@aws-cdk/core:includePrefixInUniqueNameGeneration": true,
|
|
436
|
+
"@aws-cdk/aws-efs:denyAnonymousAccess": true,
|
|
437
|
+
"@aws-cdk/aws-opensearchservice:enableOpensearchMultiAzWithStandby": true,
|
|
438
|
+
"@aws-cdk/aws-lambda-nodejs:useLatestRuntimeVersion": true,
|
|
439
|
+
"@aws-cdk/aws-efs:mountTargetOrderInsensitiveLogicalId": true,
|
|
440
|
+
"@aws-cdk/aws-rds:auroraClusterChangeScopeOfInstanceParameterGroupWithEachParameters": true,
|
|
441
|
+
"@aws-cdk/aws-appsync:useArnForSourceApiAssociationIdentifier": true,
|
|
442
|
+
"@aws-cdk/aws-rds:preventRenderingDeprecatedCredentials": true,
|
|
443
|
+
"@aws-cdk/aws-codepipeline-actions:useNewDefaultBranchForCodeCommitSource": true,
|
|
444
|
+
"@aws-cdk/aws-cloudwatch-actions:changeLambdaPermissionLogicalIdForLambdaAction": true,
|
|
445
|
+
"@aws-cdk/aws-codepipeline:crossAccountKeysDefaultValueToFalse": true,
|
|
446
|
+
"@aws-cdk/aws-codepipeline:defaultPipelineTypeToV2": true,
|
|
447
|
+
"@aws-cdk/aws-kms:reduceCrossAccountRegionPolicyScope": true,
|
|
448
|
+
"@aws-cdk/aws-eks:nodegroupNameAttribute": true,
|
|
449
|
+
"@aws-cdk/aws-ec2:ebsDefaultGp3Volume": true,
|
|
450
|
+
"@aws-cdk/aws-ecs:removeDefaultDeploymentAlarm": true,
|
|
451
|
+
"@aws-cdk/custom-resources:logApiResponseDataPropertyTrueDefault": false
|
|
452
|
+
}
|
|
453
|
+
}
|
|
454
|
+
",
|
|
455
|
+
"project.json": "{
|
|
456
|
+
"name": "@proj/test",
|
|
457
|
+
"$schema": "../../node_modules/nx/schemas/project-schema.json",
|
|
458
|
+
"sourceRoot": "packages/test/src",
|
|
459
|
+
"projectType": "application",
|
|
460
|
+
"tags": [],
|
|
461
|
+
"targets": {
|
|
462
|
+
"build": {
|
|
463
|
+
"cache": true,
|
|
464
|
+
"executor": "nx:run-commands",
|
|
465
|
+
"outputs": ["{workspaceRoot}/dist/packages/test/cdk.out"],
|
|
466
|
+
"dependsOn": ["^build"],
|
|
467
|
+
"options": {
|
|
468
|
+
"cwd": "packages/test",
|
|
469
|
+
"command": "cdk synth"
|
|
470
|
+
}
|
|
471
|
+
},
|
|
472
|
+
"lint": {
|
|
473
|
+
"executor": "@nx/eslint:lint"
|
|
474
|
+
},
|
|
475
|
+
"test": {
|
|
476
|
+
"executor": "@nx/jest:jest",
|
|
477
|
+
"outputs": ["{workspaceRoot}/coverage/{projectRoot}"],
|
|
478
|
+
"options": {
|
|
479
|
+
"jestConfig": "packages/test/jest.config.ts"
|
|
480
|
+
}
|
|
481
|
+
},
|
|
482
|
+
"compile": {
|
|
483
|
+
"executor": "@nx/js:tsc",
|
|
484
|
+
"outputs": ["{options.outputPath}"],
|
|
485
|
+
"options": {
|
|
486
|
+
"outputPath": "dist/packages/test",
|
|
487
|
+
"main": "packages/test/src/index.ts",
|
|
488
|
+
"tsConfig": "packages/test/tsconfig.lib.json",
|
|
489
|
+
"assets": ["packages/test/*.md"]
|
|
490
|
+
}
|
|
491
|
+
},
|
|
492
|
+
"deploy": {
|
|
493
|
+
"executor": "nx:run-commands",
|
|
494
|
+
"options": {
|
|
495
|
+
"cwd": "packages/test",
|
|
496
|
+
"command": "cdk deploy --require-approval=never --app ../../dist/packages/test/cdk.out"
|
|
497
|
+
}
|
|
498
|
+
}
|
|
499
|
+
}
|
|
500
|
+
}
|
|
501
|
+
",
|
|
502
|
+
"src/main.ts": "import { CdkGraph, FilterPreset, Filters } from '@aws/pdk/cdk-graph';
|
|
503
|
+
import { CdkGraphDiagramPlugin } from '@aws/pdk/cdk-graph-plugin-diagram';
|
|
504
|
+
import { CdkGraphThreatComposerPlugin } from '@aws/pdk/cdk-graph-plugin-threat-composer';
|
|
505
|
+
import { AwsPrototypingChecks, PDKNag } from '@aws/pdk/pdk-nag';
|
|
506
|
+
import { ApplicationStack } from './stacks/application-stack.js';
|
|
507
|
+
|
|
508
|
+
/* eslint-disable @typescript-eslint/no-floating-promises */
|
|
509
|
+
(async () => {
|
|
510
|
+
const app = PDKNag.app({
|
|
511
|
+
nagPacks: [new AwsPrototypingChecks()],
|
|
512
|
+
});
|
|
513
|
+
|
|
514
|
+
// Use this to deploy your own sandbox environment (assumes your CLI credentials)
|
|
515
|
+
new ApplicationStack(app, 'test-sandbox', {
|
|
516
|
+
env: {
|
|
517
|
+
account: process.env.CDK_DEFAULT_ACCOUNT,
|
|
518
|
+
region: process.env.CDK_DEFAULT_REGION,
|
|
519
|
+
},
|
|
520
|
+
});
|
|
521
|
+
|
|
522
|
+
const graph = new CdkGraph(app, {
|
|
523
|
+
plugins: [
|
|
524
|
+
new CdkGraphDiagramPlugin({
|
|
525
|
+
defaults: {
|
|
526
|
+
filterPlan: {
|
|
527
|
+
preset: FilterPreset.COMPACT,
|
|
528
|
+
filters: [{ store: Filters.pruneCustomResources() }],
|
|
529
|
+
},
|
|
530
|
+
},
|
|
531
|
+
}),
|
|
532
|
+
new CdkGraphThreatComposerPlugin(),
|
|
533
|
+
],
|
|
534
|
+
});
|
|
535
|
+
|
|
536
|
+
app.synth();
|
|
537
|
+
await graph.report();
|
|
538
|
+
})();
|
|
539
|
+
",
|
|
540
|
+
"src/stacks/application-stack.ts": "import * as cdk from 'aws-cdk-lib';
|
|
541
|
+
import { Construct } from 'constructs';
|
|
542
|
+
|
|
543
|
+
export class ApplicationStack extends cdk.Stack {
|
|
544
|
+
constructor(scope: Construct, id: string, props?: cdk.StackProps) {
|
|
545
|
+
super(scope, id, props);
|
|
546
|
+
|
|
547
|
+
// The code that defines your stack goes here
|
|
548
|
+
}
|
|
549
|
+
}
|
|
550
|
+
",
|
|
551
|
+
}
|
|
552
|
+
`;
|
|
553
|
+
|
|
554
|
+
exports[`infra generator > should generate valid CDK application code > cdk-json-content 1`] = `
|
|
555
|
+
{
|
|
556
|
+
"app": "tsx src/main.ts",
|
|
557
|
+
"context": {
|
|
558
|
+
"@aws-cdk-containers/ecs-service-extensions:enableDefaultLogDriver": true,
|
|
559
|
+
"@aws-cdk/aws-apigateway:authorizerChangeDeploymentLogicalId": true,
|
|
560
|
+
"@aws-cdk/aws-apigateway:disableCloudWatchRole": true,
|
|
561
|
+
"@aws-cdk/aws-apigateway:requestValidatorUniqueId": true,
|
|
562
|
+
"@aws-cdk/aws-appsync:useArnForSourceApiAssociationIdentifier": true,
|
|
563
|
+
"@aws-cdk/aws-autoscaling:generateLaunchTemplateInsteadOfLaunchConfig": true,
|
|
564
|
+
"@aws-cdk/aws-cloudwatch-actions:changeLambdaPermissionLogicalIdForLambdaAction": true,
|
|
565
|
+
"@aws-cdk/aws-codedeploy:removeAlarmsFromDeploymentGroup": true,
|
|
566
|
+
"@aws-cdk/aws-codepipeline-actions:useNewDefaultBranchForCodeCommitSource": true,
|
|
567
|
+
"@aws-cdk/aws-codepipeline:crossAccountKeyAliasStackSafeResourceName": true,
|
|
568
|
+
"@aws-cdk/aws-codepipeline:crossAccountKeysDefaultValueToFalse": true,
|
|
569
|
+
"@aws-cdk/aws-codepipeline:defaultPipelineTypeToV2": true,
|
|
570
|
+
"@aws-cdk/aws-ec2:ebsDefaultGp3Volume": true,
|
|
571
|
+
"@aws-cdk/aws-ec2:launchTemplateDefaultUserData": true,
|
|
572
|
+
"@aws-cdk/aws-ec2:restrictDefaultSecurityGroup": true,
|
|
573
|
+
"@aws-cdk/aws-ec2:uniqueImdsv2TemplateName": true,
|
|
574
|
+
"@aws-cdk/aws-ecs:arnFormatIncludesClusterName": true,
|
|
575
|
+
"@aws-cdk/aws-ecs:disableExplicitDeploymentControllerForCircuitBreaker": true,
|
|
576
|
+
"@aws-cdk/aws-ecs:removeDefaultDeploymentAlarm": true,
|
|
577
|
+
"@aws-cdk/aws-efs:denyAnonymousAccess": true,
|
|
578
|
+
"@aws-cdk/aws-efs:mountTargetOrderInsensitiveLogicalId": true,
|
|
579
|
+
"@aws-cdk/aws-eks:nodegroupNameAttribute": true,
|
|
580
|
+
"@aws-cdk/aws-events:eventsTargetQueueSameAccount": true,
|
|
581
|
+
"@aws-cdk/aws-iam:importedRoleStackSafeDefaultPolicyName": true,
|
|
582
|
+
"@aws-cdk/aws-iam:minimizePolicies": true,
|
|
583
|
+
"@aws-cdk/aws-kms:aliasNameRef": true,
|
|
584
|
+
"@aws-cdk/aws-kms:reduceCrossAccountRegionPolicyScope": true,
|
|
585
|
+
"@aws-cdk/aws-lambda-nodejs:useLatestRuntimeVersion": true,
|
|
586
|
+
"@aws-cdk/aws-lambda:recognizeLayerVersion": true,
|
|
587
|
+
"@aws-cdk/aws-opensearchservice:enableOpensearchMultiAzWithStandby": true,
|
|
588
|
+
"@aws-cdk/aws-rds:auroraClusterChangeScopeOfInstanceParameterGroupWithEachParameters": true,
|
|
589
|
+
"@aws-cdk/aws-rds:databaseProxyUniqueResourceName": true,
|
|
590
|
+
"@aws-cdk/aws-rds:preventRenderingDeprecatedCredentials": true,
|
|
591
|
+
"@aws-cdk/aws-redshift:columnId": true,
|
|
592
|
+
"@aws-cdk/aws-route53-patters:useCertificate": true,
|
|
593
|
+
"@aws-cdk/aws-s3:createDefaultLoggingPolicy": true,
|
|
594
|
+
"@aws-cdk/aws-s3:serverAccessLogsUseBucketPolicy": true,
|
|
595
|
+
"@aws-cdk/aws-secretsmanager:useAttachedSecretResourcePolicyForSecretTargetAttachments": true,
|
|
596
|
+
"@aws-cdk/aws-sns-subscriptions:restrictSqsDescryption": true,
|
|
597
|
+
"@aws-cdk/aws-stepfunctions-tasks:enableEmrServicePolicyV2": true,
|
|
598
|
+
"@aws-cdk/core:checkSecretUsage": true,
|
|
599
|
+
"@aws-cdk/core:enablePartitionLiterals": true,
|
|
600
|
+
"@aws-cdk/core:includePrefixInUniqueNameGeneration": true,
|
|
601
|
+
"@aws-cdk/core:target-partitions": [
|
|
602
|
+
"aws",
|
|
603
|
+
"aws-cn",
|
|
604
|
+
],
|
|
605
|
+
"@aws-cdk/core:validateSnapshotRemovalPolicy": true,
|
|
606
|
+
"@aws-cdk/custom-resources:logApiResponseDataPropertyTrueDefault": false,
|
|
607
|
+
"@aws-cdk/customresources:installLatestAwsSdkDefault": false,
|
|
608
|
+
},
|
|
609
|
+
"output": "../../dist/packages/test/cdk.out",
|
|
610
|
+
"watch": {
|
|
611
|
+
"exclude": [
|
|
612
|
+
"README.md",
|
|
613
|
+
"cdk*.json",
|
|
614
|
+
"**/*.d.ts",
|
|
615
|
+
"**/*.js",
|
|
616
|
+
"tsconfig.json",
|
|
617
|
+
"package*.json",
|
|
618
|
+
"yarn.lock",
|
|
619
|
+
"node_modules",
|
|
620
|
+
"test",
|
|
621
|
+
],
|
|
622
|
+
"include": [
|
|
623
|
+
"**",
|
|
624
|
+
],
|
|
625
|
+
},
|
|
626
|
+
}
|
|
627
|
+
`;
|
|
628
|
+
|
|
629
|
+
exports[`infra generator > should generate valid CDK application code > main-ts-content 1`] = `
|
|
630
|
+
"import { CdkGraph, FilterPreset, Filters } from '@aws/pdk/cdk-graph';
|
|
631
|
+
import { CdkGraphDiagramPlugin } from '@aws/pdk/cdk-graph-plugin-diagram';
|
|
632
|
+
import { CdkGraphThreatComposerPlugin } from '@aws/pdk/cdk-graph-plugin-threat-composer';
|
|
633
|
+
import { AwsPrototypingChecks, PDKNag } from '@aws/pdk/pdk-nag';
|
|
634
|
+
import { ApplicationStack } from './stacks/application-stack.js';
|
|
635
|
+
|
|
636
|
+
/* eslint-disable @typescript-eslint/no-floating-promises */
|
|
637
|
+
(async () => {
|
|
638
|
+
const app = PDKNag.app({
|
|
639
|
+
nagPacks: [new AwsPrototypingChecks()],
|
|
640
|
+
});
|
|
641
|
+
|
|
642
|
+
// Use this to deploy your own sandbox environment (assumes your CLI credentials)
|
|
643
|
+
new ApplicationStack(app, 'test-sandbox', {
|
|
644
|
+
env: {
|
|
645
|
+
account: process.env.CDK_DEFAULT_ACCOUNT,
|
|
646
|
+
region: process.env.CDK_DEFAULT_REGION,
|
|
647
|
+
},
|
|
648
|
+
});
|
|
649
|
+
|
|
650
|
+
const graph = new CdkGraph(app, {
|
|
651
|
+
plugins: [
|
|
652
|
+
new CdkGraphDiagramPlugin({
|
|
653
|
+
defaults: {
|
|
654
|
+
filterPlan: {
|
|
655
|
+
preset: FilterPreset.COMPACT,
|
|
656
|
+
filters: [{ store: Filters.pruneCustomResources() }],
|
|
657
|
+
},
|
|
658
|
+
},
|
|
659
|
+
}),
|
|
660
|
+
new CdkGraphThreatComposerPlugin(),
|
|
661
|
+
],
|
|
662
|
+
});
|
|
663
|
+
|
|
664
|
+
app.synth();
|
|
665
|
+
await graph.report();
|
|
666
|
+
})();
|
|
667
|
+
"
|
|
668
|
+
`;
|
|
669
|
+
|
|
670
|
+
exports[`infra generator > should generate valid CDK application code > stack-ts-content 1`] = `
|
|
671
|
+
"import * as cdk from 'aws-cdk-lib';
|
|
672
|
+
import { Construct } from 'constructs';
|
|
673
|
+
|
|
674
|
+
export class ApplicationStack extends cdk.Stack {
|
|
675
|
+
constructor(scope: Construct, id: string, props?: cdk.StackProps) {
|
|
676
|
+
super(scope, id, props);
|
|
677
|
+
|
|
678
|
+
// The code that defines your stack goes here
|
|
679
|
+
}
|
|
680
|
+
}
|
|
681
|
+
"
|
|
682
|
+
`;
|
|
683
|
+
|
|
684
|
+
exports[`infra generator > should handle custom project names correctly > custom-name-files 1`] = `
|
|
685
|
+
{
|
|
686
|
+
"cdk.json": "{
|
|
687
|
+
"app": "tsx src/main.ts",
|
|
688
|
+
"output": "../../dist/packages/custom-infra/cdk.out",
|
|
689
|
+
"watch": {
|
|
690
|
+
"include": ["**"],
|
|
691
|
+
"exclude": [
|
|
692
|
+
"README.md",
|
|
693
|
+
"cdk*.json",
|
|
694
|
+
"**/*.d.ts",
|
|
695
|
+
"**/*.js",
|
|
696
|
+
"tsconfig.json",
|
|
697
|
+
"package*.json",
|
|
698
|
+
"yarn.lock",
|
|
699
|
+
"node_modules",
|
|
700
|
+
"test"
|
|
701
|
+
]
|
|
702
|
+
},
|
|
703
|
+
"context": {
|
|
704
|
+
"@aws-cdk/aws-lambda:recognizeLayerVersion": true,
|
|
705
|
+
"@aws-cdk/core:checkSecretUsage": true,
|
|
706
|
+
"@aws-cdk/core:target-partitions": ["aws", "aws-cn"],
|
|
707
|
+
"@aws-cdk-containers/ecs-service-extensions:enableDefaultLogDriver": true,
|
|
708
|
+
"@aws-cdk/aws-ec2:uniqueImdsv2TemplateName": true,
|
|
709
|
+
"@aws-cdk/aws-ecs:arnFormatIncludesClusterName": true,
|
|
710
|
+
"@aws-cdk/aws-iam:minimizePolicies": true,
|
|
711
|
+
"@aws-cdk/core:validateSnapshotRemovalPolicy": true,
|
|
712
|
+
"@aws-cdk/aws-codepipeline:crossAccountKeyAliasStackSafeResourceName": true,
|
|
713
|
+
"@aws-cdk/aws-s3:createDefaultLoggingPolicy": true,
|
|
714
|
+
"@aws-cdk/aws-sns-subscriptions:restrictSqsDescryption": true,
|
|
715
|
+
"@aws-cdk/aws-apigateway:disableCloudWatchRole": true,
|
|
716
|
+
"@aws-cdk/core:enablePartitionLiterals": true,
|
|
717
|
+
"@aws-cdk/aws-events:eventsTargetQueueSameAccount": true,
|
|
718
|
+
"@aws-cdk/aws-ecs:disableExplicitDeploymentControllerForCircuitBreaker": true,
|
|
719
|
+
"@aws-cdk/aws-iam:importedRoleStackSafeDefaultPolicyName": true,
|
|
720
|
+
"@aws-cdk/aws-s3:serverAccessLogsUseBucketPolicy": true,
|
|
721
|
+
"@aws-cdk/aws-route53-patters:useCertificate": true,
|
|
722
|
+
"@aws-cdk/customresources:installLatestAwsSdkDefault": false,
|
|
723
|
+
"@aws-cdk/aws-rds:databaseProxyUniqueResourceName": true,
|
|
724
|
+
"@aws-cdk/aws-codedeploy:removeAlarmsFromDeploymentGroup": true,
|
|
725
|
+
"@aws-cdk/aws-apigateway:authorizerChangeDeploymentLogicalId": true,
|
|
726
|
+
"@aws-cdk/aws-ec2:launchTemplateDefaultUserData": true,
|
|
727
|
+
"@aws-cdk/aws-secretsmanager:useAttachedSecretResourcePolicyForSecretTargetAttachments": true,
|
|
728
|
+
"@aws-cdk/aws-redshift:columnId": true,
|
|
729
|
+
"@aws-cdk/aws-stepfunctions-tasks:enableEmrServicePolicyV2": true,
|
|
730
|
+
"@aws-cdk/aws-ec2:restrictDefaultSecurityGroup": true,
|
|
731
|
+
"@aws-cdk/aws-apigateway:requestValidatorUniqueId": true,
|
|
732
|
+
"@aws-cdk/aws-kms:aliasNameRef": true,
|
|
733
|
+
"@aws-cdk/aws-autoscaling:generateLaunchTemplateInsteadOfLaunchConfig": true,
|
|
734
|
+
"@aws-cdk/core:includePrefixInUniqueNameGeneration": true,
|
|
735
|
+
"@aws-cdk/aws-efs:denyAnonymousAccess": true,
|
|
736
|
+
"@aws-cdk/aws-opensearchservice:enableOpensearchMultiAzWithStandby": true,
|
|
737
|
+
"@aws-cdk/aws-lambda-nodejs:useLatestRuntimeVersion": true,
|
|
738
|
+
"@aws-cdk/aws-efs:mountTargetOrderInsensitiveLogicalId": true,
|
|
739
|
+
"@aws-cdk/aws-rds:auroraClusterChangeScopeOfInstanceParameterGroupWithEachParameters": true,
|
|
740
|
+
"@aws-cdk/aws-appsync:useArnForSourceApiAssociationIdentifier": true,
|
|
741
|
+
"@aws-cdk/aws-rds:preventRenderingDeprecatedCredentials": true,
|
|
742
|
+
"@aws-cdk/aws-codepipeline-actions:useNewDefaultBranchForCodeCommitSource": true,
|
|
743
|
+
"@aws-cdk/aws-cloudwatch-actions:changeLambdaPermissionLogicalIdForLambdaAction": true,
|
|
744
|
+
"@aws-cdk/aws-codepipeline:crossAccountKeysDefaultValueToFalse": true,
|
|
745
|
+
"@aws-cdk/aws-codepipeline:defaultPipelineTypeToV2": true,
|
|
746
|
+
"@aws-cdk/aws-kms:reduceCrossAccountRegionPolicyScope": true,
|
|
747
|
+
"@aws-cdk/aws-eks:nodegroupNameAttribute": true,
|
|
748
|
+
"@aws-cdk/aws-ec2:ebsDefaultGp3Volume": true,
|
|
749
|
+
"@aws-cdk/aws-ecs:removeDefaultDeploymentAlarm": true,
|
|
750
|
+
"@aws-cdk/custom-resources:logApiResponseDataPropertyTrueDefault": false
|
|
751
|
+
}
|
|
752
|
+
}
|
|
753
|
+
",
|
|
754
|
+
"src/main.ts": "import { CdkGraph, FilterPreset, Filters } from '@aws/pdk/cdk-graph';
|
|
755
|
+
import { CdkGraphDiagramPlugin } from '@aws/pdk/cdk-graph-plugin-diagram';
|
|
756
|
+
import { CdkGraphThreatComposerPlugin } from '@aws/pdk/cdk-graph-plugin-threat-composer';
|
|
757
|
+
import { AwsPrototypingChecks, PDKNag } from '@aws/pdk/pdk-nag';
|
|
758
|
+
import { ApplicationStack } from './stacks/application-stack.js';
|
|
759
|
+
|
|
760
|
+
/* eslint-disable @typescript-eslint/no-floating-promises */
|
|
761
|
+
(async () => {
|
|
762
|
+
const app = PDKNag.app({
|
|
763
|
+
nagPacks: [new AwsPrototypingChecks()],
|
|
764
|
+
});
|
|
765
|
+
|
|
766
|
+
// Use this to deploy your own sandbox environment (assumes your CLI credentials)
|
|
767
|
+
new ApplicationStack(app, 'custom-infra-sandbox', {
|
|
768
|
+
env: {
|
|
769
|
+
account: process.env.CDK_DEFAULT_ACCOUNT,
|
|
770
|
+
region: process.env.CDK_DEFAULT_REGION,
|
|
771
|
+
},
|
|
772
|
+
});
|
|
773
|
+
|
|
774
|
+
const graph = new CdkGraph(app, {
|
|
775
|
+
plugins: [
|
|
776
|
+
new CdkGraphDiagramPlugin({
|
|
777
|
+
defaults: {
|
|
778
|
+
filterPlan: {
|
|
779
|
+
preset: FilterPreset.COMPACT,
|
|
780
|
+
filters: [{ store: Filters.pruneCustomResources() }],
|
|
781
|
+
},
|
|
782
|
+
},
|
|
783
|
+
}),
|
|
784
|
+
new CdkGraphThreatComposerPlugin(),
|
|
785
|
+
],
|
|
786
|
+
});
|
|
787
|
+
|
|
788
|
+
app.synth();
|
|
789
|
+
await graph.report();
|
|
790
|
+
})();
|
|
791
|
+
",
|
|
792
|
+
"src/stacks/application-stack.ts": "import * as cdk from 'aws-cdk-lib';
|
|
793
|
+
import { Construct } from 'constructs';
|
|
794
|
+
|
|
795
|
+
export class ApplicationStack extends cdk.Stack {
|
|
796
|
+
constructor(scope: Construct, id: string, props?: cdk.StackProps) {
|
|
797
|
+
super(scope, id, props);
|
|
798
|
+
|
|
799
|
+
// The code that defines your stack goes here
|
|
800
|
+
}
|
|
801
|
+
}
|
|
802
|
+
",
|
|
803
|
+
}
|
|
804
|
+
`;
|
|
805
|
+
|
|
806
|
+
exports[`infra generator > should handle custom project names correctly > custom-name-project-config 1`] = `
|
|
807
|
+
{
|
|
808
|
+
"$schema": "../../node_modules/nx/schemas/project-schema.json",
|
|
809
|
+
"name": "@proj/custom-infra",
|
|
810
|
+
"projectType": "application",
|
|
811
|
+
"root": "packages/custom-infra",
|
|
812
|
+
"sourceRoot": "packages/custom-infra/src",
|
|
813
|
+
"tags": [],
|
|
814
|
+
"targets": {
|
|
815
|
+
"build": {
|
|
816
|
+
"cache": true,
|
|
817
|
+
"dependsOn": [
|
|
818
|
+
"^build",
|
|
819
|
+
],
|
|
820
|
+
"executor": "nx:run-commands",
|
|
821
|
+
"options": {
|
|
822
|
+
"command": "cdk synth",
|
|
823
|
+
"cwd": "packages/custom-infra",
|
|
824
|
+
},
|
|
825
|
+
"outputs": [
|
|
826
|
+
"{workspaceRoot}/dist/packages/custom-infra/cdk.out",
|
|
827
|
+
],
|
|
828
|
+
},
|
|
829
|
+
"compile": {
|
|
830
|
+
"executor": "@nx/js:tsc",
|
|
831
|
+
"options": {
|
|
832
|
+
"assets": [
|
|
833
|
+
"packages/custom-infra/*.md",
|
|
834
|
+
],
|
|
835
|
+
"main": "packages/custom-infra/src/index.ts",
|
|
836
|
+
"outputPath": "dist/packages/custom-infra",
|
|
837
|
+
"tsConfig": "packages/custom-infra/tsconfig.lib.json",
|
|
838
|
+
},
|
|
839
|
+
"outputs": [
|
|
840
|
+
"{options.outputPath}",
|
|
841
|
+
],
|
|
842
|
+
},
|
|
843
|
+
"deploy": {
|
|
844
|
+
"executor": "nx:run-commands",
|
|
845
|
+
"options": {
|
|
846
|
+
"command": "cdk deploy --require-approval=never --app ../../dist/packages/custom-infra/cdk.out",
|
|
847
|
+
"cwd": "packages/custom-infra",
|
|
848
|
+
},
|
|
849
|
+
},
|
|
850
|
+
"lint": {
|
|
851
|
+
"executor": "@nx/eslint:lint",
|
|
852
|
+
},
|
|
853
|
+
"test": {
|
|
854
|
+
"executor": "@nx/jest:jest",
|
|
855
|
+
"options": {
|
|
856
|
+
"jestConfig": "packages/custom-infra/jest.config.ts",
|
|
857
|
+
},
|
|
858
|
+
"outputs": [
|
|
859
|
+
"{workspaceRoot}/coverage/{projectRoot}",
|
|
860
|
+
],
|
|
861
|
+
},
|
|
862
|
+
},
|
|
863
|
+
}
|
|
864
|
+
`;
|