-
Notifications
You must be signed in to change notification settings - Fork 133
Expand file tree
/
Copy pathclawdbot-bedrock.yaml
More file actions
1930 lines (1768 loc) · 78.1 KB
/
Copy pathclawdbot-bedrock.yaml
File metadata and controls
1930 lines (1768 loc) · 78.1 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
AWSTemplateFormatVersion: '2010-09-09'
Description: 'OpenClaw - AWS Native Deployment (Bedrock + SSM + VPC Endpoints)'
Metadata:
cfn-lint:
config:
ignore_checks:
- E6101
AWS::CloudFormation::Interface:
ParameterGroups:
- Label:
default: "Basic Configuration"
Parameters:
- OpenClawModel
- OpenClawVersion
- InstanceType
- Label:
default: "Network Configuration"
Parameters:
- CreateVPCEndpoints
- EnableMonitoring
Parameters:
OpenClawModel:
Type: String
Default: "global.amazon.nova-2-lite-v1:0"
Description: "Bedrock model ID - Nova 2 Lite offers best price-performance for everyday tasks"
AllowedValues:
- "global.amazon.nova-2-lite-v1:0"
- "global.anthropic.claude-sonnet-4-6"
- "global.anthropic.claude-sonnet-4-5-20250929-v1:0"
- "us.amazon.nova-pro-v1:0"
- "global.anthropic.claude-opus-4-7"
- "global.anthropic.claude-opus-4-6-v1"
- "global.anthropic.claude-opus-4-5-20251101-v1:0"
- "global.anthropic.claude-haiku-4-5-20251001-v1:0"
- "us.deepseek.r1-v1:0"
- "us.meta.llama3-3-70b-instruct-v1:0"
- "moonshotai.kimi-k2.5"
InstanceType:
Type: String
Default: "c7g.large"
Description: "Graviton (ARM) recommended. c7g = compute-optimized (recommended, 2 vCPU for Node.js + sandbox). r7g/r6g = memory-optimized. t4g = burstable."
AllowedValues:
- "t4g.small"
- "t4g.medium"
- "t4g.large"
- "t4g.xlarge"
- "c6g.large"
- "c6g.xlarge"
- "c7g.large"
- "c7g.xlarge"
- "r6g.medium"
- "r6g.large"
- "r6g.xlarge"
- "r7g.medium"
- "r7g.large"
- "r7g.xlarge"
- "t3.small"
- "t3.medium"
- "t3.large"
- "c5.xlarge"
- "r5.large"
- "r5.xlarge"
CreateVPCEndpoints:
Type: String
Default: "false"
Description: "Create VPC endpoints for private network access to Bedrock and SSM"
AllowedValues:
- "true"
- "false"
EnableSandbox:
Type: String
Default: "true"
Description: "Install Docker for sandboxed execution (recommended for group chats)"
OpenClawVersion:
Type: String
Default: "2026.6.34"
AllowedValues:
- "2026.3.24"
- "2026.4.5"
- "2026.4.10"
- "2026.4.27"
- "2026.6.9"
- "2026.6.34"
- "2026.7.1"
- "extended-stable"
- "latest"
Description: "OpenClaw version. Default 2026.6.34 tracks OpenClaw's 'extended-stable' channel (the maintained production line). Use the 'extended-stable' dist-tag to auto-follow that channel, or '2026.7.1' for the latest release. 2026.3.24 (no model approval, WeChat compatible); 2026.4.5+ (auto-discovery, embeddings). Avoid 'latest' in production — prefer a pinned version or 'extended-stable'."
EnableMonitoring:
Type: String
Default: "true"
Description: "Enable CloudWatch monitoring, health checks, auto-recovery, and log shipping (+~$4/mo)"
AllowedValues:
- "true"
- "false"
EnableDataProtection:
Type: String
Default: "false"
Description: "If retain both EBS volume and S3 bucket on stack deletion,set to true. Data will be deleted if set to false."
AllowedValues:
- "true"
- "false"
EnablePublicAccess:
Type: String
Default: "false"
Description: "Enable public access via ALB + CloudFront"
AllowedValues:
- "true"
- "false"
EnableWAF:
Type: String
Default: "false"
Description: "Enable AWS WAF for CloudFront (Layer 7 DDoS protection, SQL injection, XSS). WAF must be created in us-east-1."
AllowedValues:
- "true"
- "false"
AllowedCountries:
Type: CommaDelimitedList
Default: ""
Description: "Optional: Restrict CloudFront access to specific countries using ISO 3166-1 alpha-2 codes (e.g., AU,US,GB,JP). Leave empty (default) to allow all countries worldwide."
Conditions:
CreateEndpoints: !Equals [!Ref CreateVPCEndpoints, "true"]
CreateWAF: !And
- !Equals [!Ref EnableWAF, "true"]
- !Equals [!Ref EnablePublicAccess, "true"]
- !Equals [!Ref "AWS::Region", "us-east-1"]
HasGeoRestriction: !Not
- !Equals
- !Join [",", !Ref AllowedCountries]
- ""
# Bedrock Mantle supported regions: https://docs.aws.amazon.com/bedrock/latest/userguide/bedrock-mantle.html#bedrock-mantle-supported
IsUsEast1: !Equals [ !Ref "AWS::Region", "us-east-1" ]
IsUsEast2: !Equals [ !Ref "AWS::Region", "us-east-2" ]
IsUsWest2: !Equals [ !Ref "AWS::Region", "us-west-2" ]
IsApSoutheast3: !Equals [ !Ref "AWS::Region", "ap-southeast-3" ]
IsApSouth1: !Equals [ !Ref "AWS::Region", "ap-south-1" ]
IsApNortheast1: !Equals [ !Ref "AWS::Region", "ap-northeast-1" ]
IsEuCentral1: !Equals [ !Ref "AWS::Region", "eu-central-1" ]
IsEuWest1: !Equals [ !Ref "AWS::Region", "eu-west-1" ]
IsEuWest2: !Equals [ !Ref "AWS::Region", "eu-west-2" ]
IsEuSouth1: !Equals [ !Ref "AWS::Region", "eu-south-1" ]
IsEuNorth1: !Equals [ !Ref "AWS::Region", "eu-north-1" ]
IsSaEast1: !Equals [ !Ref "AWS::Region", "sa-east-1" ]
IsMantleSupportedRegion: !Or
- !Or
- Condition: IsUsEast1
- Condition: IsUsEast2
- Condition: IsUsWest2
- Condition: IsApSoutheast3
- Condition: IsApSouth1
- Condition: IsApNortheast1
- !Or
- Condition: IsEuCentral1
- Condition: IsEuWest1
- Condition: IsEuWest2
- Condition: IsEuSouth1
- Condition: IsEuNorth1
- Condition: IsSaEast1
CreateMantleEndpoint: !And [ Condition: CreateEndpoints, Condition: IsMantleSupportedRegion ]
EnableCW: !Equals [!Ref EnableMonitoring, "true"]
ProtectData: !Equals [!Ref EnableDataProtection, "true"]
DeleteData: !Not [!Equals [!Ref EnableDataProtection, "true"]]
EnablePublic: !Equals [!Ref EnablePublicAccess, "true"]
DisablePublic: !Not [!Equals [!Ref EnablePublicAccess, "true"]]
Mappings:
ArchitectureMap:
t3.small: { Arch: "amd64" }
t3.medium: { Arch: "amd64" }
t3.large: { Arch: "amd64" }
t3.xlarge: { Arch: "amd64" }
c5.xlarge: { Arch: "amd64" }
r5.large: { Arch: "amd64" }
r5.xlarge: { Arch: "amd64" }
t4g.small: { Arch: "arm64" }
t4g.medium: { Arch: "arm64" }
t4g.large: { Arch: "arm64" }
t4g.xlarge: { Arch: "arm64" }
c6g.large: { Arch: "arm64" }
c6g.xlarge: { Arch: "arm64" }
c7g.large: { Arch: "arm64" }
c7g.xlarge: { Arch: "arm64" }
r6g.medium: { Arch: "arm64" }
r6g.large: { Arch: "arm64" }
r6g.xlarge: { Arch: "arm64" }
r7g.medium: { Arch: "arm64" }
r7g.large: { Arch: "arm64" }
r7g.xlarge: { Arch: "arm64" }
# CloudFront Managed Prefix List IDs by Region
# AWS Global service: com.amazonaws.global.cloudfront.origin-facing
# Note: AWS China (cn-*) and GovCloud (us-gov-*) regions are separate partitions
# and do not have CloudFront service, so they are not included here.
CloudFrontPrefixListMap:
# US regions
us-east-1: { PrefixListId: "pl-3b927c52" }
us-east-2: { PrefixListId: "pl-b6a144df" }
us-west-1: { PrefixListId: "pl-4ea04527" }
us-west-2: { PrefixListId: "pl-82a045eb" }
# Asia Pacific regions
ap-south-1: { PrefixListId: "pl-9aa247f3" }
ap-south-2: { PrefixListId: "pl-02a34e6b" }
ap-northeast-1: { PrefixListId: "pl-58a04531" }
ap-northeast-2: { PrefixListId: "pl-22a6434b" }
ap-northeast-3: { PrefixListId: "pl-96a247ff" }
ap-southeast-1: { PrefixListId: "pl-31a34658" }
ap-southeast-2: { PrefixListId: "pl-b8a742d1" }
ap-southeast-3: { PrefixListId: "pl-1ea34677" }
ap-southeast-4: { PrefixListId: "pl-9aa344f3" }
# Canada regions
ca-central-1: { PrefixListId: "pl-38a64351" }
# Europe regions
eu-central-1: { PrefixListId: "pl-a3a144ca" }
eu-central-2: { PrefixListId: "pl-14a5467d" }
eu-west-1: { PrefixListId: "pl-4fa04526" }
eu-west-2: { PrefixListId: "pl-93a247fa" }
eu-west-3: { PrefixListId: "pl-75b1541c" }
eu-south-1: { PrefixListId: "pl-8fa045e6" }
eu-south-2: { PrefixListId: "pl-04a5466d" }
eu-north-1: { PrefixListId: "pl-fab65393" }
# South America regions
sa-east-1: { PrefixListId: "pl-5da64334" }
# Middle East and Africa regions
af-south-1: { PrefixListId: "pl-a9a045c0" }
me-south-1: { PrefixListId: "pl-17a3467e" }
me-central-1: { PrefixListId: "pl-a1a242c8" }
il-central-1: { PrefixListId: "pl-89a64be0" }
Resources:
# ==================== Wait Condition ====================
OpenClawWaitHandle:
Type: AWS::CloudFormation::WaitConditionHandle
OpenClawWaitCondition:
Type: AWS::CloudFormation::WaitCondition
DependsOn: OpenClawInstance
Properties:
Handle: !Ref OpenClawWaitHandle
Timeout: '1200'
Count: 1
# ==================== VPC and Network ====================
OpenClawVPC:
Type: AWS::EC2::VPC
Properties:
CidrBlock: "10.0.0.0/16"
EnableDnsHostnames: true
EnableDnsSupport: true
Tags:
- Key: Name
Value: !Sub "${AWS::StackName}-vpc"
OpenClawInternetGateway:
Type: AWS::EC2::InternetGateway
AttachGateway:
Type: AWS::EC2::VPCGatewayAttachment
Properties:
VpcId: !Ref OpenClawVPC
InternetGatewayId: !Ref OpenClawInternetGateway
PublicSubnet:
Type: AWS::EC2::Subnet
Properties:
VpcId: !Ref OpenClawVPC
CidrBlock: "10.0.1.0/24"
MapPublicIpOnLaunch: true
AvailabilityZone: !Select [0, !GetAZs '']
Tags:
- Key: Name
Value: !Sub "${AWS::StackName}-public-subnet-az1"
PublicSubnet2:
Type: AWS::EC2::Subnet
Condition: EnablePublic
Properties:
VpcId: !Ref OpenClawVPC
CidrBlock: "10.0.4.0/24"
MapPublicIpOnLaunch: true
AvailabilityZone: !Select [1, !GetAZs '']
Tags:
- Key: Name
Value: !Sub "${AWS::StackName}-public-subnet-az2"
PrivateSubnet:
Type: AWS::EC2::Subnet
Condition: CreateEndpoints
Properties:
VpcId: !Ref OpenClawVPC
CidrBlock: "10.0.2.0/24"
AvailabilityZone: !Select [0, !GetAZs '']
Tags:
- Key: Name
Value: !Sub "${AWS::StackName}-private-subnet-az1"
# Second private subnet in a different AZ for VPC endpoint availability.
# Some services (e.g. bedrock-mantle) are not available in all AZs.
# With two subnets, CloudFormation picks the AZ that supports the service.
PrivateSubnet2:
Type: AWS::EC2::Subnet
Condition: CreateEndpoints
Properties:
VpcId: !Ref OpenClawVPC
CidrBlock: "10.0.3.0/24"
AvailabilityZone: !Select [1, !GetAZs '']
Tags:
- Key: Name
Value: !Sub "${AWS::StackName}-private-subnet-az2"
PublicRouteTable:
Type: AWS::EC2::RouteTable
Properties:
VpcId: !Ref OpenClawVPC
PublicRoute:
Type: AWS::EC2::Route
DependsOn: AttachGateway
Properties:
RouteTableId: !Ref PublicRouteTable
DestinationCidrBlock: "0.0.0.0/0"
GatewayId: !Ref OpenClawInternetGateway
SubnetRouteTableAssociation:
Type: AWS::EC2::SubnetRouteTableAssociation
Properties:
SubnetId: !Ref PublicSubnet
RouteTableId: !Ref PublicRouteTable
SubnetRouteTableAssociation2:
Type: AWS::EC2::SubnetRouteTableAssociation
Condition: EnablePublic
Properties:
SubnetId: !Ref PublicSubnet2
RouteTableId: !Ref PublicRouteTable
# Private Route Table for private subnets (VPC endpoints only, no NAT)
PrivateRouteTable:
Type: AWS::EC2::RouteTable
Condition: CreateEndpoints
Properties:
VpcId: !Ref OpenClawVPC
Tags:
- Key: Name
Value: !Sub "${AWS::StackName}-private-rtb"
PrivateSubnetRouteTableAssociation:
Type: AWS::EC2::SubnetRouteTableAssociation
Condition: CreateEndpoints
Properties:
SubnetId: !Ref PrivateSubnet
RouteTableId: !Ref PrivateRouteTable
PrivateSubnetRouteTableAssociation2:
Type: AWS::EC2::SubnetRouteTableAssociation
Condition: CreateEndpoints
Properties:
SubnetId: !Ref PrivateSubnet2
RouteTableId: !Ref PrivateRouteTable
# ==================== Network ACLs for Private Subnet Security ====================
# Private subnet now used only for VPC endpoints (when enabled)
PrivateNetworkAcl:
Type: AWS::EC2::NetworkAcl
Condition: CreateEndpoints
Properties:
VpcId: !Ref OpenClawVPC
Tags:
- Key: Name
Value: !Sub "${AWS::StackName}-private-nacl"
# Inbound Rules - only from VPC CIDR for VPC endpoints
PrivateNetworkAclInboundHTTPS:
Type: AWS::EC2::NetworkAclEntry
Condition: CreateEndpoints
Properties:
NetworkAclId: !Ref PrivateNetworkAcl
RuleNumber: 100
Protocol: 6
RuleAction: allow
CidrBlock: 10.0.0.0/16
PortRange:
From: 443
To: 443
PrivateNetworkAclInboundEphemeral:
Type: AWS::EC2::NetworkAclEntry
Condition: CreateEndpoints
Properties:
NetworkAclId: !Ref PrivateNetworkAcl
RuleNumber: 130
Protocol: 6
RuleAction: allow
CidrBlock: 0.0.0.0/0
PortRange:
From: 1024
To: 65535
# Outbound Rules - only HTTPS for VPC endpoint traffic
PrivateNetworkAclOutboundHTTPS:
Type: AWS::EC2::NetworkAclEntry
Condition: CreateEndpoints
Properties:
NetworkAclId: !Ref PrivateNetworkAcl
RuleNumber: 100
Protocol: 6
Egress: true
RuleAction: allow
CidrBlock: 0.0.0.0/0
PortRange:
From: 443
To: 443
PrivateNetworkAclOutboundEphemeral:
Type: AWS::EC2::NetworkAclEntry
Condition: CreateEndpoints
Properties:
NetworkAclId: !Ref PrivateNetworkAcl
RuleNumber: 130
Protocol: 6
Egress: true
RuleAction: allow
CidrBlock: 0.0.0.0/0
PortRange:
From: 1024
To: 65535
PrivateSubnetNetworkAclAssociation2:
Type: AWS::EC2::SubnetNetworkAclAssociation
Condition: CreateEndpoints
Properties:
SubnetId: !Ref PrivateSubnet2
NetworkAclId: !Ref PrivateNetworkAcl
# VPC Endpoint Security Group
VPCEndpointSecurityGroup:
Type: AWS::EC2::SecurityGroup
Condition: CreateEndpoints
Properties:
GroupDescription: "Security group for VPC endpoints"
VpcId: !Ref OpenClawVPC
SecurityGroupIngress:
- IpProtocol: tcp
FromPort: 443
ToPort: 443
SourceSecurityGroupId: !Ref OpenClawSecurityGroup
Tags:
- Key: Name
Value: !Sub "${AWS::StackName}-vpce-sg"
# Bedrock Runtime VPC Endpoint (Converse API)
BedrockRuntimeVPCEndpoint:
Type: AWS::EC2::VPCEndpoint
Condition: CreateEndpoints
Properties:
VpcId: !Ref OpenClawVPC
ServiceName: !Sub 'com.amazonaws.${AWS::Region}.bedrock-runtime'
VpcEndpointType: Interface
PrivateDnsEnabled: true
SubnetIds:
- !Ref PrivateSubnet
- !Ref PrivateSubnet2
SecurityGroupIds:
- !Ref VPCEndpointSecurityGroup
# Bedrock Mantle VPC Endpoint (OpenAI-compatible API for Project Mantle models like Kimi K2.5)
# Uses two subnets in different AZs — bedrock-mantle may not be available in all AZs.
BedrockMantleVPCEndpoint:
Type: AWS::EC2::VPCEndpoint
Condition: CreateMantleEndpoint
Properties:
VpcId: !Ref OpenClawVPC
ServiceName: !Sub 'com.amazonaws.${AWS::Region}.bedrock-mantle'
VpcEndpointType: Interface
PrivateDnsEnabled: true
SubnetIds:
- !Ref PrivateSubnet
- !Ref PrivateSubnet2
SecurityGroupIds:
- !Ref VPCEndpointSecurityGroup
# SSM VPC Endpoint (for Session Manager)
SSMVPCEndpoint:
Type: AWS::EC2::VPCEndpoint
Condition: CreateEndpoints
Properties:
VpcId: !Ref OpenClawVPC
ServiceName: !Sub 'com.amazonaws.${AWS::Region}.ssm'
VpcEndpointType: Interface
PrivateDnsEnabled: true
SubnetIds:
- !Ref PrivateSubnet
- !Ref PrivateSubnet2
SecurityGroupIds:
- !Ref VPCEndpointSecurityGroup
SSMMessagesVPCEndpoint:
Type: AWS::EC2::VPCEndpoint
Condition: CreateEndpoints
Properties:
VpcId: !Ref OpenClawVPC
ServiceName: !Sub 'com.amazonaws.${AWS::Region}.ssmmessages'
VpcEndpointType: Interface
PrivateDnsEnabled: true
SubnetIds:
- !Ref PrivateSubnet
- !Ref PrivateSubnet2
SecurityGroupIds:
- !Ref VPCEndpointSecurityGroup
EC2MessagesVPCEndpoint:
Type: AWS::EC2::VPCEndpoint
Condition: CreateEndpoints
Properties:
VpcId: !Ref OpenClawVPC
ServiceName: !Sub 'com.amazonaws.${AWS::Region}.ec2messages'
VpcEndpointType: Interface
PrivateDnsEnabled: true
SubnetIds:
- !Ref PrivateSubnet
- !Ref PrivateSubnet2
SecurityGroupIds:
- !Ref VPCEndpointSecurityGroup
# S3 Gateway VPC Endpoint (no additional cost, for S3 API access)
S3GatewayVPCEndpoint:
Type: AWS::EC2::VPCEndpoint
Condition: CreateEndpoints
Properties:
VpcId: !Ref OpenClawVPC
ServiceName: !Sub 'com.amazonaws.${AWS::Region}.s3'
VpcEndpointType: Gateway
RouteTableIds:
- !Ref PublicRouteTable
- !Ref PrivateRouteTable
# CloudWatch Logs VPC Endpoint (for log shipping)
CloudWatchLogsVPCEndpoint:
Type: AWS::EC2::VPCEndpoint
Condition: CreateEndpoints
Properties:
VpcId: !Ref OpenClawVPC
ServiceName: !Sub 'com.amazonaws.${AWS::Region}.logs'
VpcEndpointType: Interface
PrivateDnsEnabled: true
SubnetIds:
- !Ref PrivateSubnet
- !Ref PrivateSubnet2
SecurityGroupIds:
- !Ref VPCEndpointSecurityGroup
# ==================== IAM Role ====================
OpenClawInstanceRole:
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/AmazonSSMManagedInstanceCore'
- 'arn:aws:iam::aws:policy/CloudWatchAgentServerPolicy'
Policies:
- PolicyName: BedrockAccessPolicy
PolicyDocument:
Version: '2012-10-17'
Statement:
- Effect: Allow
Action:
- 'bedrock:InvokeModel'
- 'bedrock:InvokeModelWithResponseStream'
- 'bedrock:ListFoundationModels'
- 'bedrock:GetFoundationModel'
- 'bedrock:ListInferenceProfiles'
Resource: '*'
- PolicyName: BedrockMantleAccessPolicy
PolicyDocument:
Version: '2012-10-17'
Statement:
- Effect: Allow
Action:
- 'bedrock-mantle:*'
Resource: '*'
- !If
- EnableCW
- PolicyName: CloudWatchLogsPolicy
PolicyDocument:
Version: '2012-10-17'
Statement:
- Effect: Allow
Action:
- 'logs:CreateLogGroup'
- 'logs:CreateLogStream'
- 'logs:PutLogEvents'
- 'logs:DescribeLogStreams'
Resource: !Sub 'arn:aws:logs:${AWS::Region}:${AWS::AccountId}:log-group:/openclaw/*'
- !Ref AWS::NoValue
- PolicyName: SSMParameterPolicy
PolicyDocument:
Version: '2012-10-17'
Statement:
- Effect: Allow
Action:
- 'ssm:PutParameter'
- 'ssm:GetParameter'
Resource: !Sub 'arn:aws:ssm:${AWS::Region}:${AWS::AccountId}:parameter/openclaw/${AWS::StackName}/*'
- PolicyName: EC2DescribeTagsPolicy
PolicyDocument:
Version: '2012-10-17'
Statement:
- Effect: Allow
Action:
- 'ec2:DescribeTags'
Resource: '*'
- PolicyName: CloudFormationDescribePolicy
PolicyDocument:
Version: '2012-10-17'
Statement:
- Effect: Allow
Action:
- 'cloudformation:DescribeStackResource'
- 'cloudformation:SignalResource'
Resource: !Sub 'arn:aws:cloudformation:${AWS::Region}:${AWS::AccountId}:stack/${AWS::StackName}/*'
- PolicyName: S3BucketAccessPolicy
PolicyDocument:
Version: '2012-10-17'
Statement:
- Effect: Allow
Action:
- 's3:GetObject'
- 's3:PutObject'
- 's3:DeleteObject'
- 's3:ListBucket'
- 's3:GetBucketLocation'
Resource:
- !If
- ProtectData
- !GetAtt OpenClawS3BucketRetained.Arn
- !GetAtt OpenClawS3BucketNotRetained.Arn
- !If
- ProtectData
- !Sub '${OpenClawS3BucketRetained.Arn}/*'
- !Sub '${OpenClawS3BucketNotRetained.Arn}/*'
Tags:
- Key: Name
Value: !Sub "${AWS::StackName}-instance-role"
OpenClawInstanceProfile:
Type: AWS::IAM::InstanceProfile
Properties:
Roles:
- !Ref OpenClawInstanceRole
# ==================== Security Group ====================
ALBSecurityGroup:
Type: AWS::EC2::SecurityGroup
Condition: EnablePublic
Properties:
GroupDescription: "ALB security group - CloudFront managed prefix list only"
VpcId: !Ref OpenClawVPC
SecurityGroupIngress:
- IpProtocol: tcp
FromPort: 80
ToPort: 80
SourcePrefixListId: !FindInMap [CloudFrontPrefixListMap, !Ref "AWS::Region", PrefixListId]
Description: "HTTP from CloudFront managed prefix list (com.amazonaws.global.cloudfront.origin-facing)"
SecurityGroupEgress:
- IpProtocol: -1
CidrIp: "0.0.0.0/0"
Tags:
- Key: Name
Value: !Sub "${AWS::StackName}-alb-sg"
OpenClawSecurityGroup:
Type: AWS::EC2::SecurityGroup
Properties:
GroupDescription: "OpenClaw instance security group - SSM Session Manager only (no SSH)"
VpcId: !Ref OpenClawVPC
SecurityGroupIngress:
- !If
- EnablePublic
- IpProtocol: tcp
FromPort: 18789
ToPort: 18789
SourceSecurityGroupId: !Ref ALBSecurityGroup
Description: "OpenClaw from ALB"
- !Ref AWS::NoValue
SecurityGroupEgress:
- IpProtocol: -1
CidrIp: "0.0.0.0/0"
Tags:
- Key: Name
Value: !Sub "${AWS::StackName}-sg"
# ==================== S3 Bucket ====================
# Two conditional S3 buckets to match EnableDataProtection parameter behavior (same pattern as EBS volumes)
OpenClawS3BucketRetained:
Type: AWS::S3::Bucket
Condition: ProtectData
DeletionPolicy: Retain
UpdateReplacePolicy: Retain
Properties:
BucketName: !Sub "openclaw-${AWS::StackName}-${AWS::AccountId}"
BucketEncryption:
ServerSideEncryptionConfiguration:
- ServerSideEncryptionByDefault:
SSEAlgorithm: AES256
PublicAccessBlockConfiguration:
BlockPublicAcls: true
BlockPublicPolicy: true
IgnorePublicAcls: true
RestrictPublicBuckets: true
VersioningConfiguration:
Status: Enabled
LifecycleConfiguration:
Rules:
- Id: DeleteOldVersions
Status: Enabled
NoncurrentVersionExpirationInDays: 30
Tags:
- Key: Name
Value: !Sub "${AWS::StackName}-data-bucket"
OpenClawS3BucketNotRetained:
Type: AWS::S3::Bucket
Condition: DeleteData
DeletionPolicy: Delete
UpdateReplacePolicy: Delete
Properties:
BucketName: !Sub "openclaw-${AWS::StackName}-${AWS::AccountId}"
BucketEncryption:
ServerSideEncryptionConfiguration:
- ServerSideEncryptionByDefault:
SSEAlgorithm: AES256
PublicAccessBlockConfiguration:
BlockPublicAcls: true
BlockPublicPolicy: true
IgnorePublicAcls: true
RestrictPublicBuckets: true
VersioningConfiguration:
Status: Enabled
LifecycleConfiguration:
Rules:
- Id: DeleteOldVersions
Status: Enabled
NoncurrentVersionExpirationInDays: 30
Tags:
- Key: Name
Value: !Sub "${AWS::StackName}-data-bucket"
# ==================== Data Volume ====================
OpenClawDataVolumeRetained:
Type: AWS::EC2::Volume
Condition: ProtectData
DeletionPolicy: Retain
UpdateReplacePolicy: Retain
Properties:
AvailabilityZone: !Select [0, !GetAZs '']
Size: 30
VolumeType: gp3
Encrypted: true
Tags:
- Key: Name
Value: !Sub "${AWS::StackName}-data"
OpenClawDataVolumeNotRetained:
Type: AWS::EC2::Volume
Condition: DeleteData
DeletionPolicy: Delete
UpdateReplacePolicy: Delete
Properties:
AvailabilityZone: !Select [0, !GetAZs '']
Size: 30
VolumeType: gp3
Encrypted: true
Tags:
- Key: Name
Value: !Sub "${AWS::StackName}-data"
# ==================== EC2 Instance ====================
OpenClawInstance:
Type: AWS::EC2::Instance
Metadata:
AWS::CloudFormation::Init:
configSets:
default:
- write_files
- run_setup
write_files:
files:
/opt/openclaw/openclaw-config-legacy.json:
content: |
{
"gateway": {
"mode": "local",
"port": 18789,
"bind": "BIND_ADDRESS_PLACEHOLDER",
"trustedProxies": ["10.0.0.0/16"],
"controlUi": {
"enabled": true,
"dangerouslyDisableDeviceAuth": true,
"allowedOrigins": "ALLOWED_ORIGINS_PLACEHOLDER"
},
"auth": {
"mode": "token",
"token": "GATEWAY_TOKEN_PLACEHOLDER"
}
},
"models": {
"providers": {
"amazon-bedrock": {
"baseUrl": "https://bedrock-runtime.REGION_PLACEHOLDER.amazonaws.com",
"api": "bedrock-converse-stream",
"auth": "aws-sdk",
"models": [
{
"id": "MODEL_ID_PLACEHOLDER",
"name": "Bedrock Model",
"input": ["text", "image"],
"contextWindow": 200000,
"maxTokens": 8192
}
]
}
}
},
"agents": {
"defaults": {
"model": {
"primary": "amazon-bedrock/MODEL_ID_PLACEHOLDER"
}
}
}
}
mode: "000644"
owner: root
group: root
/opt/openclaw/openclaw-config-modern.json:
content: |
{
"gateway": {
"mode": "local",
"port": 18789,
"bind": "BIND_ADDRESS_PLACEHOLDER",
"trustedProxies": ["10.0.0.0/16"],
"controlUi": {
"enabled": true,
"dangerouslyDisableDeviceAuth": true,
"allowedOrigins": "ALLOWED_ORIGINS_PLACEHOLDER"
},
"auth": {
"mode": "token",
"token": "GATEWAY_TOKEN_PLACEHOLDER"
}
},
"plugins": {
"entries": {
"amazon-bedrock": {
"enabled": true
}
}
},
"agents": {
"defaults": {
"model": {
"primary": "amazon-bedrock/MODEL_ID_PLACEHOLDER"
},
"memorySearch": {
"provider": "bedrock",
"model": "amazon.titan-embed-text-v2:0"
}
}
}
}
mode: "000644"
owner: root
group: root
/opt/openclaw/SOUL.md:
content: |
# OpenClaw on AWS
You are an AI assistant running on AWS with Amazon Bedrock. You are helpful, concise, and friendly.
## First Conversation
When a user sends their very first message (no prior conversation history), start by warmly greeting them and then help them connect a messaging platform. Say something like:
"Welcome! I'm your AI assistant running on AWS. Before we dive in, let's connect me to your favorite messaging app so you can chat with me anytime.
Which platform would you like to connect?
1. WhatsApp — scan a QR code from your phone
2. Telegram — create a bot via @BotFather
3. Discord — add me to your server
4. Slack — install me in your workspace
5. Feishu/Lark — connect via webhook bridge
Just reply with a number or platform name, and I'll walk you through the setup step by step."
After the user chooses, guide them through the specific setup:
**WhatsApp**: Tell them to go to the Web UI (Channels > Add Channel > WhatsApp), then on their phone: WhatsApp > Settings > Linked Devices > Link a Device > scan the QR code.
**Telegram**: Tell them to message @BotFather on Telegram, send /newbot, choose a name and username (must end with 'bot'), copy the token, then paste it in Web UI (Channels > Add Channel > Telegram).
**Discord**: Tell them to visit discord.com/developers/applications, create a new app, go to Bot > Add Bot, copy the token, enable Message Content Intent, generate an invite URL, then paste the token in Web UI (Channels > Add Channel > Discord).
**Slack**: Tell them to visit api.slack.com/apps, create a new app, add bot scopes (chat:write, channels:history), install to workspace, copy the Bot User OAuth Token, then paste in Web UI (Channels > Add Channel > Slack).
**Feishu/Lark**: Tell them this uses a community bridge plugin. They need to configure their Feishu bot credentials in the Web UI. Point them to the docs: https://docs.openclaw.ai/channels or the community plugin page.
## Ongoing Conversations
After the first conversation, be a helpful general-purpose assistant. You can:
- Answer questions using web search
- Help with coding, writing, analysis
- Manage tasks and reminders
- Process files and documents
Be concise. Get to the point. If there's a good answer, give it directly.
mode: "000644"
owner: root
group: root
/opt/openclaw/ssm-portforward.sh:
content: |
#!/bin/bash
IMDS_TOKEN=$(curl -s -X PUT http://169.254.169.254/latest/api/token -H "X-aws-ec2-metadata-token-ttl-seconds: 21600")
INSTANCE_ID=$(curl -s -H "X-aws-ec2-metadata-token: $IMDS_TOKEN" http://169.254.169.254/latest/meta-data/instance-id)
REGION=$(curl -s -H "X-aws-ec2-metadata-token: $IMDS_TOKEN" http://169.254.169.254/latest/meta-data/placement/region)
STACK_NAME=$(aws ec2 describe-tags --filters "Name=resource-id,Values=$INSTANCE_ID" "Name=key,Values=aws:cloudformation:stack-name" --query "Tags[0].Value" --output text --region $REGION)
TOKEN=$(aws ssm get-parameter --name "/openclaw/$STACK_NAME/gateway-token" --with-decryption --query Parameter.Value --output text --region $REGION)
echo "=========================================="
echo "OpenClaw SSM Port Forwarding"
echo "=========================================="
echo ""
echo "Run on your local computer:"
echo ""
echo "aws ssm start-session \\"
echo " --target $INSTANCE_ID \\"
echo " --region $REGION \\"
echo " --document-name AWS-StartPortForwardingSession \\"
echo " --parameters '{\"portNumber\":[\"18789\"],\"localPortNumber\":[\"18789\"]}'"
echo ""
echo "Then open in browser:"
echo "http://localhost:18789/?token=$TOKEN"
echo ""
echo "=========================================="
mode: "000755"
owner: ubuntu
group: ubuntu
/opt/openclaw/setup.sh:
content:
Fn::Sub: |
#!/bin/bash
exec > >(tee /var/log/openclaw-setup.log)
exec 2>&1
echo "=========================================="
echo "OpenClaw AWS Native Setup: $(date)"
echo "=========================================="
export DEBIAN_FRONTEND=noninteractive
# Mount data volume
echo "[0/9] Mounting data volume..."
DATA_DEVICE=""
for dev in /dev/nvme1n1 /dev/xvdf /dev/sdf; do
if [ -b "$dev" ]; then
DATA_DEVICE="$dev"
break
fi
done
if [ -z "$DATA_DEVICE" ]; then
DATA_DEVICE=$(lsblk -dpno NAME,TYPE | awk '$2=="disk"{print $1}' | grep -v "$(findmnt -n -o SOURCE / | sed 's/p[0-9]*$//')" | head -1)
fi
if [ -n "$DATA_DEVICE" ] && [ -b "$DATA_DEVICE" ]; then
if ! blkid "$DATA_DEVICE" | grep -q ext4; then
echo "Formatting $DATA_DEVICE..."
mkfs.ext4 -L openclaw-data "$DATA_DEVICE"
fi
mkdir -p /data
if ! mount "$DATA_DEVICE" /data; then
echo "FATAL: failed to mount data volume $DATA_DEVICE at /data"
exit 1