@@ -11,9 +11,9 @@ import * as ec2 from 'aws-cdk-lib/aws-ec2';
11
11
import * as events from 'aws-cdk-lib/aws-events' ;
12
12
import * as iam from 'aws-cdk-lib/aws-iam' ;
13
13
import * as s3 from 'aws-cdk-lib/aws-s3' ;
14
- import * as core from 'aws-cdk-lib/core' ;
15
14
import { Construct } from 'constructs' ;
16
- // for files that are part of this package, we do import individual classes or functions
15
+ // for files that are part of this package or part of core, we do import individual classes or functions
16
+ import { CfnWaitCondition , CfnWaitConditionHandle , Fn , IResource , RemovalPolicy , Resource , Stack , Token } from 'aws-cdk-lib/core' ;
17
17
import { exampleResourceArnComponents } from './private/example-resource-common' ;
18
18
19
19
/**
@@ -58,7 +58,7 @@ import { exampleResourceArnComponents } from './private/example-resource-common'
58
58
*/
59
59
export interface IExampleResource extends
60
60
// all L2 interfaces need to extend IResource
61
- core . IResource ,
61
+ IResource ,
62
62
63
63
// Only for resources that have an associated IAM Role.
64
64
// Allows this resource to be the target in calls like bucket.grantRead(exampleResource).
@@ -149,7 +149,7 @@ export interface IExampleResource extends
149
149
*
150
150
* Notice that the class is not exported - it's not part of the public API of this module!
151
151
*/
152
- abstract class ExampleResourceBase extends core . Resource implements IExampleResource {
152
+ abstract class ExampleResourceBase extends Resource implements IExampleResource {
153
153
// these stay abstract at this level
154
154
public abstract readonly exampleResourceArn : string ;
155
155
public abstract readonly exampleResourceName : string ;
@@ -319,7 +319,7 @@ export interface ExampleResourceProps {
319
319
*
320
320
* @default RemovalPolicy.RETAIN
321
321
*/
322
- readonly removalPolicy ?: core . RemovalPolicy ;
322
+ readonly removalPolicy ?: RemovalPolicy ;
323
323
}
324
324
325
325
/**
@@ -364,7 +364,7 @@ export class ExampleResource extends ExampleResourceBase {
364
364
// using the Stack.formatArn helper method from the core library.
365
365
// We have to know the ARN components of ExampleResource in a few places, so,
366
366
// to avoid duplication, extract that into a module-private function
367
- public readonly exampleResourceArn = core . Stack . of ( scope )
367
+ public readonly exampleResourceArn = Stack . of ( scope )
368
368
. formatArn ( exampleResourceArnComponents ( exampleResourceName ) ) ;
369
369
}
370
370
@@ -382,8 +382,8 @@ export class ExampleResource extends ExampleResourceBase {
382
382
383
383
/**
384
384
* The constructor of a construct has always 3 arguments:
385
- * the parent Construct, the string identifier,
386
- * locally unique within the scope of the parent,
385
+ * the parent Construct, the string identifier
386
+ * ( locally unique within the scope of the parent) ,
387
387
* and a properties struct.
388
388
*
389
389
* If the props only have optional properties, like in our case,
@@ -412,7 +412,7 @@ export class ExampleResource extends ExampleResourceBase {
412
412
// so, we need to use the Token.isUnresolved() method from the core library
413
413
// to skip validation in that case.
414
414
if ( props . waitConditionHandleName !== undefined &&
415
- ! core . Token . isUnresolved ( props . waitConditionHandleName ) &&
415
+ ! Token . isUnresolved ( props . waitConditionHandleName ) &&
416
416
! / ^ [ _ a - z A - Z ] + $ / . test ( props . waitConditionHandleName ) ) {
417
417
throw new Error ( 'waitConditionHandleName must be non-empty and contain only letters and underscores, ' +
418
418
`got: '${ props . waitConditionHandleName } '` ) ;
@@ -435,12 +435,12 @@ export class ExampleResource extends ExampleResourceBase {
435
435
// This guarantees that they get scoped correctly,
436
436
// and the CDK will make sure their locally-unique identifiers
437
437
// are globally unique, which makes your L2 compose.
438
- const waitConditionHandle = new core . CfnWaitConditionHandle ( this , 'WaitConditionHandle' ) ;
438
+ const waitConditionHandle = new CfnWaitConditionHandle ( this , 'WaitConditionHandle' ) ;
439
439
440
440
// The 'main' L1 you create should always have the logical ID 'Resource'.
441
441
// This is important, so that the ConstructNode.defaultChild method works correctly.
442
442
// The local variable representing the L1 is often called 'resource' as well.
443
- const resource = new core . CfnWaitCondition ( this , 'Resource' , {
443
+ const resource = new CfnWaitCondition ( this , 'Resource' , {
444
444
count : 0 ,
445
445
handle : waitConditionHandle . ref ,
446
446
timeout : '10' ,
@@ -460,7 +460,7 @@ export class ExampleResource extends ExampleResourceBase {
460
460
// and the ARN for your resource is of the form 'arn:aws:<service>:<region>:<account>:resource/physical-name',
461
461
// which is quite common,
462
462
// you can use Fn::Select and Fn::Split to take out the part after the '/' from the ARN:
463
- core . Fn . select ( 1 , core . Fn . split ( '/' , resource . ref ) ) ,
463
+ Fn . select ( 1 , Fn . split ( '/' , resource . ref ) ) ,
464
464
) ;
465
465
this . exampleResourceArn = this . getResourceArnAttribute (
466
466
// A lot of the L1 classes have an 'attrArn' property -
@@ -469,7 +469,7 @@ export class ExampleResource extends ExampleResourceBase {
469
469
// you can often formulate the ARN yourself,
470
470
// using the Stack.formatArn helper function.
471
471
// Here, we assume resource.ref returns the physical name of the resource.
472
- core . Stack . of ( this ) . formatArn ( exampleResourceArnComponents ( resource . ref ) ) ,
472
+ Stack . of ( this ) . formatArn ( exampleResourceArnComponents ( resource . ref ) ) ,
473
473
// always use the protected physicalName property for this second argument
474
474
exampleResourceArnComponents ( this . physicalName ) ) ;
475
475
@@ -505,7 +505,7 @@ export class ExampleResource extends ExampleResourceBase {
505
505
// this is how you apply the removal policy
506
506
resource . applyRemovalPolicy ( props . removalPolicy , {
507
507
// this is the default to apply if props.removalPolicy is undefined
508
- default : core . RemovalPolicy . RETAIN ,
508
+ default : RemovalPolicy . RETAIN ,
509
509
} ) ;
510
510
}
511
511
}
0 commit comments