@aws/nx-plugin 0.1.5 → 0.2.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/LICENSE-THIRD-PARTY +794 -496
- package/generators.json +1 -7
- package/package.json +7 -7
- package/src/cloudscape-website/app/README.md +84 -48
- package/src/cloudscape-website/app/__snapshots__/generator.spec.ts.snap +157 -218
- package/src/cloudscape-website/app/files/app/README.md.template +44 -0
- package/src/cloudscape-website/app/files/app/src/layouts/App/index.tsx.template +40 -43
- package/src/cloudscape-website/app/files/app/src/layouts/App/navitems.ts.template +3 -3
- package/src/cloudscape-website/app/files/app/src/layouts/Routes/index.tsx.template +4 -6
- package/src/cloudscape-website/app/files/app/src/main.tsx.template +7 -10
- package/src/cloudscape-website/app/files/app/src/pages/Home/index.tsx.template +0 -2
- package/src/cloudscape-website/app/files/common/constructs/src/app/static-websites/__websiteNameKebabCase__.ts.template +13 -0
- package/src/cloudscape-website/app/files/common/constructs/src/{__websiteNameKebabCase__ → core}/static-website.ts.template +74 -144
- package/src/cloudscape-website/app/generator.js +83 -65
- package/src/cloudscape-website/app/generator.js.map +1 -1
- package/src/cloudscape-website/app/schema.d.ts +3 -6
- package/src/cloudscape-website/app/schema.json +1 -29
- package/src/cloudscape-website/cognito-auth/README.md +53 -32
- package/src/cloudscape-website/cognito-auth/__snapshots__/generator.spec.ts.snap +161 -125
- package/src/cloudscape-website/cognito-auth/files/app/components/CognitoAuth/index.tsx.template +53 -39
- package/src/cloudscape-website/cognito-auth/files/common/constructs/src/core/user-identity.ts.template +168 -0
- package/src/cloudscape-website/cognito-auth/generator.js +129 -46
- package/src/cloudscape-website/cognito-auth/generator.js.map +1 -1
- package/src/cloudscape-website/cognito-auth/schema.d.ts +1 -0
- package/src/cloudscape-website/cognito-auth/schema.json +7 -1
- package/src/cloudscape-website/runtime-config/__snapshots__/generator.spec.ts.snap +15 -17
- package/src/cloudscape-website/runtime-config/files/app/components/RuntimeConfig/index.tsx.template +7 -10
- package/src/cloudscape-website/runtime-config/files/app/hooks/useRuntimeConfig.tsx.template +13 -0
- package/src/cloudscape-website/runtime-config/generator.js +3 -1
- package/src/cloudscape-website/runtime-config/generator.js.map +1 -1
- package/src/infra/app/README.md +71 -46
- package/src/infra/app/__snapshots__/generator.spec.ts.snap +120 -187
- package/src/infra/app/files/app/README.md.template +76 -0
- package/src/infra/app/files/app/src/main.ts.template +18 -0
- package/src/infra/app/files/common/constructs/src/core/cfn-guard-rules/aws-prototyping.guard +1282 -0
- package/src/infra/app/files/common/constructs/src/core/cfn-guard-rules/cfn-nag.guard +6839 -0
- package/src/infra/app/files/common/constructs/src/core/cfn-guard-rules/hipaa-security.guard +2807 -0
- package/src/infra/app/files/common/constructs/src/core/cfn-guard-rules/nist-csf.guard +2585 -0
- package/src/infra/app/files/common/constructs/src/core/cfn-guard-rules/pci-dss-3-2-1.guard +2236 -0
- package/src/infra/app/files/common/constructs/src/core/cfn-guard-rules/wa-reliability-pillar.guard +885 -0
- package/src/infra/app/files/common/constructs/src/core/cfn-guard-rules/wa-security-pillar.guard +2205 -0
- package/src/infra/app/files/common/constructs/src/core/cfn-guard.ts.template +63 -0
- package/src/infra/app/generator.js +17 -3
- package/src/infra/app/generator.js.map +1 -1
- package/src/infra/app/schema.d.ts +10 -1
- package/src/infra/app/schema.json +16 -8
- package/src/trpc/backend/README.md +102 -80
- package/src/trpc/backend/__snapshots__/generator.spec.ts.snap +37 -17
- package/src/trpc/backend/files/backend/README.md.template +33 -0
- package/src/trpc/backend/files/common/constructs/src/app/trpc-apis/__apiNameKebabCase__.ts.template +18 -0
- package/src/trpc/backend/files/common/constructs/src/{__apiNameKebabCase__/index.ts.template → core/trpc-api.ts.template} +12 -16
- package/src/trpc/backend/files/schema/README.md.template +33 -0
- package/src/trpc/backend/generator.js +29 -43
- package/src/trpc/backend/generator.js.map +1 -1
- package/src/trpc/backend/schema.d.ts +3 -1
- package/src/trpc/backend/schema.json +8 -13
- package/src/trpc/react/README.md +46 -66
- package/src/trpc/react/__snapshots__/generator.spec.ts.snap +104 -65
- package/src/trpc/react/files/src/components/TrpcClients/IsolatedTrpcProvider.tsx.template +75 -0
- package/src/trpc/react/files/src/components/TrpcClients/TrpcApis.tsx.template +1 -0
- package/src/trpc/react/files/src/components/TrpcClients/TrpcClientProviders.tsx.template +10 -0
- package/src/trpc/react/files/src/components/TrpcClients/index.tsx.template +5 -0
- package/src/trpc/react/files/src/hooks/useSigV4.tsx.template +38 -0
- package/src/trpc/react/files/src/hooks/use__apiNameClassName__.tsx.template +3 -0
- package/src/trpc/react/generator.js +123 -24
- package/src/trpc/react/generator.js.map +1 -1
- package/src/trpc/react/schema.json +2 -2
- package/src/ts/cjs-to-esm/generator.js.map +1 -1
- package/src/ts/lib/eslint.d.ts +1 -1
- package/src/ts/lib/eslint.js +59 -11
- package/src/ts/lib/eslint.js.map +1 -1
- package/src/ts/lib/files/README.md.template +33 -0
- package/src/ts/lib/generator.js +11 -4
- package/src/ts/lib/generator.js.map +1 -1
- package/src/ts/lib/schema.d.ts +1 -3
- package/src/ts/lib/schema.json +2 -15
- package/src/ts/lib/ts-project-utils.js.map +1 -1
- package/src/ts/lib/vitest.js +14 -0
- package/src/ts/lib/vitest.js.map +1 -1
- package/src/utils/ast.d.ts +13 -0
- package/src/utils/ast.js +102 -0
- package/src/utils/ast.js.map +1 -0
- package/src/utils/files/common/constructs/src/app/index.ts.template +0 -0
- package/src/utils/files/common/constructs/src/{runtime-config → core}/runtime-config.ts.template +3 -5
- package/src/utils/files/common/constructs/src/index.ts.template +2 -1
- package/src/utils/files/common/readme/README.md.template +33 -0
- package/src/utils/files/common/types/src/runtime-config.ts.template +1 -13
- package/src/utils/format.js.map +1 -1
- package/src/utils/names.d.ts +2 -0
- package/src/utils/names.js +27 -0
- package/src/utils/names.js.map +1 -0
- package/src/utils/npm-scope.js.map +1 -1
- package/src/utils/paths.js.map +1 -1
- package/src/utils/shared-constructs.js +37 -4
- package/src/utils/shared-constructs.js.map +1 -1
- package/src/utils/versions.d.ts +15 -9
- package/src/utils/versions.js +14 -8
- package/src/utils/versions.js.map +1 -1
- package/src/cloudscape-website/app/files/common/constructs/src/__websiteNameKebabCase__/cloudfront-web-acl.ts.template +0 -317
- package/src/cloudscape-website/app/files/common/constructs/src/__websiteNameKebabCase__/index.ts.template +0 -4
- package/src/cloudscape-website/app/files/common/constructs/src/__websiteNameKebabCase__/webacl_event_handler/index.ts.template +0 -301
- package/src/cloudscape-website/cognito-auth/files/common/constructs/src/identity/index.ts.template +0 -4
- package/src/cloudscape-website/cognito-auth/files/common/constructs/src/identity/user-identity.ts.template +0 -66
- package/src/cloudscape-website/cognito-auth/files/common/constructs/src/identity/userpool-with-mfa.ts.template +0 -70
- package/src/gitlab/generator.d.ts +0 -8
- package/src/gitlab/generator.js +0 -16
- package/src/gitlab/generator.js.map +0 -1
- package/src/gitlab/schema.d.ts +0 -9
- package/src/gitlab/schema.json +0 -52
- package/src/infra/app/files/src/main.ts.template +0 -37
- package/src/trpc/react/files/src/components/TRPCClientProvider/index.tsx.template +0 -34
- package/src/trpc/react/files/src/hooks/useTrpc.tsx.template +0 -5
- /package/src/infra/app/files/{cdk.json → app/cdk.json} +0 -0
- /package/src/infra/app/files/{src → app/src}/stacks/application-stack.ts.template +0 -0
- /package/src/utils/files/common/constructs/src/{runtime-config → core}/index.ts.template +0 -0
package/src/infra/app/README.md
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
# Infrastructure App Generator
|
|
2
2
|
|
|
3
3
|
## Overview
|
|
4
|
-
|
|
4
|
+
|
|
5
|
+
This generator creates a new AWS CDK infrastructure application. The generated application includes security best practices through CFN guard checks. The codebase is structured using TypeScript and ES Modules (ESM) for modern development practices.
|
|
5
6
|
|
|
6
7
|
## Usage
|
|
7
8
|
|
|
@@ -10,12 +11,14 @@ You can generate a new infrastructure application in two ways:
|
|
|
10
11
|
### 1. Using VSCode IDE
|
|
11
12
|
|
|
12
13
|
First, install the NX Console extension for VSCode:
|
|
14
|
+
|
|
13
15
|
1. Open VSCode
|
|
14
16
|
2. Go to Extensions (Ctrl+Shift+X / Cmd+Shift+X)
|
|
15
17
|
3. Search for "Nx Console"
|
|
16
18
|
4. Install [Nx Console](https://marketplace.visualstudio.com/items?itemName=nrwl.angular-console)
|
|
17
19
|
|
|
18
20
|
Then generate your application:
|
|
21
|
+
|
|
19
22
|
1. Open the NX Console in VSCode
|
|
20
23
|
2. Click on "Generate"
|
|
21
24
|
3. Search for "infra#app"
|
|
@@ -25,33 +28,38 @@ Then generate your application:
|
|
|
25
28
|
### 2. Using CLI
|
|
26
29
|
|
|
27
30
|
Generate the application:
|
|
31
|
+
|
|
28
32
|
```bash
|
|
29
33
|
nx g @aws/nx-plugin:infra#app my-infra --directory=apps/infrastructure
|
|
30
34
|
```
|
|
31
35
|
|
|
32
36
|
You can also perform a dry-run to see what files would be generated without actually creating them:
|
|
37
|
+
|
|
33
38
|
```bash
|
|
34
39
|
nx g @aws/nx-plugin:infra#app my-infra --directory=apps/infrastructure --dry-run
|
|
35
40
|
```
|
|
36
41
|
|
|
37
42
|
## Input Parameters
|
|
38
43
|
|
|
39
|
-
| Parameter
|
|
40
|
-
|
|
41
|
-
| name
|
|
42
|
-
|
|
|
43
|
-
|
|
|
44
|
+
| Parameter | Type | Default | Description |
|
|
45
|
+
| -------------- | ------ | --------------- | ---------------------------------------------------------------------------------------- |
|
|
46
|
+
| name\* | string | - | The name of the application (required). Must start with a letter and not contain colons. |
|
|
47
|
+
| ruleSet\* | string | aws_prototyping | cfn guard ruleset to use |
|
|
48
|
+
| directory | string | "packages" | The directory to store the application in. |
|
|
49
|
+
| unitTestRunner | string | "vitest" | Test runner for unit tests. Options: jest, vitest, none |
|
|
44
50
|
|
|
45
|
-
|
|
51
|
+
\*Required parameter
|
|
46
52
|
|
|
47
53
|
## Expected Output
|
|
48
54
|
|
|
49
|
-
The generator creates
|
|
55
|
+
The generator creates two main components:
|
|
56
|
+
|
|
57
|
+
### 1. Infra app code
|
|
50
58
|
|
|
51
59
|
```
|
|
52
60
|
<directory>/<name>/
|
|
53
61
|
├── src/
|
|
54
|
-
│
|
|
62
|
+
│ └── main.ts # Application entry point with CDK and PDK setup
|
|
55
63
|
│ └── stacks/ # CDK stack definitions
|
|
56
64
|
│ └── application-stack.ts # Main application stack
|
|
57
65
|
├── cdk.json # CDK configuration
|
|
@@ -59,12 +67,24 @@ The generator creates an infrastructure application with the following structure
|
|
|
59
67
|
└── project.json # Project configuration and build targets
|
|
60
68
|
```
|
|
61
69
|
|
|
70
|
+
### 2. Infra library code
|
|
71
|
+
|
|
72
|
+
```
|
|
73
|
+
common/constructs
|
|
74
|
+
└── src
|
|
75
|
+
└── core
|
|
76
|
+
└── cfn-guard.ts # Provides a wrapper around @cdklabs/cdk-validator-cfnguard along with a suppressRule function
|
|
77
|
+
└── cfn-guard-rules
|
|
78
|
+
└── *.guard # cfn guard ruleset definitions
|
|
79
|
+
```
|
|
80
|
+
|
|
62
81
|
Additionally, it:
|
|
82
|
+
|
|
63
83
|
1. Configures build settings for CDK synthesis and deployment
|
|
64
84
|
2. Installs required dependencies:
|
|
65
|
-
- @aws/pdk
|
|
66
85
|
- aws-cdk-lib
|
|
67
86
|
- aws-cdk
|
|
87
|
+
- @cdklabs/cdk-validator-cfnguard
|
|
68
88
|
- constructs
|
|
69
89
|
- esbuild
|
|
70
90
|
- source-map-support
|
|
@@ -72,42 +92,24 @@ Additionally, it:
|
|
|
72
92
|
|
|
73
93
|
## Features
|
|
74
94
|
|
|
75
|
-
### 1.
|
|
76
|
-
The generated application includes PDK (Project Development Kit) integration which provides:
|
|
77
|
-
- Security best practices through PDK Nag checks
|
|
78
|
-
- Infrastructure visualization with CDK Graph
|
|
79
|
-
- Threat modeling capabilities through Threat Composer
|
|
95
|
+
### 1. Cfn Guard integration
|
|
80
96
|
|
|
81
|
-
|
|
82
|
-
The application automatically generates infrastructure diagrams using CDK Graph:
|
|
83
|
-
```typescript
|
|
84
|
-
const graph = new CdkGraph(app, {
|
|
85
|
-
plugins: [
|
|
86
|
-
new CdkGraphDiagramPlugin({
|
|
87
|
-
defaults: {
|
|
88
|
-
filterPlan: {
|
|
89
|
-
preset: FilterPreset.COMPACT,
|
|
90
|
-
filters: [{ store: Filters.pruneCustomResources() }],
|
|
91
|
-
},
|
|
92
|
-
},
|
|
93
|
-
}),
|
|
94
|
-
new CdkGraphThreatComposerPlugin(),
|
|
95
|
-
],
|
|
96
|
-
});
|
|
97
|
-
```
|
|
97
|
+
The generated application includes Cfn guard integration which ensures security best practices via automated policy checks.
|
|
98
98
|
|
|
99
|
-
### 3. Security Checks
|
|
100
|
-
PDK Nag is configured with AWS Prototyping Checks to ensure infrastructure security:
|
|
101
99
|
```typescript
|
|
102
|
-
|
|
103
|
-
|
|
100
|
+
import { CfnGuardValidator, RuleSet } from ':e2e-test/common-constructs';
|
|
101
|
+
|
|
102
|
+
const app = new App({
|
|
103
|
+
policyValidationBeta1: [new CfnGuardValidator(RuleSet.AWS_PROTOTYPING)],
|
|
104
104
|
});
|
|
105
105
|
```
|
|
106
106
|
|
|
107
|
-
###
|
|
107
|
+
### 2. Build and Deploy Targets
|
|
108
|
+
|
|
108
109
|
The generator configures two main targets in your project.json:
|
|
109
110
|
|
|
110
111
|
1. **Build Target**
|
|
112
|
+
|
|
111
113
|
- Synthesizes CDK templates
|
|
112
114
|
- Caches results for faster subsequent builds
|
|
113
115
|
- Outputs to `dist/<directory>/cdk.out`
|
|
@@ -126,19 +128,17 @@ Add AWS resources to your stack in `src/stacks/application-stack.ts`:
|
|
|
126
128
|
```typescript
|
|
127
129
|
import * as cdk from 'aws-cdk-lib';
|
|
128
130
|
import { Construct } from 'constructs';
|
|
129
|
-
|
|
130
|
-
import {
|
|
131
|
+
/* Replace MyWebsite and MyApi with whatever you called them */
|
|
132
|
+
import { UserIdentity, MyWebsite, MyApi } from ':my-org/common-constructs';
|
|
131
133
|
|
|
132
134
|
export class ApplicationStack extends cdk.Stack {
|
|
133
135
|
constructor(scope: Construct, id: string, props?: cdk.StackProps) {
|
|
134
136
|
super(scope, id, props);
|
|
135
137
|
|
|
136
138
|
const identity = new UserIdentity(this, 'UserIdentity');
|
|
137
|
-
const myapi = new MyApi(this, 'MyApi'
|
|
138
|
-
defaultAuthorizer: new HttpIamAuthorizer(),
|
|
139
|
-
});
|
|
139
|
+
const myapi = new MyApi(this, 'MyApi');
|
|
140
140
|
myapi.grantInvokeAccess(identity.identityPool.authenticatedRole);
|
|
141
|
-
new
|
|
141
|
+
new MyWebsite(this, 'Website');
|
|
142
142
|
}
|
|
143
143
|
}
|
|
144
144
|
```
|
|
@@ -148,14 +148,15 @@ The generated code serves as a starting point that you can adapt to your specifi
|
|
|
148
148
|
### Building the Application
|
|
149
149
|
|
|
150
150
|
To create a production build:
|
|
151
|
+
|
|
151
152
|
```bash
|
|
152
153
|
nx build my-infra
|
|
153
154
|
```
|
|
154
155
|
|
|
155
156
|
All built code is located in the `dist` folder at the root of your workspace. For example, if your infrastructure application is in `apps/infrastructure/my-infra`, the built code will be in `dist/apps/infrastructure/my-infra`. This includes:
|
|
157
|
+
|
|
156
158
|
- Compiled TypeScript files
|
|
157
159
|
- CDK synthesized templates in `dist/apps/infrastructure/my-infra/cdk.out`
|
|
158
|
-
- Generated infrastructure diagrams
|
|
159
160
|
- Source maps for debugging
|
|
160
161
|
|
|
161
162
|
### Deploying to AWS
|
|
@@ -163,7 +164,7 @@ All built code is located in the `dist` folder at the root of your workspace. Fo
|
|
|
163
164
|
To deploy your infrastructure:
|
|
164
165
|
|
|
165
166
|
```bash
|
|
166
|
-
nx deploy my-infra
|
|
167
|
+
nx deploy my-infra --all
|
|
167
168
|
```
|
|
168
169
|
|
|
169
170
|
This command will deploy your infrastructure to AWS using the account and region configured in your AWS CLI.
|
|
@@ -172,4 +173,28 @@ You can also perform a hotswap deployment if you are only making modifications t
|
|
|
172
173
|
|
|
173
174
|
```bash
|
|
174
175
|
nx deploy my-infra --hotswap
|
|
175
|
-
```
|
|
176
|
+
```
|
|
177
|
+
|
|
178
|
+
### Cfn Guard Suppressions
|
|
179
|
+
|
|
180
|
+
There may be instances where you want to suppress certain rules on resources. You can do this in two ways:
|
|
181
|
+
|
|
182
|
+
#### Supress a rule on a given construct
|
|
183
|
+
|
|
184
|
+
```typescript
|
|
185
|
+
import { suppressRule } from ':my-org/common-constructs';
|
|
186
|
+
|
|
187
|
+
...
|
|
188
|
+
// suppresses the RULE_NAME for the given construct.
|
|
189
|
+
suppressRule(construct, 'RULE_NAME');
|
|
190
|
+
```
|
|
191
|
+
|
|
192
|
+
#### Supress a rule on a descendant construct
|
|
193
|
+
|
|
194
|
+
```typescript
|
|
195
|
+
import { suppressRule } from ':my-org/common-constructs';
|
|
196
|
+
|
|
197
|
+
...
|
|
198
|
+
// Supresses the RULE_NAME for the construct or any of its descendants if it is an instance of Bucket
|
|
199
|
+
suppressRule(construct, 'RULE_NAME', (construct) => construct instanceof Bucket);
|
|
200
|
+
```
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
exports[`infra generator > should add required dependencies to package.json > dependencies 1`] = `
|
|
4
4
|
{
|
|
5
|
-
"@
|
|
5
|
+
"@cdklabs/cdk-validator-cfnguard": "^0.0.60",
|
|
6
6
|
"aws-cdk": "^2.166.0",
|
|
7
7
|
"aws-cdk-lib": "^2.166.0",
|
|
8
8
|
"constructs": "^10.4.2",
|
|
@@ -14,19 +14,33 @@ exports[`infra generator > should add required dependencies to package.json > de
|
|
|
14
14
|
exports[`infra generator > should add required dependencies to package.json > dev-dependencies 1`] = `
|
|
15
15
|
{
|
|
16
16
|
"@eslint/js": "^9.8.0",
|
|
17
|
-
"@nx/eslint": "20.
|
|
18
|
-
"@nx/eslint-plugin": "20.
|
|
17
|
+
"@nx/eslint": "20.3.1",
|
|
18
|
+
"@nx/eslint-plugin": "20.3.1",
|
|
19
|
+
"@nx/js": "20.3.1",
|
|
20
|
+
"@nx/vite": "20.3.1",
|
|
21
|
+
"@nx/web": "20.3.1",
|
|
22
|
+
"@swc-node/register": "~1.9.1",
|
|
23
|
+
"@swc/core": "~1.5.7",
|
|
24
|
+
"@swc/helpers": "~0.5.11",
|
|
25
|
+
"@vitest/coverage-v8": "^1.0.4",
|
|
26
|
+
"@vitest/ui": "^1.3.1",
|
|
19
27
|
"eslint": "^9.8.0",
|
|
20
28
|
"eslint-config-prettier": "^9.0.0",
|
|
29
|
+
"eslint-plugin-prettier": "^5.2.2",
|
|
30
|
+
"jsdom": "~22.1.0",
|
|
31
|
+
"prettier": "^3.4.2",
|
|
21
32
|
"tsx": "^4.19.2",
|
|
22
|
-
"typescript
|
|
33
|
+
"typescript": "~5.6.2",
|
|
34
|
+
"typescript-eslint": "^8.13.0",
|
|
35
|
+
"vite": "^5.0.0",
|
|
36
|
+
"vitest": "^1.3.1",
|
|
23
37
|
}
|
|
24
38
|
`;
|
|
25
39
|
|
|
26
40
|
exports[`infra generator > should add required dependencies to package.json > package-json 1`] = `
|
|
27
41
|
{
|
|
28
42
|
"dependencies": {
|
|
29
|
-
"@
|
|
43
|
+
"@cdklabs/cdk-validator-cfnguard": "^0.0.60",
|
|
30
44
|
"aws-cdk": "^2.166.0",
|
|
31
45
|
"aws-cdk-lib": "^2.166.0",
|
|
32
46
|
"constructs": "^10.4.2",
|
|
@@ -35,12 +49,26 @@ exports[`infra generator > should add required dependencies to package.json > pa
|
|
|
35
49
|
},
|
|
36
50
|
"devDependencies": {
|
|
37
51
|
"@eslint/js": "^9.8.0",
|
|
38
|
-
"@nx/eslint": "20.
|
|
39
|
-
"@nx/eslint-plugin": "20.
|
|
52
|
+
"@nx/eslint": "20.3.1",
|
|
53
|
+
"@nx/eslint-plugin": "20.3.1",
|
|
54
|
+
"@nx/js": "20.3.1",
|
|
55
|
+
"@nx/vite": "20.3.1",
|
|
56
|
+
"@nx/web": "20.3.1",
|
|
57
|
+
"@swc-node/register": "~1.9.1",
|
|
58
|
+
"@swc/core": "~1.5.7",
|
|
59
|
+
"@swc/helpers": "~0.5.11",
|
|
60
|
+
"@vitest/coverage-v8": "^1.0.4",
|
|
61
|
+
"@vitest/ui": "^1.3.1",
|
|
40
62
|
"eslint": "^9.8.0",
|
|
41
63
|
"eslint-config-prettier": "^9.0.0",
|
|
64
|
+
"eslint-plugin-prettier": "^5.2.2",
|
|
65
|
+
"jsdom": "~22.1.0",
|
|
66
|
+
"prettier": "^3.4.2",
|
|
42
67
|
"tsx": "^4.19.2",
|
|
43
|
-
"typescript
|
|
68
|
+
"typescript": "~5.6.2",
|
|
69
|
+
"typescript-eslint": "^8.13.0",
|
|
70
|
+
"vite": "^5.0.0",
|
|
71
|
+
"vitest": "^1.3.1",
|
|
44
72
|
},
|
|
45
73
|
"name": "@proj/source",
|
|
46
74
|
"type": "module",
|
|
@@ -122,12 +150,12 @@ exports[`infra generator > should configure project.json with correct targets >
|
|
|
122
150
|
"executor": "@nx/eslint:lint",
|
|
123
151
|
},
|
|
124
152
|
"test": {
|
|
125
|
-
"executor": "@nx/
|
|
153
|
+
"executor": "@nx/vite:test",
|
|
126
154
|
"options": {
|
|
127
|
-
"
|
|
155
|
+
"reportsDirectory": "../../coverage/packages/test",
|
|
128
156
|
},
|
|
129
157
|
"outputs": [
|
|
130
|
-
"{
|
|
158
|
+
"{options.reportsDirectory}",
|
|
131
159
|
],
|
|
132
160
|
},
|
|
133
161
|
},
|
|
@@ -204,43 +232,24 @@ exports[`infra generator > should generate consistent file content across runs >
|
|
|
204
232
|
}
|
|
205
233
|
}
|
|
206
234
|
",
|
|
207
|
-
"src/main.ts": "import {
|
|
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';
|
|
235
|
+
"src/main.ts": "import { App } from 'aws-cdk-lib';
|
|
211
236
|
import { ApplicationStack } from './stacks/application-stack.js';
|
|
237
|
+
import { CfnGuardValidator, RuleSet } from ':proj/common-constructs';
|
|
212
238
|
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
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
|
-
});
|
|
239
|
+
const app = new App({
|
|
240
|
+
policyValidationBeta1: [new CfnGuardValidator(RuleSet.AWS_PROTOTYPING)],
|
|
241
|
+
});
|
|
240
242
|
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
243
|
+
// Use this to deploy your own sandbox environment (assumes your CLI credentials)
|
|
244
|
+
new ApplicationStack(app, 'test-sandbox', {
|
|
245
|
+
env: {
|
|
246
|
+
account: process.env.CDK_DEFAULT_ACCOUNT,
|
|
247
|
+
region: process.env.CDK_DEFAULT_REGION,
|
|
248
|
+
},
|
|
249
|
+
crossRegionReferences: true,
|
|
250
|
+
});
|
|
251
|
+
|
|
252
|
+
app.synth();
|
|
244
253
|
",
|
|
245
254
|
"src/stacks/application-stack.ts": "import * as cdk from 'aws-cdk-lib';
|
|
246
255
|
import { Construct } from 'constructs';
|
|
@@ -342,43 +351,24 @@ exports[`infra generator > should generate files with correct content > cdk-json
|
|
|
342
351
|
`;
|
|
343
352
|
|
|
344
353
|
exports[`infra generator > should generate files with correct content > main-ts 1`] = `
|
|
345
|
-
"import {
|
|
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';
|
|
354
|
+
"import { App } from 'aws-cdk-lib';
|
|
349
355
|
import { ApplicationStack } from './stacks/application-stack.js';
|
|
356
|
+
import { CfnGuardValidator, RuleSet } from ':proj/common-constructs';
|
|
350
357
|
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
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
|
-
});
|
|
358
|
+
const app = new App({
|
|
359
|
+
policyValidationBeta1: [new CfnGuardValidator(RuleSet.AWS_PROTOTYPING)],
|
|
360
|
+
});
|
|
361
|
+
|
|
362
|
+
// Use this to deploy your own sandbox environment (assumes your CLI credentials)
|
|
363
|
+
new ApplicationStack(app, 'test-sandbox', {
|
|
364
|
+
env: {
|
|
365
|
+
account: process.env.CDK_DEFAULT_ACCOUNT,
|
|
366
|
+
region: process.env.CDK_DEFAULT_REGION,
|
|
367
|
+
},
|
|
368
|
+
crossRegionReferences: true,
|
|
369
|
+
});
|
|
378
370
|
|
|
379
|
-
|
|
380
|
-
await graph.report();
|
|
381
|
-
})();
|
|
371
|
+
app.synth();
|
|
382
372
|
"
|
|
383
373
|
`;
|
|
384
374
|
|
|
@@ -473,10 +463,10 @@ exports[`infra generator > should generate files with correct content > project-
|
|
|
473
463
|
"executor": "@nx/eslint:lint"
|
|
474
464
|
},
|
|
475
465
|
"test": {
|
|
476
|
-
"executor": "@nx/
|
|
477
|
-
"outputs": ["{
|
|
466
|
+
"executor": "@nx/vite:test",
|
|
467
|
+
"outputs": ["{options.reportsDirectory}"],
|
|
478
468
|
"options": {
|
|
479
|
-
"
|
|
469
|
+
"reportsDirectory": "../../coverage/packages/test"
|
|
480
470
|
}
|
|
481
471
|
},
|
|
482
472
|
"compile": {
|
|
@@ -499,43 +489,24 @@ exports[`infra generator > should generate files with correct content > project-
|
|
|
499
489
|
}
|
|
500
490
|
}
|
|
501
491
|
",
|
|
502
|
-
"src/main.ts": "import {
|
|
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';
|
|
492
|
+
"src/main.ts": "import { App } from 'aws-cdk-lib';
|
|
506
493
|
import { ApplicationStack } from './stacks/application-stack.js';
|
|
494
|
+
import { CfnGuardValidator, RuleSet } from ':proj/common-constructs';
|
|
507
495
|
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
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
|
-
});
|
|
496
|
+
const app = new App({
|
|
497
|
+
policyValidationBeta1: [new CfnGuardValidator(RuleSet.AWS_PROTOTYPING)],
|
|
498
|
+
});
|
|
535
499
|
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
500
|
+
// Use this to deploy your own sandbox environment (assumes your CLI credentials)
|
|
501
|
+
new ApplicationStack(app, 'test-sandbox', {
|
|
502
|
+
env: {
|
|
503
|
+
account: process.env.CDK_DEFAULT_ACCOUNT,
|
|
504
|
+
region: process.env.CDK_DEFAULT_REGION,
|
|
505
|
+
},
|
|
506
|
+
crossRegionReferences: true,
|
|
507
|
+
});
|
|
508
|
+
|
|
509
|
+
app.synth();
|
|
539
510
|
",
|
|
540
511
|
"src/stacks/application-stack.ts": "import * as cdk from 'aws-cdk-lib';
|
|
541
512
|
import { Construct } from 'constructs';
|
|
@@ -627,43 +598,24 @@ exports[`infra generator > should generate valid CDK application code > cdk-json
|
|
|
627
598
|
`;
|
|
628
599
|
|
|
629
600
|
exports[`infra generator > should generate valid CDK application code > main-ts-content 1`] = `
|
|
630
|
-
"import {
|
|
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';
|
|
601
|
+
"import { App } from 'aws-cdk-lib';
|
|
634
602
|
import { ApplicationStack } from './stacks/application-stack.js';
|
|
603
|
+
import { CfnGuardValidator, RuleSet } from ':proj/common-constructs';
|
|
635
604
|
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
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
|
-
});
|
|
605
|
+
const app = new App({
|
|
606
|
+
policyValidationBeta1: [new CfnGuardValidator(RuleSet.AWS_PROTOTYPING)],
|
|
607
|
+
});
|
|
608
|
+
|
|
609
|
+
// Use this to deploy your own sandbox environment (assumes your CLI credentials)
|
|
610
|
+
new ApplicationStack(app, 'test-sandbox', {
|
|
611
|
+
env: {
|
|
612
|
+
account: process.env.CDK_DEFAULT_ACCOUNT,
|
|
613
|
+
region: process.env.CDK_DEFAULT_REGION,
|
|
614
|
+
},
|
|
615
|
+
crossRegionReferences: true,
|
|
616
|
+
});
|
|
663
617
|
|
|
664
|
-
|
|
665
|
-
await graph.report();
|
|
666
|
-
})();
|
|
618
|
+
app.synth();
|
|
667
619
|
"
|
|
668
620
|
`;
|
|
669
621
|
|
|
@@ -751,43 +703,24 @@ exports[`infra generator > should handle custom project names correctly > custom
|
|
|
751
703
|
}
|
|
752
704
|
}
|
|
753
705
|
",
|
|
754
|
-
"src/main.ts": "import {
|
|
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';
|
|
706
|
+
"src/main.ts": "import { App } from 'aws-cdk-lib';
|
|
758
707
|
import { ApplicationStack } from './stacks/application-stack.js';
|
|
708
|
+
import { CfnGuardValidator, RuleSet } from ':proj/common-constructs';
|
|
759
709
|
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
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
|
-
});
|
|
710
|
+
const app = new App({
|
|
711
|
+
policyValidationBeta1: [new CfnGuardValidator(RuleSet.AWS_PROTOTYPING)],
|
|
712
|
+
});
|
|
713
|
+
|
|
714
|
+
// Use this to deploy your own sandbox environment (assumes your CLI credentials)
|
|
715
|
+
new ApplicationStack(app, 'custom-infra-sandbox', {
|
|
716
|
+
env: {
|
|
717
|
+
account: process.env.CDK_DEFAULT_ACCOUNT,
|
|
718
|
+
region: process.env.CDK_DEFAULT_REGION,
|
|
719
|
+
},
|
|
720
|
+
crossRegionReferences: true,
|
|
721
|
+
});
|
|
787
722
|
|
|
788
|
-
|
|
789
|
-
await graph.report();
|
|
790
|
-
})();
|
|
723
|
+
app.synth();
|
|
791
724
|
",
|
|
792
725
|
"src/stacks/application-stack.ts": "import * as cdk from 'aws-cdk-lib';
|
|
793
726
|
import { Construct } from 'constructs';
|
|
@@ -851,12 +784,12 @@ exports[`infra generator > should handle custom project names correctly > custom
|
|
|
851
784
|
"executor": "@nx/eslint:lint",
|
|
852
785
|
},
|
|
853
786
|
"test": {
|
|
854
|
-
"executor": "@nx/
|
|
787
|
+
"executor": "@nx/vite:test",
|
|
855
788
|
"options": {
|
|
856
|
-
"
|
|
789
|
+
"reportsDirectory": "../../coverage/packages/custom-infra",
|
|
857
790
|
},
|
|
858
791
|
"outputs": [
|
|
859
|
-
"{
|
|
792
|
+
"{options.reportsDirectory}",
|
|
860
793
|
],
|
|
861
794
|
},
|
|
862
795
|
},
|