-
Notifications
You must be signed in to change notification settings - Fork 4.5k
Expand file tree
/
Copy pathrule.ts
More file actions
2983 lines (2894 loc) · 163 KB
/
rule.ts
File metadata and controls
2983 lines (2894 loc) · 163 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
import { createHash } from 'crypto';
import type { Construct } from 'constructs';
import type { ConfigRuleReference, IConfigRuleRef } from './config.generated';
import { CfnConfigRule } from './config.generated';
import * as events from '../../aws-events';
import * as iam from '../../aws-iam';
import type * as lambda from '../../aws-lambda';
import type { IResource } from '../../core';
import { ArnFormat, Lazy, Resource, Stack, ValidationError } from '../../core';
import { addConstructMetadata } from '../../core/lib/metadata-resource';
import { propertyInjectable } from '../../core/lib/prop-injectable';
/**
* Interface representing an AWS Config rule
*/
export interface IRule extends IResource, IConfigRuleRef {
/**
* The name of the rule.
*
* @attribute
*/
readonly configRuleName: string;
/**
* Defines an EventBridge event rule which triggers for rule events. Use
* `rule.addEventPattern(pattern)` to specify a filter.
*/
onEvent(id: string, options?: events.OnEventOptions): events.Rule;
/**
* Defines a EventBridge event rule which triggers for rule compliance events.
*/
onComplianceChange(id: string, options?: events.OnEventOptions): events.Rule;
/**
* Defines a EventBridge event rule which triggers for rule re-evaluation status events.
*/
onReEvaluationStatus(id: string, options?: events.OnEventOptions): events.Rule;
}
/**
* The mode of evaluation for the rule.
*/
export class EvaluationMode {
/**
* Evaluate resources that have already been deployed
*/
public static readonly DETECTIVE = new EvaluationMode(['DETECTIVE']);
/**
* Evaluate resources before they have been deployed
*/
public static readonly PROACTIVE = new EvaluationMode(['PROACTIVE']);
/**
* Evaluate resources that have already been deployed and before they have been deployed
*/
public static readonly DETECTIVE_AND_PROACTIVE = new EvaluationMode(['DETECTIVE', 'PROACTIVE']);
/**
* @param modes The modes of evaluation for the rule
*/
protected constructor(public readonly modes: string[]) {}
}
/**
* A new or imported rule.
*/
abstract class RuleBase extends Resource implements IRule {
public abstract readonly configRuleName: string;
/**
* Defines an EventBridge event rule which triggers for rule events. Use
* `rule.addEventPattern(pattern)` to specify a filter.
*/
public onEvent(id: string, options: events.OnEventOptions = {}) {
const rule = new events.Rule(this, id, options);
rule.addEventPattern({
source: ['aws.config'],
detail: {
configRuleName: [this.configRuleName],
},
});
rule.addTarget(options.target);
return rule;
}
/**
* Defines an EventBridge event rule which triggers for rule compliance events.
*/
public onComplianceChange(id: string, options: events.OnEventOptions = {}): events.Rule {
const rule = this.onEvent(id, options);
rule.addEventPattern({
detailType: ['Config Rules Compliance Change'],
});
return rule;
}
/**
* Defines an EventBridge event rule which triggers for rule re-evaluation status events.
*/
public onReEvaluationStatus(id: string, options: events.OnEventOptions = {}): events.Rule {
const rule = this.onEvent(id, options);
rule.addEventPattern({
detailType: ['Config Rules Re-evaluation Status'],
});
return rule;
}
public get configRuleRef(): ConfigRuleReference {
const self = this;
return {
get configRuleArn(): string { throw new ValidationError('CannotConfigRuleCreatedWithout', 'Cannot get the ARN of this ConfigRule; it has been created without knowledge of its id', self); },
configRuleName: this.configRuleName,
};
}
}
/**
* A new managed or custom rule.
*/
abstract class RuleNew extends RuleBase {
/**
* Imports an existing rule.
*
* @param configRuleName the name of the rule
*/
public static fromConfigRuleName(scope: Construct, id: string, configRuleName: string): IRule {
class Import extends RuleBase {
public readonly configRuleName = configRuleName;
}
return new Import(scope, id);
}
/**
* The arn of the rule.
*/
public abstract readonly configRuleArn: string;
/**
* The id of the rule.
*/
public abstract readonly configRuleId: string;
/**
* The compliance status of the rule.
*/
public abstract readonly configRuleComplianceType: string;
protected ruleScope?: RuleScope;
protected isManaged?: boolean;
protected isCustomWithChanges?: boolean;
public get configRuleRef(): ConfigRuleReference {
return {
configRuleArn: Stack.of(this).formatArn({
service: 'config',
account: this.env.account,
region: this.env.region,
resource: 'config-rule',
resourceName: this.configRuleId,
arnFormat: ArnFormat.SLASH_RESOURCE_NAME,
}),
configRuleName: this.configRuleName,
};
}
}
/**
* Determines which resources trigger an evaluation of an AWS Config rule.
*/
export class RuleScope {
/** restricts scope of changes to a specific resource type or resource identifier */
public static fromResource(resourceType: ResourceType, resourceId?: string) {
return new RuleScope(resourceId, [resourceType]);
}
/** restricts scope of changes to specific resource types */
public static fromResources(resourceTypes: ResourceType[]) {
return new RuleScope(undefined, resourceTypes);
}
/** restricts scope of changes to a specific tag */
public static fromTag(key: string, value?: string) {
return new RuleScope(undefined, undefined, key, value);
}
/** Resource types that will trigger evaluation of a rule */
public readonly resourceTypes?: ResourceType[];
/** ID of the only AWS resource that will trigger evaluation of a rule */
public readonly resourceId?: string;
/** tag key applied to resources that will trigger evaluation of a rule */
public readonly key?: string;
/** tag value applied to resources that will trigger evaluation of a rule */
public readonly value?: string;
private constructor(resourceId?: string, resourceTypes?: ResourceType[], tagKey?: string, tagValue?: string) {
this.resourceTypes = resourceTypes;
this.resourceId = resourceId;
this.key = tagKey;
this.value = tagValue;
}
}
/**
* The maximum frequency at which the AWS Config rule runs evaluations.
*/
export enum MaximumExecutionFrequency {
/**
* 1 hour.
*/
ONE_HOUR = 'One_Hour',
/**
* 3 hours.
*/
THREE_HOURS = 'Three_Hours',
/**
* 6 hours.
*/
SIX_HOURS = 'Six_Hours',
/**
* 12 hours.
*/
TWELVE_HOURS = 'Twelve_Hours',
/**
* 24 hours.
*/
TWENTY_FOUR_HOURS = 'TwentyFour_Hours',
}
/**
* Construction properties for a new rule.
*/
export interface RuleProps {
/**
* A name for the AWS Config rule.
*
* @default - CloudFormation generated name
*/
readonly configRuleName?: string;
/**
* A description about this AWS Config rule.
*
* @default - No description
*/
readonly description?: string;
/**
* Input parameter values that are passed to the AWS Config rule.
*
* @default - No input parameters
*/
readonly inputParameters?: { [key: string]: any };
/**
* The maximum frequency at which the AWS Config rule runs evaluations.
*
* @default MaximumExecutionFrequency.TWENTY_FOUR_HOURS
*/
readonly maximumExecutionFrequency?: MaximumExecutionFrequency;
/**
* Defines which resources trigger an evaluation for an AWS Config rule.
*
* @default - evaluations for the rule are triggered when any resource in the recording group changes.
*/
readonly ruleScope?: RuleScope;
/**
* The modes the AWS Config rule can be evaluated in. The valid values are distinct objects.
*
* @default - Detective evaluation mode only
*/
readonly evaluationModes?: EvaluationMode;
}
/**
* Construction properties for a ManagedRule.
*/
export interface ManagedRuleProps extends RuleProps {
/**
* The identifier of the AWS managed rule.
*
* @see https://docs.aws.amazon.com/config/latest/developerguide/managed-rules-by-aws-config.html
*/
readonly identifier: string;
}
/**
* A new managed rule.
*
* @resource AWS::Config::ConfigRule
*/
@propertyInjectable
export class ManagedRule extends RuleNew {
/** Uniquely identifies this class. */
public static readonly PROPERTY_INJECTION_ID: string = 'aws-cdk-lib.aws-config.ManagedRule';
/** @attribute */
public readonly configRuleName: string;
/** @attribute */
public readonly configRuleArn: string;
/** @attribute */
public readonly configRuleId: string;
/** @attribute */
public readonly configRuleComplianceType: string;
constructor(scope: Construct, id: string, props: ManagedRuleProps) {
super(scope, id, {
physicalName: props.configRuleName,
});
// Enhanced CDK Analytics Telemetry
addConstructMetadata(this, props);
this.ruleScope = props.ruleScope;
const rule = new CfnConfigRule(this, 'Resource', {
configRuleName: this.physicalName,
description: props.description,
inputParameters: props.inputParameters,
maximumExecutionFrequency: props.maximumExecutionFrequency,
scope: Lazy.any({ produce: () => renderScope(this.ruleScope) }), // scope can use values such as stack id (see CloudFormationStackDriftDetectionCheck)
source: {
owner: 'AWS',
sourceIdentifier: props.identifier,
},
evaluationModes: props.evaluationModes?.modes.map((mode) => ({
mode,
})),
});
this.configRuleName = rule.ref;
this.configRuleArn = rule.attrArn;
this.configRuleId = rule.attrConfigRuleId;
this.configRuleComplianceType = rule.attrComplianceType;
this.isManaged = true;
}
}
/**
* The source of the event, such as an AWS service,
* that triggers AWS Config to evaluate your AWS resources.
*/
enum EventSource {
/* from aws.config */
AWS_CONFIG = 'aws.config',
}
/**
* The type of notification that triggers AWS Config to run an evaluation for a rule.
*/
enum MessageType {
/**
* Triggers an evaluation when AWS Config delivers a configuration item as a result of a resource change.
*/
CONFIGURATION_ITEM_CHANGE_NOTIFICATION = 'ConfigurationItemChangeNotification',
/**
* Triggers an evaluation when AWS Config delivers an oversized configuration item.
*/
OVERSIZED_CONFIGURATION_ITEM_CHANGE_NOTIFICATION = 'OversizedConfigurationItemChangeNotification',
/**
* Triggers a periodic evaluation at the frequency specified for MaximumExecutionFrequency.
*/
SCHEDULED_NOTIFICATION = 'ScheduledNotification',
/**
* Triggers a periodic evaluation when AWS Config delivers a configuration snapshot.
*/
CONFIGURATION_SNAPSHOT_DELIVERY_COMPLETED = 'ConfigurationSnapshotDeliveryCompleted',
}
/**
* Construction properties for a CustomRule.
*/
interface SourceDetail {
/**
* The source of the event, such as an AWS service,
* that triggers AWS Config to evaluate your AWS resources.
*
*/
readonly eventSource: EventSource;
/**
* The frequency at which you want AWS Config to run evaluations for a custom rule with a periodic trigger.
*/
readonly maximumExecutionFrequency?: MaximumExecutionFrequency;
/**
* The type of notification that triggers AWS Config to run an evaluation for a rule.
*/
readonly messageType: MessageType;
}
/**
* Construction properties for a CustomRule.
*/
export interface CustomRuleProps extends RuleProps {
/**
* The Lambda function to run.
*/
readonly lambdaFunction: lambda.IFunction;
/**
* Whether to run the rule on configuration changes.
*
* @default false
*/
readonly configurationChanges?: boolean;
/**
* Whether to run the rule on a fixed frequency.
*
* @default false
*/
readonly periodic?: boolean;
}
/**
* A new custom rule.
*
* @resource AWS::Config::ConfigRule
*/
@propertyInjectable
export class CustomRule extends RuleNew {
/** Uniquely identifies this class. */
public static readonly PROPERTY_INJECTION_ID: string = 'aws-cdk-lib.aws-config.CustomRule';
/** @attribute */
public readonly configRuleName: string;
/** @attribute */
public readonly configRuleArn: string;
/** @attribute */
public readonly configRuleId: string;
/** @attribute */
public readonly configRuleComplianceType: string;
constructor(scope: Construct, id: string, props: CustomRuleProps) {
super(scope, id, {
physicalName: props.configRuleName,
});
// Enhanced CDK Analytics Telemetry
addConstructMetadata(this, props);
if (!props.configurationChanges && !props.periodic) {
throw new ValidationError('MustBeLeastTrue', 'At least one of `configurationChanges` or `periodic` must be set to true.', this);
}
const sourceDetails: SourceDetail[] = [];
this.ruleScope = props.ruleScope;
if (props.configurationChanges) {
sourceDetails.push({
eventSource: EventSource.AWS_CONFIG,
messageType: MessageType.CONFIGURATION_ITEM_CHANGE_NOTIFICATION,
});
sourceDetails.push({
eventSource: EventSource.AWS_CONFIG,
messageType: MessageType.OVERSIZED_CONFIGURATION_ITEM_CHANGE_NOTIFICATION,
});
}
if (props.periodic) {
sourceDetails.push({
eventSource: EventSource.AWS_CONFIG,
maximumExecutionFrequency: props.maximumExecutionFrequency,
messageType: MessageType.SCHEDULED_NOTIFICATION,
});
}
const hash = createHash('sha256')
.update(JSON.stringify({
/* eslint-disable-next-line @typescript-eslint/unbound-method *//* REMOVEME: this is a latent bug */
fnName: props.lambdaFunction.functionName.toString,
accountId: Stack.of(this).resolve(this.env.account),
region: Stack.of(this).resolve(this.env.region),
}), 'utf8')
.digest('base64');
const customRulePermissionId: string = `CustomRulePermission${hash}`;
if (!props.lambdaFunction.permissionsNode.tryFindChild(customRulePermissionId)) {
props.lambdaFunction.addPermission(customRulePermissionId, {
principal: new iam.ServicePrincipal('config.amazonaws.com'),
sourceAccount: this.env.account,
});
}
if (props.lambdaFunction.role) {
props.lambdaFunction.role.addManagedPolicy(
iam.ManagedPolicy.fromAwsManagedPolicyName('service-role/AWSConfigRulesExecutionRole'),
);
}
// The lambda permission must be created before the rule
this.node.addDependency(props.lambdaFunction);
const rule = new CfnConfigRule(this, 'Resource', {
configRuleName: this.physicalName,
description: props.description,
inputParameters: props.inputParameters,
maximumExecutionFrequency: props.maximumExecutionFrequency,
scope: Lazy.any({ produce: () => renderScope(this.ruleScope) }), // scope can use values such as stack id (see CloudFormationStackDriftDetectionCheck)
source: {
owner: 'CUSTOM_LAMBDA',
sourceDetails,
sourceIdentifier: props.lambdaFunction.functionArn,
},
evaluationModes: props.evaluationModes?.modes.map((mode) => ({
mode,
})),
});
this.configRuleName = rule.ref;
this.configRuleArn = rule.attrArn;
this.configRuleId = rule.attrConfigRuleId;
this.configRuleComplianceType = rule.attrComplianceType;
if (props.configurationChanges) {
this.isCustomWithChanges = true;
}
}
}
/**
* Construction properties for a CustomPolicy.
*/
export interface CustomPolicyProps extends RuleProps {
/**
* The policy definition containing the logic for your AWS Config Custom Policy rule.
*/
readonly policyText: string;
/**
* The boolean expression for enabling debug logging for your AWS Config Custom Policy rule.
*
* @default false
*/
readonly enableDebugLog?: boolean;
}
/**
* A new custom policy.
*
* @resource AWS::Config::ConfigRule
*/
@propertyInjectable
export class CustomPolicy extends RuleNew {
/**
* Uniquely identifies this class.
*/
public static readonly PROPERTY_INJECTION_ID: string = 'aws-cdk-lib.aws-config.CustomPolicy';
/** @attribute */
public readonly configRuleName: string;
/** @attribute */
public readonly configRuleArn: string;
/** @attribute */
public readonly configRuleId: string;
/** @attribute */
public readonly configRuleComplianceType: string;
constructor(scope: Construct, id: string, props: CustomPolicyProps) {
super(scope, id, {
physicalName: props.configRuleName,
});
// Enhanced CDK Analytics Telemetry
addConstructMetadata(this, props);
if (!props.policyText || [...props.policyText].length === 0) {
throw new ValidationError('PolicyTextCannotEmpty', 'Policy Text cannot be empty.', this);
}
if ([...props.policyText].length > 10000) {
throw new ValidationError('PolicyTextLimitedCharactersLess', 'Policy Text is limited to 10,000 characters or less.', this);
}
const sourceDetails: SourceDetail[] = [];
this.ruleScope = props.ruleScope;
sourceDetails.push({
eventSource: EventSource.AWS_CONFIG,
messageType: MessageType.CONFIGURATION_ITEM_CHANGE_NOTIFICATION,
});
sourceDetails.push({
eventSource: EventSource.AWS_CONFIG,
messageType: MessageType.OVERSIZED_CONFIGURATION_ITEM_CHANGE_NOTIFICATION,
});
const rule = new CfnConfigRule(this, 'Resource', {
configRuleName: this.physicalName,
description: props.description,
inputParameters: props.inputParameters,
scope: Lazy.any({ produce: () => renderScope(this.ruleScope) }), // scope can use values such as stack id (see CloudFormationStackDriftDetectionCheck)
source: {
owner: 'CUSTOM_POLICY',
sourceDetails,
customPolicyDetails: {
enableDebugLogDelivery: props.enableDebugLog,
policyRuntime: 'guard-2.x.x',
policyText: props.policyText,
},
},
evaluationModes: props.evaluationModes?.modes.map((mode) => ({
mode,
})),
});
this.configRuleName = rule.ref;
this.configRuleArn = rule.attrArn;
this.configRuleId = rule.attrConfigRuleId;
this.configRuleComplianceType = rule.attrComplianceType;
this.isCustomWithChanges = true;
}
}
/**
* Managed rules that are supported by AWS Config.
* @see https://docs.aws.amazon.com/config/latest/developerguide/managed-rules-by-aws-config.html
*/
export class ManagedRuleIdentifiers {
/**
* Checks that the inline policies attached to your AWS Identity and Access Management users,
* roles, and groups do not allow blocked actions on all AWS Key Management Service keys.
* @see https://docs.aws.amazon.com/config/latest/developerguide/iam-inline-policy-blocked-kms-actions.html
*/
public static readonly IAM_INLINE_POLICY_BLOCKED_KMS_ACTIONS = 'IAM_INLINE_POLICY_BLOCKED_KMS_ACTIONS';
/**
* Checks that the managed AWS Identity and Access Management policies that you create do not
* allow blocked actions on all AWS AWS KMS keys.
* @see https://docs.aws.amazon.com/config/latest/developerguide/iam-customer-policy-blocked-kms-actions.html
*/
public static readonly IAM_CUSTOMER_POLICY_BLOCKED_KMS_ACTIONS = 'IAM_CUSTOMER_POLICY_BLOCKED_KMS_ACTIONS';
/**
* Checks whether the active access keys are rotated within the number of days specified in maxAccessKeyAge.
* @see https://docs.aws.amazon.com/config/latest/developerguide/access-keys-rotated.html
*/
public static readonly ACCESS_KEYS_ROTATED = 'ACCESS_KEYS_ROTATED';
/**
* Checks whether AWS account is part of AWS Organizations.
* @see https://docs.aws.amazon.com/config/latest/developerguide/account-part-of-organizations.html
*/
public static readonly ACCOUNT_PART_OF_ORGANIZATIONS = 'ACCOUNT_PART_OF_ORGANIZATIONS';
/**
* Checks whether ACM Certificates in your account are marked for expiration within the specified number of days.
* @see https://docs.aws.amazon.com/config/latest/developerguide/acm-certificate-expiration-check.html
*/
public static readonly ACM_CERTIFICATE_EXPIRATION_CHECK = 'ACM_CERTIFICATE_EXPIRATION_CHECK';
/**
* Checks if an Application Load Balancer (ALB) is configured with a user defined desync mitigation mode.
* @see https://docs.aws.amazon.com/config/latest/developerguide/alb-desync-mode-check.html
*/
public static readonly ALB_DESYNC_MODE_CHECK = 'ALB_DESYNC_MODE_CHECK';
/**
* Checks if rule evaluates Application Load Balancers (ALBs) to ensure they are configured to drop http headers.
* @see https://docs.aws.amazon.com/config/latest/developerguide/alb-http-drop-invalid-header-enabled.html
*/
public static readonly ALB_HTTP_DROP_INVALID_HEADER_ENABLED = 'ALB_HTTP_DROP_INVALID_HEADER_ENABLED';
/**
* Checks whether HTTP to HTTPS redirection is configured on all HTTP listeners of Application Load Balancer.
* @see https://docs.aws.amazon.com/config/latest/developerguide/alb-http-to-https-redirection-check.html
*/
public static readonly ALB_HTTP_TO_HTTPS_REDIRECTION_CHECK = 'ALB_HTTP_TO_HTTPS_REDIRECTION_CHECK';
/**
* Checks if Web Application Firewall (WAF) is enabled on Application Load Balancers (ALBs).
* @see https://docs.aws.amazon.com/config/latest/developerguide/alb-waf-enabled.html
*/
public static readonly ALB_WAF_ENABLED = 'ALB_WAF_ENABLED';
/**
* Checks if Amazon API Gateway V2 stages have access logging enabled.
* @see https://docs.aws.amazon.com/config/latest/developerguide/api-gwv2-access-logs-enabled.html
*/
public static readonly API_GWV2_ACCESS_LOGS_ENABLED = 'API_GWV2_ACCESS_LOGS_ENABLED';
/**
* Checks if Amazon API Gatewayv2 API routes have an authorization type set.
* @see https://docs.aws.amazon.com/config/latest/developerguide/api-gwv2-authorization-type-configured.html
*/
public static readonly API_GWV2_AUTHORIZATION_TYPE_CONFIGURED = 'API_GWV2_AUTHORIZATION_TYPE_CONFIGURED';
/**
* Checks if an Amazon API Gateway API stage is using an AWS WAF Web ACL.
* @see https://docs.aws.amazon.com/config/latest/developerguide/api-gw-associated-with-waf.html
*/
public static readonly API_GW_ASSOCIATED_WITH_WAF = 'API_GW_ASSOCIATED_WITH_WAF';
/**
* Checks that all methods in Amazon API Gateway stages have caching enabled and encrypted.
* @see https://docs.aws.amazon.com/config/latest/developerguide/api-gw-cache-enabled-and-encrypted.html
*/
public static readonly API_GW_CACHE_ENABLED_AND_ENCRYPTED = 'API_GW_CACHE_ENABLED_AND_ENCRYPTED';
/**
* Checks that Amazon API Gateway APIs are of the type specified in the rule parameter endpointConfigurationType.
* @see https://docs.aws.amazon.com/config/latest/developerguide/api-gw-endpoint-type-check.html
*/
public static readonly API_GW_ENDPOINT_TYPE_CHECK = 'API_GW_ENDPOINT_TYPE_CHECK';
/**
* Checks that all methods in Amazon API Gateway stage has logging enabled.
* @see https://docs.aws.amazon.com/config/latest/developerguide/api-gw-execution-logging-enabled.html
*/
public static readonly API_GW_EXECUTION_LOGGING_ENABLED = 'API_GW_EXECUTION_LOGGING_ENABLED';
/**
* Checks if a REST API stage uses an Secure Sockets Layer (SSL) certificate.
* @see https://docs.aws.amazon.com/config/latest/developerguide/api-gw-ssl-enabled.html
*/
public static readonly API_GW_SSL_ENABLED = 'API_GW_SSL_ENABLED';
/**
* Checks if AWS X-Ray tracing is enabled on Amazon API Gateway REST APIs.
* @see https://docs.aws.amazon.com/config/latest/developerguide/api-gw-xray-enabled.html
*/
public static readonly API_GW_XRAY_ENABLED = 'API_GW_XRAY_ENABLED';
/**
* Checks whether running instances are using specified AMIs.
* @see https://docs.aws.amazon.com/config/latest/developerguide/approved-amis-by-id.html
*/
public static readonly APPROVED_AMIS_BY_ID = 'APPROVED_AMIS_BY_ID';
/**
* Checks whether running instances are using specified AMIs.
* @see https://docs.aws.amazon.com/config/latest/developerguide/approved-amis-by-tag.html
*/
public static readonly APPROVED_AMIS_BY_TAG = 'APPROVED_AMIS_BY_TAG';
/**
* Checks if a recovery point was created for Amazon Aurora DB clusters.
* @see https://docs.aws.amazon.com/config/latest/developerguide/aurora-last-backup-recovery-point-created.html
*/
public static readonly AURORA_LAST_BACKUP_RECOVERY_POINT_CREATED = 'AURORA_LAST_BACKUP_RECOVERY_POINT_CREATED';
/**
* Checks if an Amazon Aurora MySQL cluster has backtracking enabled.
* @see https://docs.aws.amazon.com/config/latest/developerguide/aurora-mysql-backtracking-enabled.html
*/
public static readonly AURORA_MYSQL_BACKTRACKING_ENABLED = 'AURORA_MYSQL_BACKTRACKING_ENABLED';
/**
* Checks if Amazon Aurora DB clusters are protected by a backup plan.
* @see https://docs.aws.amazon.com/config/latest/developerguide/aurora-resources-protected-by-backup-plan.html
*/
public static readonly AURORA_RESOURCES_PROTECTED_BY_BACKUP_PLAN = 'AURORA_RESOURCES_PROTECTED_BY_BACKUP_PLAN';
/**
* Checks if Capacity Rebalancing is enabled for Amazon EC2 Auto Scaling groups that use multiple instance types.
* @see https://docs.aws.amazon.com/config/latest/developerguide/autoscaling-capacity-rebalancing.html
*/
public static readonly AUTOSCALING_CAPACITY_REBALANCING = 'AUTOSCALING_CAPACITY_REBALANCING';
/**
* Checks whether your Auto Scaling groups that are associated with a load balancer are using
* Elastic Load Balancing health checks.
* @see https://docs.aws.amazon.com/config/latest/developerguide/autoscaling-group-elb-healthcheck-required.html
*/
public static readonly AUTOSCALING_GROUP_ELB_HEALTHCHECK_REQUIRED = 'AUTOSCALING_GROUP_ELB_HEALTHCHECK_REQUIRED';
/**
* Checks whether only IMDSv2 is enabled.
* @see https://docs.aws.amazon.com/config/latest/developerguide/autoscaling-launchconfig-requires-imdsv2.html
*/
public static readonly AUTOSCALING_LAUNCHCONFIG_REQUIRES_IMDSV2 = 'AUTOSCALING_LAUNCHCONFIG_REQUIRES_IMDSV2';
/**
* Checks the number of network hops that the metadata token can travel.
* @see https://docs.aws.amazon.com/config/latest/developerguide/autoscaling-launch-config-hop-limit.html
*/
public static readonly AUTOSCALING_LAUNCH_CONFIG_HOP_LIMIT = 'AUTOSCALING_LAUNCH_CONFIG_HOP_LIMIT';
/**
* Checks if Amazon EC2 Auto Scaling groups have public IP addresses enabled through Launch Configurations.
* @see https://docs.aws.amazon.com/config/latest/developerguide/autoscaling-launch-config-public-ip-disabled.html
*/
public static readonly AUTOSCALING_LAUNCH_CONFIG_PUBLIC_IP_DISABLED = 'AUTOSCALING_LAUNCH_CONFIG_PUBLIC_IP_DISABLED';
/**
* Checks if an Amazon Elastic Compute Cloud (EC2) Auto Scaling group is created from an EC2 launch template.
* @see https://docs.aws.amazon.com/config/latest/developerguide/autoscaling-launch-template.html
*/
public static readonly AUTOSCALING_LAUNCH_TEMPLATE = 'AUTOSCALING_LAUNCH_TEMPLATE';
/**
* Checks if the Auto Scaling group spans multiple Availability Zones.
* @see https://docs.aws.amazon.com/config/latest/developerguide/autoscaling-multiple-az.html
*/
public static readonly AUTOSCALING_MULTIPLE_AZ = 'AUTOSCALING_MULTIPLE_AZ';
/**
* Checks if an Amazon Elastic Compute Cloud (Amazon EC2) Auto Scaling group uses multiple instance types.
* @see https://docs.aws.amazon.com/config/latest/developerguide/autoscaling-multiple-instance-types.html
*/
public static readonly AUTOSCALING_MULTIPLE_INSTANCE_TYPES = 'AUTOSCALING_MULTIPLE_INSTANCE_TYPES';
/**
* Checks if a backup plan has a backup rule that satisfies the required frequency and retention period.
* @see https://docs.aws.amazon.com/config/latest/developerguide/backup-plan-min-frequency-and-min-retention-check.html
*/
public static readonly BACKUP_PLAN_MIN_FREQUENCY_AND_MIN_RETENTION_CHECK = 'BACKUP_PLAN_MIN_FREQUENCY_AND_MIN_RETENTION_CHECK';
/**
* Checks if a recovery point is encrypted.
* @see https://docs.aws.amazon.com/config/latest/developerguide/backup-recovery-point-encrypted.html
*/
public static readonly BACKUP_RECOVERY_POINT_ENCRYPTED = 'BACKUP_RECOVERY_POINT_ENCRYPTED';
/**
* Checks if a backup vault has an attached resource-based policy which prevents deletion of recovery points.
* @see https://docs.aws.amazon.com/config/latest/developerguide/backup-recovery-point-manual-deletion-disabled.html
*/
public static readonly BACKUP_RECOVERY_POINT_MANUAL_DELETION_DISABLED = 'BACKUP_RECOVERY_POINT_MANUAL_DELETION_DISABLED';
/**
* Checks if a recovery point expires no earlier than after the specified period.
* @see https://docs.aws.amazon.com/config/latest/developerguide/backup-recovery-point-minimum-retention-check.html
*/
public static readonly BACKUP_RECOVERY_POINT_MINIMUM_RETENTION_CHECK = 'BACKUP_RECOVERY_POINT_MINIMUM_RETENTION_CHECK';
/**
* Checks if an AWS Elastic Beanstalk environment is configured for enhanced health reporting.
* @see https://docs.aws.amazon.com/config/latest/developerguide/beanstalk-enhanced-health-reporting-enabled.html
*/
public static readonly BEANSTALK_ENHANCED_HEALTH_REPORTING_ENABLED = 'BEANSTALK_ENHANCED_HEALTH_REPORTING_ENABLED';
/**
* Checks if Classic Load Balancers (CLB) are configured with a user defined Desync mitigation mode.
* @see https://docs.aws.amazon.com/config/latest/developerguide/clb-desync-mode-check.html
*/
public static readonly CLB_DESYNC_MODE_CHECK = 'CLB_DESYNC_MODE_CHECK';
/**
* Checks if a Classic Load Balancer spans multiple Availability Zones (AZs).
* @see https://docs.aws.amazon.com/config/latest/developerguide/clb-multiple-az.html
*/
public static readonly CLB_MULTIPLE_AZ = 'CLB_MULTIPLE_AZ';
/**
* Checks whether an AWS CloudFormation stack's actual configuration differs, or has drifted,
* from its expected configuration.
* @see https://docs.aws.amazon.com/config/latest/developerguide/cloudformation-stack-drift-detection-check.html
*/
public static readonly CLOUDFORMATION_STACK_DRIFT_DETECTION_CHECK = 'CLOUDFORMATION_STACK_DRIFT_DETECTION_CHECK';
/**
* Checks whether your CloudFormation stacks are sending event notifications to an SNS topic.
* @see https://docs.aws.amazon.com/config/latest/developerguide/cloudformation-stack-notification-check.html
*/
public static readonly CLOUDFORMATION_STACK_NOTIFICATION_CHECK = 'CLOUDFORMATION_STACK_NOTIFICATION_CHECK';
/**
* Checks if Amazon CloudFront distributions are configured to capture information from
* Amazon Simple Storage Service (Amazon S3) server access logs.
* @see https://docs.aws.amazon.com/config/latest/developerguide/cloudfront-accesslogs-enabled.html
*/
public static readonly CLOUDFRONT_ACCESSLOGS_ENABLED = 'CLOUDFRONT_ACCESSLOGS_ENABLED';
/**
* Checks if Amazon CloudFront distributions are associated with either WAF or WAFv2 web access control lists (ACLs).
* @see https://docs.aws.amazon.com/config/latest/developerguide/cloudfront-associated-with-waf.html
*/
public static readonly CLOUDFRONT_ASSOCIATED_WITH_WAF = 'CLOUDFRONT_ASSOCIATED_WITH_WAF';
/**
* Checks if the certificate associated with an Amazon CloudFront distribution is the default Secure Sockets Layer (SSL) certificate.
* @see https://docs.aws.amazon.com/config/latest/developerguide/cloudfront-custom-ssl-certificate.html
*/
public static readonly CLOUDFRONT_CUSTOM_SSL_CERTIFICATE = 'CLOUDFRONT_CUSTOM_SSL_CERTIFICATE';
/**
* Checks if an Amazon CloudFront distribution is configured to return a specific object that is the default root object.
* @see https://docs.aws.amazon.com/config/latest/developerguide/cloudfront-default-root-object-configured.html
*/
public static readonly CLOUDFRONT_DEFAULT_ROOT_OBJECT_CONFIGURED = 'CLOUDFRONT_DEFAULT_ROOT_OBJECT_CONFIGURED';
/**
* Checks if CloudFront distributions are using deprecated SSL protocols for HTTPS communication between
* CloudFront edge locations and custom origins.
* @see https://docs.aws.amazon.com/config/latest/developerguide/cloudfront-no-deprecated-ssl-protocols.html
*/
public static readonly CLOUDFRONT_NO_DEPRECATED_SSL_PROTOCOLS = 'CLOUDFRONT_NO_DEPRECATED_SSL_PROTOCOLS';
/**
* Checks that Amazon CloudFront distribution with Amazon S3 Origin type has Origin Access Identity (OAI) configured.
* @see https://docs.aws.amazon.com/config/latest/developerguide/cloudfront-origin-access-identity-enabled.html
*/
public static readonly CLOUDFRONT_ORIGIN_ACCESS_IDENTITY_ENABLED = 'CLOUDFRONT_ORIGIN_ACCESS_IDENTITY_ENABLED';
/**
* Checks whether an origin group is configured for the distribution of at least 2 origins in the
* origin group for Amazon CloudFront.
* @see https://docs.aws.amazon.com/config/latest/developerguide/cloudfront-origin-failover-enabled.html
*/
public static readonly CLOUDFRONT_ORIGIN_FAILOVER_ENABLED = 'CLOUDFRONT_ORIGIN_FAILOVER_ENABLED';
/**
* Checks if Amazon CloudFront distributions are using a minimum security policy and cipher suite of TLSv1.2 or
* greater for viewer connections.
* @see https://docs.aws.amazon.com/config/latest/developerguide/cloudfront-security-policy-check.html
*/
public static readonly CLOUDFRONT_SECURITY_POLICY_CHECK = 'CLOUDFRONT_SECURITY_POLICY_CHECK';
/**
* Checks if Amazon CloudFront distributions are using a custom SSL certificate and are configured
* to use SNI to serve HTTPS requests.
* @see https://docs.aws.amazon.com/config/latest/developerguide/cloudfront-sni-enabled.html
*/
public static readonly CLOUDFRONT_SNI_ENABLED = 'CLOUDFRONT_SNI_ENABLED';
/**
* Checks if Amazon CloudFront distributions are encrypting traffic to custom origins.
* @see https://docs.aws.amazon.com/config/latest/developerguide/cloudfront-traffic-to-origin-encrypted.html
*/
public static readonly CLOUDFRONT_TRAFFIC_TO_ORIGIN_ENCRYPTED = 'CLOUDFRONT_TRAFFIC_TO_ORIGIN_ENCRYPTED';
/**
* Checks whether your Amazon CloudFront distributions use HTTPS (directly or via a redirection).
* @see https://docs.aws.amazon.com/config/latest/developerguide/cloudfront-viewer-policy-https.html
*/
public static readonly CLOUDFRONT_VIEWER_POLICY_HTTPS = 'CLOUDFRONT_VIEWER_POLICY_HTTPS';
/**
* Checks whether AWS CloudTrail trails are configured to send logs to Amazon CloudWatch Logs.
* @see https://docs.aws.amazon.com/config/latest/developerguide/cloud-trail-cloud-watch-logs-enabled.html
*/
public static readonly CLOUD_TRAIL_CLOUD_WATCH_LOGS_ENABLED = 'CLOUD_TRAIL_CLOUD_WATCH_LOGS_ENABLED';
/**
* Checks whether AWS CloudTrail is enabled in your AWS account.
* @see https://docs.aws.amazon.com/config/latest/developerguide/cloudtrail-enabled.html
*/
public static readonly CLOUD_TRAIL_ENABLED = 'CLOUD_TRAIL_ENABLED';
/**
* Checks whether AWS CloudTrail is configured to use the server side encryption (SSE)
* AWS Key Management Service (AWS KMS) customer master key (CMK) encryption.
* @see https://docs.aws.amazon.com/config/latest/developerguide/cloud-trail-encryption-enabled.html
*/
public static readonly CLOUD_TRAIL_ENCRYPTION_ENABLED = 'CLOUD_TRAIL_ENCRYPTION_ENABLED';
/**
* Checks whether AWS CloudTrail creates a signed digest file with logs.
* @see https://docs.aws.amazon.com/config/latest/developerguide/cloud-trail-log-file-validation-enabled.html
*/
public static readonly CLOUD_TRAIL_LOG_FILE_VALIDATION_ENABLED = 'CLOUD_TRAIL_LOG_FILE_VALIDATION_ENABLED';
/**
* Checks whether at least one AWS CloudTrail trail is logging Amazon S3 data events for all S3 buckets.
* @see https://docs.aws.amazon.com/config/latest/developerguide/cloudtrail-s3-dataevents-enabled.html
*/
public static readonly CLOUDTRAIL_S3_DATAEVENTS_ENABLED = 'CLOUDTRAIL_S3_DATAEVENTS_ENABLED';
/**
* Checks that there is at least one AWS CloudTrail trail defined with security best practices.
* @see https://docs.aws.amazon.com/config/latest/developerguide/cloudtrail-security-trail-enabled.html
*/
public static readonly CLOUDTRAIL_SECURITY_TRAIL_ENABLED = 'CLOUDTRAIL_SECURITY_TRAIL_ENABLED';
/**
* Checks whether CloudWatch alarms have at least one alarm action, one INSUFFICIENT_DATA action,
* or one OK action enabled.
* @see https://docs.aws.amazon.com/config/latest/developerguide/cloudwatch-alarm-action-check.html
*/
public static readonly CLOUDWATCH_ALARM_ACTION_CHECK = 'CLOUDWATCH_ALARM_ACTION_CHECK';
/**
* Checks if Amazon CloudWatch alarms actions are in enabled state.
* @see https://docs.aws.amazon.com/config/latest/developerguide/cloudwatch-alarm-action-enabled-check.html
*/
public static readonly CLOUDWATCH_ALARM_ACTION_ENABLED_CHECK = 'CLOUDWATCH_ALARM_ACTION_ENABLED_CHECK';
/**
* Checks whether the specified resource type has a CloudWatch alarm for the specified metric.
* @see https://docs.aws.amazon.com/config/latest/developerguide/cloudwatch-alarm-resource-check.html
*/
public static readonly CLOUDWATCH_ALARM_RESOURCE_CHECK = 'CLOUDWATCH_ALARM_RESOURCE_CHECK';
/**
* Checks whether CloudWatch alarms with the given metric name have the specified settings.
* @see https://docs.aws.amazon.com/config/latest/developerguide/cloudwatch-alarm-settings-check.html
*/
public static readonly CLOUDWATCH_ALARM_SETTINGS_CHECK = 'CLOUDWATCH_ALARM_SETTINGS_CHECK';
/**
* Checks whether a log group in Amazon CloudWatch Logs is encrypted with
* a AWS Key Management Service (KMS) managed Customer Master Keys (CMK).
* @see https://docs.aws.amazon.com/config/latest/developerguide/cloudwatch-log-group-encrypted.html
*/
public static readonly CLOUDWATCH_LOG_GROUP_ENCRYPTED = 'CLOUDWATCH_LOG_GROUP_ENCRYPTED';
/**
* Checks that key rotation is enabled for each key and matches to the key ID of the
* customer created customer master key (CMK).
* @see https://docs.aws.amazon.com/config/latest/developerguide/cmk-backing-key-rotation-enabled.html
*/
public static readonly CMK_BACKING_KEY_ROTATION_ENABLED = 'CMK_BACKING_KEY_ROTATION_ENABLED';
/**
* Checks if an AWS CodeBuild project has encryption enabled for all of its artifacts.
* @see https://docs.aws.amazon.com/config/latest/developerguide/codebuild-project-artifact-encryption.html
*/
public static readonly CODEBUILD_PROJECT_ARTIFACT_ENCRYPTION = 'CODEBUILD_PROJECT_ARTIFACT_ENCRYPTION';
/**
* Checks if an AWS CodeBuild project environment has privileged mode enabled.
* @see https://docs.aws.amazon.com/config/latest/developerguide/codebuild-project-environment-privileged-check.html
*/
public static readonly CODEBUILD_PROJECT_ENVIRONMENT_PRIVILEGED_CHECK = 'CODEBUILD_PROJECT_ENVIRONMENT_PRIVILEGED_CHECK';
/**
* Checks whether the project contains environment variables AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY.
* @see https://docs.aws.amazon.com/config/latest/developerguide/codebuild-project-envvar-awscred-check.html
*/
public static readonly CODEBUILD_PROJECT_ENVVAR_AWSCRED_CHECK = 'CODEBUILD_PROJECT_ENVVAR_AWSCRED_CHECK';
/**
* Checks if an AWS CodeBuild project environment has at least one log option enabled.
* @see https://docs.aws.amazon.com/config/latest/developerguide/codebuild-project-logging-enabled.html
*/
public static readonly CODEBUILD_PROJECT_LOGGING_ENABLED = 'CODEBUILD_PROJECT_LOGGING_ENABLED';
/**
* Checks if a AWS CodeBuild project configured with Amazon S3 Logs has encryption enabled for its logs.
* @see https://docs.aws.amazon.com/config/latest/developerguide/codebuild-project-s3-logs-encrypted.html
*/
public static readonly CODEBUILD_PROJECT_S3_LOGS_ENCRYPTED = 'CODEBUILD_PROJECT_S3_LOGS_ENCRYPTED';
/**
* Checks whether the GitHub or Bitbucket source repository URL contains either personal access tokens
* or user name and password.
* @see https://docs.aws.amazon.com/config/latest/developerguide/codebuild-project-source-repo-url-check.html
*/
public static readonly CODEBUILD_PROJECT_SOURCE_REPO_URL_CHECK = 'CODEBUILD_PROJECT_SOURCE_REPO_URL_CHECK';
/**
* Checks if the deployment group is configured with automatic deployment rollback and
* deployment monitoring with alarms attached.
* @see https://docs.aws.amazon.com/config/latest/developerguide/codedeploy-auto-rollback-monitor-enabled.html
*/
public static readonly CODEDEPLOY_AUTO_ROLLBACK_MONITOR_ENABLED = 'CODEDEPLOY_AUTO_ROLLBACK_MONITOR_ENABLED';
/**
* Checks if the deployment group for EC2/On-Premises Compute Platform is configured with
* a minimum healthy hosts fleet percentage or host count greater than or equal to the input threshold.
* @see https://docs.aws.amazon.com/config/latest/developerguide/codedeploy-ec2-minimum-healthy-hosts-configured.html
*/
public static readonly CODEDEPLOY_EC2_MINIMUM_HEALTHY_HOSTS_CONFIGURED = 'CODEDEPLOY_EC2_MINIMUM_HEALTHY_HOSTS_CONFIGURED';
/**
* Checks if the deployment group for Lambda Compute Platform is not using the default deployment configuration.
* @see https://docs.aws.amazon.com/config/latest/developerguide/codedeploy-lambda-allatonce-traffic-shift-disabled.html
*/