@@ -27,7 +27,7 @@ According to the kind of project you are developing:
27
27
28
28
You can use a classic import to get access to each service namespaces:
29
29
30
- ``` ts
30
+ ``` ts nofixture
31
31
import { Stack , App , aws_s3 as s3 } from ' aws-cdk-lib' ;
32
32
33
33
const app = new App ();
@@ -40,7 +40,7 @@ new s3.Bucket(stack, 'TestBucket');
40
40
41
41
Alternatively, you can use "barrel" imports:
42
42
43
- ``` ts
43
+ ``` ts nofixture
44
44
import { App , Stack } from ' aws-cdk-lib' ;
45
45
import { Bucket } from ' aws-cdk-lib/aws-s3' ;
46
46
@@ -684,13 +684,13 @@ exports.handler = async (e) => {
684
684
` sum.ts ` :
685
685
686
686
``` ts nofixture
687
+ import { Construct } from ' constructs' ;
687
688
import {
688
- Construct ,
689
689
CustomResource ,
690
690
CustomResourceProvider ,
691
691
CustomResourceProviderRuntime ,
692
692
Token ,
693
- } from ' @ aws-cdk/core ' ;
693
+ } from ' aws-cdk-lib ' ;
694
694
695
695
export interface SumProps {
696
696
readonly lhs: number ;
@@ -911,7 +911,7 @@ a property of the creationPolicy on the resource options. Setting it to true wil
911
911
resources that depend on the fleet resource.
912
912
913
913
``` ts
914
- const fleet = new CfnFleet (stack , ' Fleet' , {
914
+ const fleet = new appstream . CfnFleet (this , ' Fleet' , {
915
915
instanceType: ' stream.standard.small' ,
916
916
name: ' Fleet' ,
917
917
computeCapacity: {
@@ -930,14 +930,18 @@ The properties passed to the level 2 constructs `AutoScalingGroup` and `Instance
930
930
931
931
The CfnWaitCondition resource from the ` aws-cloudformation ` module suppports the ` resourceSignal ` .
932
932
The format of the timeout is ` PT#H#M#S ` . In the example below AWS Cloudformation will wait for
933
- 3 success signals to occur within 15 minutes before the status of the resource will be set to
933
+ 3 success signals to occur within 15 minutes before the status of the resource will be set to
934
934
` CREATE_COMPLETE ` .
935
935
936
936
``` ts
937
- resource .cfnOptions .resourceSignal = {
938
- count: 3 ,
939
- timeout: ' PR15M' ,
940
- }
937
+ declare const resource: CfnResource ;
938
+
939
+ resource .cfnOptions .creationPolicy = {
940
+ resourceSignal: {
941
+ count: 3 ,
942
+ timeout: ' PR15M' ,
943
+ }
944
+ };
941
945
```
942
946
943
947
[ creation-policy ] : https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-attribute-creationpolicy.html
@@ -1290,8 +1294,6 @@ to all roles within a specific construct scope. The most common use case would
1290
1294
be to apply a permissions boundary at the `Stage` level.
1291
1295
1292
1296
` ` ` ts
1293
- declare const app: App;
1294
-
1295
1297
const prodStage = new Stage(app, 'ProdStage', {
1296
1298
permissionsBoundary: PermissionsBoundary.fromName('cdk-${Qualifier}-PermissionsBoundary'),
1297
1299
});
@@ -1323,19 +1325,21 @@ will be printed to the console or to a file (see below).
1323
1325
To use one or more validation plugins in your application, use the
1324
1326
`policyValidationBeta1` property of `Stage` :
1325
1327
1326
- ` ` ` ts
1328
+ ` ` ` ts fixture=validation-plugin
1327
1329
// globally for the entire app (an app is a stage)
1328
1330
const app = new App({
1329
1331
policyValidationBeta1: [
1330
- // These hypothetical classes implement IValidationPlugin :
1331
- new ThirdPartyPluginX(),
1332
+ // These hypothetical classes implement IPolicyValidationPluginBeta1 :
1333
+ new ThirdPartyPluginX(),
1332
1334
new ThirdPartyPluginY(),
1333
1335
],
1334
1336
});
1335
1337
1336
1338
// only apply to a particular stage
1337
1339
const prodStage = new Stage(app, 'ProdStage', {
1338
- policyValidationBeta1: [...],
1340
+ policyValidationBeta1: [
1341
+ new ThirdPartyPluginX(),
1342
+ ],
1339
1343
});
1340
1344
` ` `
1341
1345
@@ -1351,12 +1355,12 @@ validation.
1351
1355
> secure to use.
1352
1356
1353
1357
By default, the report will be printed in a human readable format. If you want a
1354
- report in JSON format, enable it using the `@aws-cdk/core:validationReportJson`
1358
+ report in JSON format, enable it using the `@aws-cdk/core:validationReportJson`
1355
1359
context passing it directly to the application :
1356
1360
1357
1361
` ` ` ts
1358
- const app = new App({
1359
- context: { '@aws-cdk/core:validationReportJson': true },
1362
+ const app = new App({
1363
+ context: { '@aws-cdk/core:validationReportJson': true },
1360
1364
});
1361
1365
` ` `
1362
1366
@@ -1372,35 +1376,39 @@ the standard output.
1372
1376
# ## For plugin authors
1373
1377
1374
1378
The communication protocol between the CDK core module and your policy tool is
1375
- defined by the `IValidationPluginBeta1 ` interface. To create a new plugin you must
1379
+ defined by the `IPolicyValidationPluginBeta1 ` interface. To create a new plugin you must
1376
1380
write a class that implements this interface. There are two things you need to
1377
1381
implement : the plugin name (by overriding the `name` property), and the
1378
1382
` validate()` method.
1379
1383
1380
- The framework will call `validate()`, passing an `IValidationContextBeta1 ` object.
1384
+ The framework will call `validate()`, passing an `IPolicyValidationContextBeta1 ` object.
1381
1385
The location of the templates to be validated is given by `templatePaths`. The
1382
- plugin should return an instance of `ValidationPluginReportBeta1 `. This object
1386
+ plugin should return an instance of `PolicyValidationPluginReportBeta1 `. This object
1383
1387
represents the report that the user wil receive at the end of the synthesis.
1384
1388
1385
- ` ` ` ts
1386
- validate(context: ValidationContextBeta1): ValidationReportBeta1 {
1387
- // First read the templates using context.templatePaths...
1388
-
1389
- // ...then perform the validation, and then compose and return the report.
1390
- // Using hard-coded values here for better clarity:
1391
- return {
1392
- success: false,
1393
- violations: [{
1394
- ruleName: 'CKV_AWS_117',
1395
- recommendation: 'Ensure that AWS Lambda function is configured inside a VPC',
1396
- fix: 'https://docs.bridgecrew.io/docs/ensure-that-aws-lambda-function-is-configured-inside-a-vpc-1',
1397
- violatingResources: [{
1398
- resourceName: 'MyFunction3BAA72D1',
1399
- templatePath: '/home/johndoe/myapp/cdk.out/MyService.template.json',
1400
- locations: 'Properties/VpcConfig',
1389
+ ` ` ` ts fixture=validation-plugin
1390
+ class MyPlugin implements IPolicyValidationPluginBeta1 {
1391
+ public readonly name = 'MyPlugin';
1392
+
1393
+ public validate(context: IPolicyValidationContextBeta1): PolicyValidationPluginReportBeta1 {
1394
+ // First read the templates using context.templatePaths...
1395
+
1396
+ // ...then perform the validation, and then compose and return the report.
1397
+ // Using hard-coded values here for better clarity:
1398
+ return {
1399
+ success: false,
1400
+ violations: [{
1401
+ ruleName: 'CKV_AWS_117',
1402
+ description: 'Ensure that AWS Lambda function is configured inside a VPC',
1403
+ fix: 'https://docs.bridgecrew.io/docs/ensure-that-aws-lambda-function-is-configured-inside-a-vpc-1',
1404
+ violatingResources: [{
1405
+ resourceLogicalId: 'MyFunction3BAA72D1',
1406
+ templatePath: '/home/johndoe/myapp/cdk.out/MyService.template.json',
1407
+ locations: ['Properties/VpcConfig'],
1408
+ }],
1401
1409
}],
1402
- }],
1403
- };
1410
+ };
1411
+ }
1404
1412
}
1405
1413
` ` `
1406
1414
0 commit comments