-
Notifications
You must be signed in to change notification settings - Fork 0
/
amazon-inspector-lab-env.yaml
1014 lines (941 loc) · 30.8 KB
/
amazon-inspector-lab-env.yaml
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
# InspectorDemoEnv.yaml
#
# This CloudFormation template does the following:
#
# (1) creates a VPC with a single public subnet
# (2) launches an Amazon EC2 instance for each Amazon Linux/Windows AMI
# that supports Amazon Inspector
# (3) Creates an Inspector resource group, target, and assessment
# template for each of these instances based on the available rules packages
# for the OS at the time this template was developed. This will need to
# be manually updated.
#
# This CloudFormation template does *not* do the following:
#
# (1) Run the Inspector assessments
#
---
AWSTemplateFormatVersion: '2010-09-09'
Description: AWS Inspector Demo
# Note the use of the AWS-specific parameter type.
#
# See:
#
# https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/parameters-section-structure.html
Metadata:
AWS::CloudFormation::Interface:
ParameterGroups:
- Label:
default: "General Parameters"
Parameters:
- AzName
- InstanceKeyPair
- TargetInstanceType
- ProjectTag
- SgAdminCidr
- Label:
default: "Choose instances to create"
Parameters:
- CreateAmazonLinux
- CreateAmazonLinux2
- CreateWindows2008R2
- CreateWindows2012
- CreateWindows2012R2
- CreateWindows2016
- Label:
default: "Lastest AMI ID SSM filter (you should normally accept the default)"
Parameters:
- AmazonLinuxAmiId
- AmazonLinux2AmiId
- Windows2008R2AmiId
- Windows2012AmiId
- Windows2012R2AmiId
- Windows2016AmiId
Parameters:
AzName:
Type: AWS::EC2::AvailabilityZone::Name
Description: Subnet Availability Zone
InstanceKeyPair:
Type: AWS::EC2::KeyPair::KeyName
TargetInstanceType:
Type: String
Default: t3.micro
Description: Instance type for targets
AllowedValues:
- t2.nano
- t2.micro
- t2.small
- t2.medium
- t2.large
- t2.xlarge
- t2.2xlarge
- t3.nano
- t3.micro
- t3.small
- t3.medium
- t3.large
- t3.xlarge
- t3.2xlarge
- m4.large
- m4.xlarge
- m4.2xlarge
- m4.4xlarge
- m4.10xlarge
- m4.16xlarge
- m5.large
- m5.xlarge
- m5.2xlarge
- m5.4xlarge
- m5.12xlarge
- m5.24xlarge
- m5d.large
- m5d.xlarge
- m5d.2xlarge
- m5d.4xlarge
- m5d.12xlarge
- m5d.24xlarge
- c4.large
- c4.xlarge
- c4.2xlarge
- c4.4xlarge
- c4.8xlarge
- c5.large
- c5.xlarge
- c5.2xlarge
- c5.4xlarge
- c5.9xlarge
- c5.18xlarge
- c5d.xlarge
- c5d.2xlarge
- c5d.4xlarge
- c5d.9xlarge
- c5d.18xlarge
- r4.large
- r4.xlarge
- r4.2xlarge
- r4.4xlarge
- r4.8xlarge
- r4.16xlarge
- r5.large
- r5.xlarge
- r5.2xlarge
- r5.4xlarge
- r5.12xlarge
- r5.24xlarge
- r5d.large
- r5d.xlarge
- r5d.2xlarge
- r5d.4xlarge
- r5d.12xlarge
- r5d.24xlarge
- x1.16xlarge
- x1.32xlarge
- x1e.xlarge
- x1e.2xlarge
- x1e.4xlarge
- x1e.8xlarge
- x1e.16xlarge
- x1e.32xlarge
- z1d.large
- z1d.xlarge
- z1d.2xlarge
- z1d.3xlarge
- z1d.6xlarge
- z1d.12xlarge
- d2.xlarge
- d2.2xlarge
- d2.4xlarge
- d2.8xlarge
- h1.2xlarge
- h1.4xlarge
- h1.8xlarge
- h1.16xlarge
- i3.large
- i3.xlarge
- i3.2xlarge
- i3.4xlarge
- i3.8xlarge
- i3.16xlarge
- i3.metal
- f1.2xlarge
- f1.4xlarge
- f1.16xlarge
- g3.4xlarge
- g3.8xlarge
- g3.16xlarge
- p2.xlarge
- p2.8xlarge
- p2.16xlarge
- p3.2xlarge
- p3.8xlarge
- p3.16xlarge
CreateAmazonLinux:
Type: String
Default: true
Description: Create Amazon Linux instance?
AllowedValues:
- true
- false
CreateAmazonLinux2:
Type: String
Default: true
Description: Create Amazon Linux 2 instance?
AllowedValues:
- true
- false
CreateWindows2008R2:
Type: String
Default: true
Description: Create Windows 2008 R2 instance?
AllowedValues:
- true
- false
CreateWindows2012:
Type: String
Default: true
Description: Create Windows 2012 instance?
AllowedValues:
- true
- false
CreateWindows2012R2:
Type: String
Default: true
Description: Create Windows 2012R2 instance?
AllowedValues:
- true
- false
CreateWindows2016:
Type: String
Default: true
Description: Create Windows 2016 instance?
AllowedValues:
- true
- false
ProjectTag:
Type: String
Description: Project tag (2-32 alphanumerics)
Default: InspectorDemo
MinLength: 2
MaxLength: 32
AllowedPattern: '[a-zA-Z][a-zA-Z0-9]*'
SgAdminCidr:
Type: String
Description: The CIDR block for administering EC2 instances (default "uninitialized" 0.0.0.0/32)
MinLength: 9
MaxLength: 18
Default: "0.0.0.0/32"
AllowedPattern: "(\\d{1,3})\\.(\\d{1,3})\\.(\\d{1,3})\\.(\\d{1,3})/(\\d{1,2})"
ConstraintDescription: Must be a valid IP CIDR range of the form x.x.x.x/x
AmazonLinuxAmiId:
Type : 'AWS::SSM::Parameter::Value<String>'
Default: '/aws/service/ami-amazon-linux-latest/amzn-ami-hvm-x86_64-gp2'
AmazonLinux2AmiId:
Type : 'AWS::SSM::Parameter::Value<String>'
Default: '/aws/service/ami-amazon-linux-latest/amzn2-ami-hvm-x86_64-gp2'
Windows2008R2AmiId:
Type : 'AWS::SSM::Parameter::Value<String>'
Default: '/aws/service/ami-windows-latest/Windows_Server-2008-R2_SP1-English-64Bit-Base'
Windows2012AmiId:
Type : 'AWS::SSM::Parameter::Value<String>'
Default: '/aws/service/ami-windows-latest/Windows_Server-2012-RTM-English-64Bit-Base'
Windows2012R2AmiId:
Type : 'AWS::SSM::Parameter::Value<String>'
Default: '/aws/service/ami-windows-latest/Windows_Server-2012-R2_RTM-English-64Bit-Base'
Windows2016AmiId:
Type : 'AWS::SSM::Parameter::Value<String>'
Default: '/aws/service/ami-windows-latest/Windows_Server-2016-English-Full-Base'
Conditions:
LaunchAmazonLinux: !Equals [ !Ref CreateAmazonLinux, true ]
LaunchAmazonLinux2: !Equals [ !Ref CreateAmazonLinux2, true ]
LaunchWindows2008R2: !Equals [ !Ref CreateWindows2008R2, true ]
LaunchWindows2012: !Equals [ !Ref CreateWindows2012, true ]
LaunchWindows2012R2: !Equals [ !Ref CreateWindows2012R2, true ]
LaunchWindows2016: !Equals [ !Ref CreateWindows2016, true ]
Mappings:
RulesPackagesMap:
us-west-2:
CVE: 'arn:aws:inspector:us-west-2:758058086616:rulespackage/0-9hgA516p'
CIS: 'arn:aws:inspector:us-west-2:758058086616:rulespackage/0-H5hpSawc'
SBP: 'arn:aws:inspector:us-west-2:758058086616:rulespackage/0-JJOtZiqQ'
NET: 'arn:aws:inspector:us-west-2:758058086616:rulespackage/0-rD1z6dpl'
RBA: 'arn:aws:inspector:us-west-2:758058086616:rulespackage/0-vg5GGHSD'
us-east-1:
CVE: 'arn:aws:inspector:us-east-1:316112463485:rulespackage/0-gEjTy7T7'
CIS: 'arn:aws:inspector:us-east-1:316112463485:rulespackage/0-rExsr2X8'
NET: 'arn:aws:inspector:us-east-1:316112463485:rulespackage/0-PmNV0Tcd'
SBP: 'arn:aws:inspector:us-east-1:316112463485:rulespackage/0-R01qwB5Q'
RBA: 'arn:aws:inspector:us-east-1:316112463485:rulespackage/0-gBONHN9h'
us-east-2:
CVE: 'arn:aws:inspector:us-east-2:646659390643:rulespackage/0-JnA8Zp85'
CIS: 'arn:aws:inspector:us-east-2:646659390643:rulespackage/0-m8r61nnh'
NET: 'arn:aws:inspector:us-east-2:646659390643:rulespackage/0-cE4kTR30'
SBP: 'arn:aws:inspector:us-east-2:646659390643:rulespackage/0-AxKmMHPX'
RBA: 'arn:aws:inspector:us-east-2:646659390643:rulespackage/0-UCYZFKPV'
us-west-1:
CVE: 'arn:aws:inspector:us-west-1:166987590008:rulespackage/0-TKgzoVOa'
CIS: 'arn:aws:inspector:us-west-1:166987590008:rulespackage/0-xUY8iRqX'
NET: 'arn:aws:inspector:us-west-1:166987590008:rulespackage/0-TxmXimXF'
SBP: 'arn:aws:inspector:us-west-1:166987590008:rulespackage/0-byoQRFYm'
RBA: 'arn:aws:inspector:us-west-1:166987590008:rulespackage/0-yeYxlt0x'
ap-south-1:
CVE: 'arn:aws:inspector:ap-south-1:162588757376:rulespackage/0-LqnJE9dO'
CIS: 'arn:aws:inspector:ap-south-1:162588757376:rulespackage/0-PSUlX14m'
NET: 'arn:aws:inspector:ap-south-1:162588757376:rulespackage/0-YxKfjFu1'
SBP: 'arn:aws:inspector:ap-south-1:162588757376:rulespackage/0-fs0IZZBj'
RBA: 'arn:aws:inspector:ap-south-1:162588757376:rulespackage/0-EhMQZy6C'
ap-southeast-2:
CVE: 'arn:aws:inspector:ap-southeast-2:454640832652:rulespackage/0-D5TGAxiR'
CIS: 'arn:aws:inspector:ap-southeast-2:454640832652:rulespackage/0-Vkd2Vxjq'
SBP: 'arn:aws:inspector:ap-southeast-2:454640832652:rulespackage/0-asL6HRgN'
RBA: 'arn:aws:inspector:ap-southeast-2:454640832652:rulespackage/0-P8Tel2Xj'
ap-northeast-2:
CVE: 'arn:aws:inspector:ap-northeast-2:526946625049:rulespackage/0-PoGHMznc'
CIS: 'arn:aws:inspector:ap-northeast-2:526946625049:rulespackage/0-T9srhg1z'
NET: 'arn:aws:inspector:ap-northeast-2:526946625049:rulespackage/0-s3OmLzhL'
SBP: 'arn:aws:inspector:ap-northeast-2:526946625049:rulespackage/0-2WRpmi4n'
RBA: 'arn:aws:inspector:ap-northeast-2:526946625049:rulespackage/0-PoYq7lI7'
ap-northeast-1:
CVE: 'arn:aws:inspector:ap-northeast-1:406045910587:rulespackage/0-gHP9oWNT'
CIS: 'arn:aws:inspector:ap-northeast-1:406045910587:rulespackage/0-7WNjqgGu'
NET: 'arn:aws:inspector:ap-northeast-1:406045910587:rulespackage/0-YI95DVd7'
SBP: 'arn:aws:inspector:ap-northeast-1:406045910587:rulespackage/0-bBUQnxMq'
RBA: 'arn:aws:inspector:ap-northeast-1:406045910587:rulespackage/0-knGBhqEu'
eu-west-1:
CVE: 'arn:aws:inspector:eu-west-1:357557129151:rulespackage/0-ubA5XvBh'
CIS: 'arn:aws:inspector:eu-west-1:357557129151:rulespackage/0-sJBhCr0F'
NET: 'arn:aws:inspector:eu-west-1:357557129151:rulespackage/0-SPzU33xe'
SBP: 'arn:aws:inspector:eu-west-1:357557129151:rulespackage/0-SnojL3Z6'
RBA: 'arn:aws:inspector:eu-west-1:357557129151:rulespackage/0-lLmwe1zd'
eu-west-2:
CVE: 'arn:aws:inspector:eu-west-2:146838936955:rulespackage/0-kZGCqcE1'
CIS: 'arn:aws:inspector:eu-west-2:146838936955:rulespackage/0-IeCjwf1W'
NET: 'arn:aws:inspector:eu-west-2:146838936955:rulespackage/0-AizSYyNq'
SBP: 'arn:aws:inspector:eu-west-2:146838936955:rulespackage/0-XApUiSaP'
RBA: 'arn:aws:inspector:eu-west-2:146838936955:rulespackage/0-S8t0UlXB'
eu-central-1:
CVE: 'arn:aws:inspector:eu-central-1:537503971621:rulespackage/0-wNqHa8M9'
CIS: 'arn:aws:inspector:eu-central-1:537503971621:rulespackage/0-nZrAVuv8'
NET: 'arn:aws:inspector:eu-central-1:537503971621:rulespackage/0-6yunpJ91'
SBP: 'arn:aws:inspector:eu-central-1:537503971621:rulespackage/0-ZujVHEPB'
RBA: 'arn:aws:inspector:eu-central-1:537503971621:rulespackage/0-0GMUM6fg'
us-gov-east-1:
CVE: 'arn:aws-us-gov:inspector:us-gov-east-1:206278770380:rulespackage/0-3IFKFuOb'
CIS: 'arn:aws-us-gov:inspector:us-gov-east-1:206278770380:rulespackage/0-pTLCdIww'
SBP: 'arn:aws-us-gov:inspector:us-gov-east-1:206278770380:rulespackage/0-vlgEGcVD'
RBA: 'arn:aws-us-gov:inspector:us-gov-east-1:206278770380:rulespackage/0-850TmCFX'
us-gov-west-1:
CVE: 'arn:aws-us-gov:inspector:us-gov-west-1:850862329162:rulespackage/0-4oQgcI4G'
CIS: 'arn:aws-us-gov:inspector:us-gov-west-1:850862329162:rulespackage/0-Ac4CFOuc'
SBP: 'arn:aws-us-gov:inspector:us-gov-west-1:850862329162:rulespackage/0-rOTGqe5G'
RBA: 'arn:aws-us-gov:inspector:us-gov-west-1:850862329162:rulespackage/0-JMyjuzoW'
Resources:
Vpc:
Type: AWS::EC2::VPC
Properties:
CidrBlock: 10.200.0.0/16
EnableDnsHostnames: 'true'
Tags:
- Key: Name
Value: 'InspectorDemo'
- Key: Project
Value: !Ref ProjectTag
PublicSubnet:
Type: AWS::EC2::Subnet
Properties:
AvailabilityZone: !Ref AzName
CidrBlock: 10.200.11.0/24
MapPublicIpOnLaunch: 'true'
VpcId: !Ref Vpc
Tags:
- Key: Name
Value: 'InspectorDemo'
- Key: Project
Value: !Ref ProjectTag
VpcIgw:
Type: AWS::EC2::InternetGateway
Properties:
Tags:
- Key: Name
Value: 'InspectorDemo'
- Key: Project
Value: !Ref ProjectTag
VpcIgwAttachment:
Type: AWS::EC2::VPCGatewayAttachment
Properties:
InternetGatewayId: !Ref VpcIgw
VpcId: !Ref Vpc
# Note the use of the DependsOn attribute. You need to use this to delay
# the creation of the route table if it contains a route that reports to
# an Internet Gateway.
#
# See:
#
# https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-attribute-dependson.html
RouteTable:
Type: AWS::EC2::RouteTable
DependsOn: VpcIgwAttachment
Properties:
VpcId: !Ref Vpc
Tags:
- Key: Name
Value: 'InspectorDemo'
- Key: Project
Value: !Ref ProjectTag
DefaultRoute:
Type: AWS::EC2::Route
Properties:
DestinationCidrBlock: 0.0.0.0/0
GatewayId: !Ref VpcIgw
RouteTableId: !Ref RouteTable
AssociatePublicSubnetToRouteTable:
Type: AWS::EC2::SubnetRouteTableAssociation
Properties:
RouteTableId: !Ref RouteTable
SubnetId: !Ref PublicSubnet
RdpSg:
Type: AWS::EC2::SecurityGroup
Properties:
GroupDescription: 'Enable RDP access via port 3389'
SecurityGroupIngress:
- IpProtocol: tcp
FromPort: 3389
ToPort: 3389
CidrIp: !Ref SgAdminCidr
VpcId: !Ref Vpc
Tags:
- Key: Name
Value: 'InspectorDemo'
- Key: Project
Value: !Ref ProjectTag
SshSg:
Type: AWS::EC2::SecurityGroup
Properties:
GroupDescription: 'Enable SSH access via port 22'
SecurityGroupIngress:
- IpProtocol: tcp
FromPort: 22
ToPort: 22
CidrIp: !Ref SgAdminCidr
VpcId: !Ref Vpc
Tags:
- Key: Name
Value: 'InspectorDemo'
- Key: Project
Value: !Ref ProjectTag
# InstanceRole - The IAM role that will be attached to the Amazon EC2
# instance. We need to have the managed policies needed by both Amazon
# Inspector and AWS Systems Manager. Additional policies are included
# for the CloudFormation helper scripts.
InstanceRole:
Type: AWS::IAM::Role
Properties:
AssumeRolePolicyDocument:
Version: '2012-10-17'
Statement:
- Effect: Allow
Principal:
Service:
- ec2.amazonaws.com
Action:
- sts:AssumeRole
ManagedPolicyArns:
- arn:aws:iam::aws:policy/AmazonInspectorFullAccess
- arn:aws:iam::aws:policy/AmazonSSMFullAccess
- arn:aws:iam::aws:policy/AWSConfigUserAccess
- arn:aws:iam::aws:policy/AWSHealthFullAccess
- arn:aws:iam::aws:policy/CloudWatchReadOnlyAccess
Policies:
- PolicyName: "root"
PolicyDocument:
Version: "2012-10-17"
Statement:
- Effect: "Allow"
Action:
- cloudformation:SignalResource
- cloudformation:DescribeStackResource
- resource-groups:*
Resource: "*"
InstanceProfile:
Type: AWS::IAM::InstanceProfile
Properties:
Path: '/'
Roles:
- !Ref InstanceRole
AmazonLinuxInstance:
Type: AWS::EC2::Instance
Condition: LaunchAmazonLinux
CreationPolicy:
ResourceSignal:
Timeout: PT15M
Properties:
AvailabilityZone: !Ref AzName
IamInstanceProfile: !Ref InstanceProfile
ImageId: !Ref AmazonLinuxAmiId
InstanceInitiatedShutdownBehavior: stop
InstanceType: !Ref TargetInstanceType
KeyName: !Ref InstanceKeyPair
Monitoring: 'true'
NetworkInterfaces:
- AssociatePublicIpAddress: 'true'
DeviceIndex: '0'
GroupSet:
- !Ref SshSg
SubnetId: !Ref PublicSubnet
Tenancy: default
Tags:
- Key: Name
Value: 'ID Amazon Linux'
- Key: Project
Value: !Ref ProjectTag
UserData:
Fn::Base64: !Sub |
#!/bin/bash -xe
/opt/aws/bin/cfn-signal \
-e $? \
--stack ${AWS::StackName} \
--resource AmazonLinuxInstance \
--region ${AWS::Region}
AmazonLinuxInspectorRG:
Type: AWS::Inspector::ResourceGroup
Condition: LaunchAmazonLinux
Properties:
ResourceGroupTags:
- Key: "Name"
Value: "ID Amazon Linux"
AmazonLinuxInspectorTarget:
Type: AWS::Inspector::AssessmentTarget
Condition: LaunchAmazonLinux
Properties:
ResourceGroupArn: !GetAtt AmazonLinuxInspectorRG.Arn
AmazonLinuxOneHourInspectorTemplate:
Type: AWS::Inspector::AssessmentTemplate
Condition: LaunchAmazonLinux
Properties:
AssessmentTargetArn: !GetAtt AmazonLinuxInspectorTarget.Arn
DurationInSeconds: 3600
RulesPackageArns:
- !FindInMap [RulesPackagesMap, !Ref 'AWS::Region', CVE]
- !FindInMap [RulesPackagesMap, !Ref 'AWS::Region', CIS]
- !FindInMap [RulesPackagesMap, !Ref 'AWS::Region', SBP]
- !FindInMap [RulesPackagesMap, !Ref 'AWS::Region', RBA]
UserAttributesForFindings:
- Key: 'Name'
Value: 'ID Amazon Linux 2'
- Key: Project
Value: !Ref ProjectTag
AssociateSsmAmazonLinux:
Type: "AWS::SSM::Association"
Condition: LaunchAmazonLinux
Properties:
Name: AmazonInspector-ManageAWSAgent
Parameters:
Operation:
- Install
Targets:
- Key: InstanceIds
Values:
- !Ref AmazonLinuxInstance
AmazonLinux2Instance:
Type: AWS::EC2::Instance
Condition: LaunchAmazonLinux2
CreationPolicy:
ResourceSignal:
Timeout: PT15M
Properties:
AvailabilityZone: !Ref AzName
IamInstanceProfile: !Ref InstanceProfile
ImageId: !Ref AmazonLinux2AmiId
InstanceInitiatedShutdownBehavior: stop
InstanceType: !Ref TargetInstanceType
KeyName: !Ref InstanceKeyPair
Monitoring: 'true'
NetworkInterfaces:
- AssociatePublicIpAddress: 'true'
DeviceIndex: '0'
GroupSet:
- !Ref SshSg
SubnetId: !Ref PublicSubnet
Tenancy: default
Tags:
- Key: Name
Value: 'ID Amazon Linux 2'
- Key: Project
Value: !Ref ProjectTag
UserData:
Fn::Base64: !Sub |
#!/bin/bash -xe
/opt/aws/bin/cfn-signal \
-e $? \
--stack ${AWS::StackName} \
--resource AmazonLinux2Instance \
--region ${AWS::Region}
AmazonLinux2InspectorRG:
Type: AWS::Inspector::ResourceGroup
Condition: LaunchAmazonLinux2
Properties:
ResourceGroupTags:
- Key: "Name"
Value: "ID Amazon Linux 2"
AmazonLinux2InspectorTarget:
Type: AWS::Inspector::AssessmentTarget
Condition: LaunchAmazonLinux2
Properties:
ResourceGroupArn: !GetAtt AmazonLinux2InspectorRG.Arn
AmazonLinux2OneHourInspectorTemplate:
Type: AWS::Inspector::AssessmentTemplate
Condition: LaunchAmazonLinux2
Properties:
AssessmentTargetArn: !GetAtt AmazonLinux2InspectorTarget.Arn
DurationInSeconds: 3600
RulesPackageArns:
- !FindInMap [RulesPackagesMap, !Ref 'AWS::Region', CVE]
- !FindInMap [RulesPackagesMap, !Ref 'AWS::Region', SBP]
- !FindInMap [RulesPackagesMap, !Ref 'AWS::Region', RBA]
UserAttributesForFindings:
- Key: 'Name'
Value: 'ID Amazon Linux 2'
- Key: Project
Value: !Ref ProjectTag
AssociateSsmAmazonLinux2:
Type: "AWS::SSM::Association"
Condition: LaunchAmazonLinux2
Properties:
Name: AmazonInspector-ManageAWSAgent
Parameters:
Operation:
- Install
Targets:
- Key: InstanceIds
Values:
- !Ref AmazonLinux2Instance
Windows2008R2Instance:
Type: AWS::EC2::Instance
Condition: LaunchWindows2008R2
Metadata:
AWS::CloudFormation::Init:
config:
pagkages:
msi: https://s3.amazonaws.com/cloudformation-examples/aws-cfn-bootstrap-win64-latest.msi
CreationPolicy:
ResourceSignal:
Timeout: PT15M
Properties:
AvailabilityZone: !Ref AzName
IamInstanceProfile: !Ref InstanceProfile
ImageId: !Ref Windows2008R2AmiId
InstanceInitiatedShutdownBehavior: stop
InstanceType: !Ref TargetInstanceType
KeyName: !Ref InstanceKeyPair
Monitoring: 'true'
NetworkInterfaces:
- AssociatePublicIpAddress: 'true'
DeviceIndex: '0'
GroupSet:
- !Ref RdpSg
SubnetId: !Ref PublicSubnet
Tenancy: default
Tags:
- Key: Name
Value: 'ID Windows 2008 R2'
- Key: Project
Value: !Ref ProjectTag
UserData:
Fn::Base64: !Sub |
<script>
cfn-init.exe ^
--stack ${AWS::StackId} ^
--resource Windows2008R2Instance ^
--region ${AWS::Region}
cfn-signal.exe ^
--exit-code %ERRORLEVEL% ^
--stack ${AWS::StackId} ^
--resource Windows2008R2Instance ^
--region ${AWS::Region}
</script>
Windows2008R2InspectorRG:
Type: AWS::Inspector::ResourceGroup
Condition: LaunchWindows2008R2
Properties:
ResourceGroupTags:
- Key: "Name"
Value: "ID Windows 2008 R2"
Windows2008R2InspectorTarget:
Type: AWS::Inspector::AssessmentTarget
Condition: LaunchWindows2008R2
Properties:
ResourceGroupArn: !GetAtt Windows2008R2InspectorRG.Arn
Windows2008R2OneHourInspectorTemplate:
Type: AWS::Inspector::AssessmentTemplate
Condition: LaunchWindows2008R2
Properties:
AssessmentTargetArn: !GetAtt Windows2008R2InspectorTarget.Arn
DurationInSeconds: 3600
RulesPackageArns:
- !FindInMap [RulesPackagesMap, !Ref 'AWS::Region', CVE]
- !FindInMap [RulesPackagesMap, !Ref 'AWS::Region', CIS]
- !FindInMap [RulesPackagesMap, !Ref 'AWS::Region', RBA]
UserAttributesForFindings:
- Key: 'Name'
Value: 'ID Windows 2008 R2'
- Key: Project
Value: !Ref ProjectTag
AssociateSsmWindows2008R2:
Type: "AWS::SSM::Association"
Condition: LaunchWindows2008R2
Properties:
Name: AmazonInspector-ManageAWSAgent
Parameters:
Operation:
- Install
Targets:
- Key: InstanceIds
Values:
- !Ref Windows2008R2Instance
Windows2012Instance:
Type: AWS::EC2::Instance
Condition: LaunchWindows2012
Metadata:
AWS::CloudFormation::Init:
config:
pagkages:
msi: https://s3.amazonaws.com/cloudformation-examples/aws-cfn-bootstrap-win64-latest.msi
CreationPolicy:
ResourceSignal:
Timeout: PT15M
Properties:
AvailabilityZone: !Ref AzName
IamInstanceProfile: !Ref InstanceProfile
ImageId: !Ref Windows2012AmiId
InstanceInitiatedShutdownBehavior: stop
InstanceType: !Ref TargetInstanceType
KeyName: !Ref InstanceKeyPair
Monitoring: 'true'
NetworkInterfaces:
- AssociatePublicIpAddress: 'true'
DeviceIndex: '0'
GroupSet:
- !Ref RdpSg
SubnetId: !Ref PublicSubnet
Tenancy: default
Tags:
- Key: Name
Value: 'ID Windows 2012'
- Key: Project
Value: !Ref ProjectTag
UserData:
Fn::Base64: !Sub |
<script>
cfn-init.exe ^
--stack ${AWS::StackId} ^
--resource Windows2012Instance ^
--region ${AWS::Region}
cfn-signal.exe ^
--exit-code %ERRORLEVEL% ^
--stack ${AWS::StackId} ^
--resource Windows2012Instance ^
--region ${AWS::Region}
</script>
Windows2012InspectorRG:
Type: AWS::Inspector::ResourceGroup
Condition: LaunchWindows2012
Properties:
ResourceGroupTags:
- Key: "Name"
Value: "ID Windows 2012"
Windows2012InspectorTarget:
Type: AWS::Inspector::AssessmentTarget
Condition: LaunchWindows2012
Properties:
ResourceGroupArn: !GetAtt Windows2012InspectorRG.Arn
Windows2012OneHourInspectorTemplate:
Type: AWS::Inspector::AssessmentTemplate
Condition: LaunchWindows2012
Properties:
AssessmentTargetArn: !GetAtt Windows2012InspectorTarget.Arn
DurationInSeconds: 3600
RulesPackageArns:
- !FindInMap [RulesPackagesMap, !Ref 'AWS::Region', CVE]
- !FindInMap [RulesPackagesMap, !Ref 'AWS::Region', CIS]
- !FindInMap [RulesPackagesMap, !Ref 'AWS::Region', RBA]
UserAttributesForFindings:
- Key: 'Name'
Value: 'ID Windows 2012'
- Key: Project
Value: !Ref ProjectTag
AssociateSsmWindows2012:
Type: "AWS::SSM::Association"
Condition: LaunchWindows2012
Properties:
Name: AmazonInspector-ManageAWSAgent
Parameters:
Operation:
- Install
Targets:
- Key: InstanceIds
Values:
- !Ref Windows2012Instance
Windows2012R2Instance:
Type: AWS::EC2::Instance
Condition: LaunchWindows2012R2
Metadata:
AWS::CloudFormation::Init:
config:
pagkages:
msi: https://s3.amazonaws.com/cloudformation-examples/aws-cfn-bootstrap-win64-latest.msi
CreationPolicy:
ResourceSignal:
Timeout: PT15M
Properties:
AvailabilityZone: !Ref AzName
IamInstanceProfile: !Ref InstanceProfile
ImageId: !Ref Windows2012R2AmiId
InstanceInitiatedShutdownBehavior: stop
InstanceType: !Ref TargetInstanceType
KeyName: !Ref InstanceKeyPair
Monitoring: 'true'
NetworkInterfaces:
- AssociatePublicIpAddress: 'true'
DeviceIndex: '0'
GroupSet:
- !Ref RdpSg
SubnetId: !Ref PublicSubnet
Tenancy: default
Tags:
- Key: Name
Value: 'ID Windows 2012 R2'
- Key: Project
Value: !Ref ProjectTag
UserData:
Fn::Base64: !Sub |
<script>
cfn-init.exe ^
--stack ${AWS::StackId} ^
--resource Windows2012R2Instance ^
--region ${AWS::Region}
cfn-signal.exe ^
--exit-code %ERRORLEVEL% ^
--stack ${AWS::StackId} ^
--resource Windows2012R2Instance ^
--region ${AWS::Region}
</script>
Windows2012R2InspectorRG:
Type: AWS::Inspector::ResourceGroup
Condition: LaunchWindows2012R2
Properties:
ResourceGroupTags:
- Key: "Name"
Value: "ID Windows 2012 R2"
Windows2012R2InspectorTarget:
Type: AWS::Inspector::AssessmentTarget
Condition: LaunchWindows2012R2
Properties:
ResourceGroupArn: !GetAtt Windows2012R2InspectorRG.Arn
Windows2012R2OneHourInspectorTemplate:
Type: AWS::Inspector::AssessmentTemplate
Condition: LaunchWindows2012R2
Properties:
AssessmentTargetArn: !GetAtt Windows2012R2InspectorTarget.Arn
DurationInSeconds: 3600
RulesPackageArns:
- !FindInMap [RulesPackagesMap, !Ref 'AWS::Region', CVE]
- !FindInMap [RulesPackagesMap, !Ref 'AWS::Region', CIS]
- !FindInMap [RulesPackagesMap, !Ref 'AWS::Region', RBA]
UserAttributesForFindings:
- Key: 'Name'
Value: 'ID Windows 2012 R2'
- Key: Project
Value: !Ref ProjectTag
AssociateSsmWindows2012R2:
Type: "AWS::SSM::Association"
Condition: LaunchWindows2012R2
Properties:
Name: AmazonInspector-ManageAWSAgent
Parameters:
Operation:
- Install
Targets:
- Key: InstanceIds
Values:
- !Ref Windows2012R2Instance
Windows2016Instance:
Type: AWS::EC2::Instance
Condition: LaunchWindows2016
Metadata:
AWS::CloudFormation::Init:
config:
pagkages:
msi: https://s3.amazonaws.com/cloudformation-examples/aws-cfn-bootstrap-win64-latest.msi
CreationPolicy:
ResourceSignal:
Timeout: PT15M
Properties:
AvailabilityZone: !Ref AzName
IamInstanceProfile: !Ref InstanceProfile
ImageId: !Ref Windows2016AmiId
InstanceInitiatedShutdownBehavior: stop
InstanceType: !Ref TargetInstanceType
KeyName: !Ref InstanceKeyPair
Monitoring: 'true'
NetworkInterfaces:
- AssociatePublicIpAddress: 'true'
DeviceIndex: '0'
GroupSet:
- !Ref RdpSg
SubnetId: !Ref PublicSubnet
Tenancy: default
Tags:
- Key: Name
Value: 'ID Windows 2016'
- Key: Project
Value: !Ref ProjectTag
UserData:
Fn::Base64: !Sub |
<script>
cfn-init.exe ^
--stack ${AWS::StackId} ^
--resource Windows2016Instance ^
--region ${AWS::Region}
cfn-signal.exe ^
--exit-code %ERRORLEVEL% ^
--stack ${AWS::StackId} ^
--resource Windows2016Instance ^
--region ${AWS::Region}
</script>
Windows2016InspectorRG:
Type: AWS::Inspector::ResourceGroup
Condition: LaunchWindows2016
Properties:
ResourceGroupTags:
- Key: "Name"
Value: "ID Windows 2016"
Windows2016InspectorTarget:
Type: AWS::Inspector::AssessmentTarget
Condition: LaunchWindows2016
Properties:
ResourceGroupArn: !GetAtt Windows2016InspectorRG.Arn
Windows2016OneHourInspectorTemplate:
Type: AWS::Inspector::AssessmentTemplate
Condition: LaunchWindows2016
Properties:
AssessmentTargetArn: !GetAtt Windows2016InspectorTarget.Arn
DurationInSeconds: 3600
RulesPackageArns:
- !FindInMap [RulesPackagesMap, !Ref 'AWS::Region', CVE]
- !FindInMap [RulesPackagesMap, !Ref 'AWS::Region', RBA]
UserAttributesForFindings:
- Key: 'Name'
Value: 'ID Amazon Linux 2'
- Key: Project