This repository has been archived by the owner on Apr 21, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 23
/
identity.yaml
1033 lines (1025 loc) · 36.7 KB
/
identity.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
# Copyright (c) 2020, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
AWSTemplateFormatVersion: 2010-09-09
Description: >-
WSO2 Identity Server deployment with Clustering
Metadata:
'AWS::CloudFormation::Interface':
ParameterGroups:
- Label:
default: Basic Configuration
Parameters:
- AWSAccessKeyId
- AWSAccessKeySecret
- KeyPairName
- WSO2InstanceType
- CertificateName
- WSO2ISDBInstanceEndpointAddress
- WSO2ISDBInstanceEndpointPort
- DB
- DBUsername
- DBPassword
- Label:
default: Advanced Configuration
Parameters:
- OperatingSystem
- CustomUserData
- JDK
- ElasticSearchEndpoint
- ElasticSearchRegion
- EnvironmentName
- WSO2ISVPC
- WSO2ISPrivateSubnet1
- WSO2ISPrivateSubnet2
- WSO2ISPublicSubnet1
- WSO2ISPublicSubnet2
ParameterLabels:
AWSAccessKeyId:
default: AWS Access Key ID
AWSAccessKeySecret:
default: AWS Access Secret Key
OperatingSystem:
default: Operating System
CertificateName:
default: SSL Certificate Name
WSO2ISDBInstanceEndpointAddress:
default: DBInstance Endpoint Address
WSO2ISDBInstanceEndpointPort:
default: DBInstance Port
KeyPairName:
default: Key Pair Name
DBUsername:
default: DB Username
DBPassword:
default: DB Password
EnvironmentName:
default: Environment Name
JDK:
default: JDK
CustomUserData:
default: Customer User Data
WSO2InstanceType:
default: Instance Type
DB:
default: Database
ElasticSearchEndpoint:
default: ElasticSearch Endpoint
ElasticSearchRegion:
default: ElasticSearch Region
WSO2ISVPC:
default: VPC ID
WSO2ISPrivateSubnet1:
default: WSO2 Private Subnet 1 - ID
WSO2ISPrivateSubnet2:
default: WSO2 Private Subnet 2 - ID
WSO2ISPublicSubnet1:
default: WSO2 Public Subnet 1 - ID
WSO2ISPublicSubnet2:
default: WSO2 Public Subnet 2 - ID
Resources:
# File system configurations
WSO2ISEFSSecurityGroup:
Type: 'AWS::EC2::SecurityGroup'
Properties:
VpcId: !Ref WSO2ISVPC
GroupDescription: EFS Security Group
SecurityGroupIngress:
- IpProtocol: tcp
FromPort: '2049'
ToPort: '2049'
CidrIp: 0.0.0.0/0
Tags:
- Key: Name
Value: !Sub ${EnvironmentName} WSO2ISEFSSecurityGroup
WSO2ISEFSFileSystem:
Type: 'AWS::EFS::FileSystem'
Properties:
PerformanceMode: generalPurpose
FileSystemTags:
- Key: Name
Value: !Sub ${EnvironmentName} WSO2ISEFSSecurityGroup
WSO2ISPrivateSubnet1EFSMountTarget:
Type: 'AWS::EFS::MountTarget'
Properties:
SubnetId: !Ref WSO2ISPrivateSubnet1
FileSystemId: !Ref WSO2ISEFSFileSystem
SecurityGroups:
- !Ref WSO2ISEFSSecurityGroup
WSO2ISPrivateSubnet2EFSMountTarget:
Type: 'AWS::EFS::MountTarget'
Properties:
SubnetId: !Ref WSO2ISPrivateSubnet2
FileSystemId: !Ref WSO2ISEFSFileSystem
SecurityGroups:
- !Ref WSO2ISEFSSecurityGroup
# Product configurations
WSO2ISSecurityGroup:
Type: 'AWS::EC2::SecurityGroup'
Properties:
VpcId: !Ref WSO2ISVPC
GroupDescription: WSO2 Identity Manager Security Group
GroupName: WSO2SecurityGroup
SecurityGroupIngress:
- IpProtocol: tcp
FromPort: 22
ToPort: 22
CidrIp: 0.0.0.0/0
- IpProtocol: tcp
FromPort: 443
ToPort: 443
CidrIp: 0.0.0.0/0
- IpProtocol: tcp
FromPort: 9200
ToPort: 9200
CidrIp: 0.0.0.0/0
- IpProtocol: tcp
FromPort: '8280'
ToPort: '8280'
SourceSecurityGroupId: !Ref WSO2ISLoadBalancerSecurityGroup
- IpProtocol: tcp
FromPort: '9763'
ToPort: '9763'
SourceSecurityGroupId: !Ref WSO2ISLoadBalancerSecurityGroup
- IpProtocol: tcp
FromPort: '9443'
ToPort: '9443'
SourceSecurityGroupId: !Ref WSO2ISLoadBalancerSecurityGroup
- IpProtocol: tcp
FromPort: '8243'
ToPort: '8243'
SourceSecurityGroupId: !Ref WSO2ISLoadBalancerSecurityGroup
- IpProtocol: tcp
FromPort: '5672'
ToPort: '5672'
SourceSecurityGroupId: !Ref WSO2ISLoadBalancerSecurityGroup
- IpProtocol: tcp
FromPort: '4100'
ToPort: '4100'
CidrIp: 0.0.0.0/0
- IpProtocol: tcp
FromPort: '5701'
ToPort: '5701'
CidrIp: 0.0.0.0/0
- IpProtocol: tcp
FromPort: '8140'
ToPort: '8140'
CidrIp: 0.0.0.0/0
Tags:
- Key: Name
Value: !Sub ${EnvironmentName} WSO2ISSecurityGroup
PuppetMaster:
Type: 'AWS::EC2::Instance'
CreationPolicy:
ResourceSignal:
Count: 1
Timeout: PT30M
Properties:
DisableApiTermination: 'false'
InstanceInitiatedShutdownBehavior: stop
ImageId: !FindInMap
- WSO2PuppetMasterRegionMap
- !Ref 'AWS::Region'
- Ubuntu1804
InstanceType: !Ref WSO2InstanceType
BlockDeviceMappings:
- DeviceName: /dev/sda1
Ebs:
VolumeSize: '50'
VolumeType: gp2
DeleteOnTermination: 'true'
KeyName: !Ref KeyPairName
Monitoring: 'false'
Tags:
- Key: Name
Value: !Sub ${EnvironmentName} PuppetMasterInstance
NetworkInterfaces:
- DeleteOnTermination: 'true'
Description: Primary network interface
DeviceIndex: 0
SubnetId: !Ref WSO2ISPrivateSubnet1
GroupSet:
- !Ref PuppetMasterSecurityGroup
UserData: !Base64
'Fn::Join':
- |+
- - '#!/bin/bash'
- exec > >(tee /var/log/user-data.log|logger -t user-data -s 2>/dev/console) 2>&1
- apt-get update
- apt-get -y install python-setuptools python-pip
- pip install https://s3.amazonaws.com/cloudformation-examples/aws-cfn-bootstrap-latest.tar.gz
- 'export PATH=~/.local/bin:$PATH'
- echo "> Set hostname to puppetmaster"
- hostname puppetmaster
- echo $(hostname) >> /etc/hostname
- echo "127.0.0.1 $(hostname)" >> /etc/hosts
- !Join
- ''
- - sed -i "s/access-key/
- !Ref AWSAccessKeyId
- /g" /usr/lib/logstash-6.5.1/logstash-PUPPETMASTER.conf
- !Join
- ''
- - sed -i "s/REGION_NAME/
- !Ref ElasticSearchRegion
- /g" /usr/lib/logstash-6.5.1/logstash-PUPPETMASTER.conf
- !Join
- ''
- - sed -i "s^secret-key^
- !Ref AWSAccessKeySecret
- ^g" /usr/lib/logstash-6.5.1/logstash-PUPPETMASTER.conf
- !Join
- ''
- - sed -i "s^STACK_NAME^
- !Ref AWS::StackName
- ^g" /usr/lib/logstash-6.5.1/logstash-PUPPETMASTER.conf
- !Join
- ''
- - sed -i "s^ELASTICSEARCH_ENDPOINT^
- !Ref ElasticSearchEndpoint
- ^g" /usr/lib/logstash-6.5.1/logstash-PUPPETMASTER.conf
- export INSTANCEID=$(ec2metadata | grep -m 1 'instance-id:' | awk '{print $2}')
- sed -i "s/INSTANCE_ID/$INSTANCEID/g" /usr/lib/logstash-6.5.1/logstash-PUPPETMASTER.conf
- apt-get update
- apt install openjdk-8-jre-headless -y
- nohup /usr/lib/logstash-6.5.1/bin/logstash -f /usr/lib/logstash-6.5.1/logstash-PUPPETMASTER.conf & >> /home/ubuntu/elastic.log
- sed -i '/\[main\]/a dns_alt_names=puppetmaster,puppet' /etc/puppet/puppet.conf
- sed -i '/\[master\]/a autosign=true' /etc/puppet/puppet.conf
- service puppetmaster restart
- cd /home/ubuntu
- !Sub "./wso2-update-2.sh"
- !Sub "/usr/local/bin/cfn-signal -e $? --stack ${AWS::StackName} --resource PuppetMaster --region ${AWS::Region}"
- !Join
- ''
- - sed -i "s/access-key/
- !Ref AWSAccessKeyId
- /g" /etc/puppet/code/environments/production/modules/is5110/manifests/params.pp
- !Join
- ''
- - sed -i "s/REGION_NAME/
- !Ref "AWS::Region"
- /g" /etc/puppet/code/environments/production/modules/is5110/manifests/params.pp
- !Join
- ''
- - sed -i "s/CF_ELB_DNS_NAME/
- !GetAtt
- WSO2ISLoadBalancer
- DNSName
- >-
/g"
/etc/puppet/code/environments/production/modules/is5110/manifests/params.pp
- !Join
- ''
- - sed -i "s/CF_DB_USERNAME/
- !Ref DBUsername
- /g" /etc/puppet/code/environments/production/modules/is5110/manifests/params.pp
- !Join
- ''
- - sed -i "s/CF_DB_PASSWORD/
- !Ref DBPassword
- /g" /etc/puppet/code/environments/production/modules/is5110/manifests/params.pp
- !Join
- ''
- - sed -i "s/CF_DBMS/
- !Select [0, !Split ["_", !FindInMap [ DBEngineMap, !Ref DB, DBEngine]]]
- /g" /etc/puppet/code/environments/production/modules/is5110/manifests/params.pp
- !Join
- ''
- - sed -i "s/CF_RDS_URL/
- !Ref WSO2ISDBInstanceEndpointAddress
- /g" /etc/puppet/code/environments/production/modules/is5110/manifests/params.pp
- !Join
- ''
- - sed -i "s^secretkey^
- !Ref AWSAccessKeySecret
- ^g" /etc/puppet/code/environments/production/modules/is5110/manifests/params.pp
- export DB_NAME=WSO2_IS_DB
- !Join
- ''
- - sed -i "s/JDK_TYPE/
- !Ref JDK
- /g" /etc/puppet/code/environments/production/modules/is5110/manifests/params.pp
- !Join
- ''
- - export DB_HOSTNAME=
- !Ref WSO2ISDBInstanceEndpointAddress
- !Join
- ''
- - export DB_PORT=
- !Ref WSO2ISDBInstanceEndpointPort
- !Join
- ''
- - export DB_USERNAME=
- !Ref DBUsername
- !Join
- ''
- - export DB_PASSWORD=
- !Ref DBPassword
- !Join
- ''
- - sed -i "s/CF_DB_USERNAME/
- !Ref DBUsername
- /g" /usr/local/bin/provision_db_is.sh
- !Join
- ''
- - sed -i "s/CF_DB_PASSWORD/
- !Ref DBPassword
- /g" /usr/local/bin/provision_db_is.sh
- !Join
- ''
- - sed -i "s/CF_DB_HOST/
- !Ref WSO2ISDBInstanceEndpointAddress
- /g" /usr/local/bin/provision_db_is.sh
- !Join
- ''
- - sed -i "s/CF_DB_PORT/
- !Ref WSO2ISDBInstanceEndpointPort
- /g" /usr/local/bin/provision_db_is.sh
- !Join
- ''
- - sed -i "s/CF_DBMS_NAME/
- !Select [0, !Split ["_", !FindInMap [ DBEngineMap, !Ref DB, DBEngine]]]
- /g" /usr/local/bin/provision_db_is.sh
- !Join
- ''
- - sed -i "s/CF_DBMS_VERSION/
- !Select [1, !Split ["_", !FindInMap [ DBEngineMap, !Ref DB, DBEngine]]]
- /g" /usr/local/bin/provision_db_is.sh
- !Join
- ''
- - sed -i "s/CF_PRODUCT_VERSION/
- 5.11.0
- /g" /usr/local/bin/provision_db_is.sh
- wget -O /home/ubuntu/is/is5110/is_mssql.sql 'https://is-5110-dbscripts.s3.amazonaws.com/is_mssql.sql'
- wget -O /home/ubuntu/is/is5110/is_mysql.sql 'https://is-5110-dbscripts.s3.amazonaws.com/is_mysql.sql'
- wget -O /home/ubuntu/is/is5110/is_oracle_bps.sql 'https://is-5110-dbscripts.s3.amazonaws.com/is_oracle_bps.sql'
- wget -O /home/ubuntu/is/is5110/is_oracle_common.sql 'https://is-5110-dbscripts.s3.amazonaws.com/is_oracle_common.sql'
- wget -O /home/ubuntu/is/is5110/is_oracle_consent.sql 'https://is-5110-dbscripts.s3.amazonaws.com/is_oracle_consent.sql'
- wget -O /home/ubuntu/is/is5110/is_oracle_identity.sql 'https://is-5110-dbscripts.s3.amazonaws.com/is_oracle_identity.sql'
- wget -O /home/ubuntu/is/is5110/is_postgres.sql 'https://is-5110-dbscripts.s3.amazonaws.com/is_postgres.sql'
- bash /usr/local/bin/provision_db_is.sh
PuppetMasterSecurityGroup:
Type: 'AWS::EC2::SecurityGroup'
Properties:
VpcId: !Ref WSO2ISVPC
GroupDescription: WSO2 PuppetMaster Security Group
SecurityGroupIngress:
- IpProtocol: tcp
FromPort: 22
ToPort: 22
CidrIp: 0.0.0.0/0
- IpProtocol: tcp
FromPort: '8140'
ToPort: '8140'
CidrIp: 0.0.0.0/0
- IpProtocol: tcp
FromPort: 9200
ToPort: 9200
CidrIp: 0.0.0.0/0
Tags:
- Key: Name
Value: !Sub ${EnvironmentName} PuppetMasterSecurityGroup
WSO2ISNode1LaunchConfiguration:
Type: 'AWS::AutoScaling::LaunchConfiguration'
Properties:
ImageId: !FindInMap
- WSO2ISAMIRegionMap
- !Ref 'AWS::Region'
- !Ref OperatingSystem
InstanceType: !Ref WSO2InstanceType
BlockDeviceMappings:
- DeviceName: /dev/sda1
Ebs:
VolumeSize: '20'
VolumeType: gp2
DeleteOnTermination: 'true'
KeyName: !Ref KeyPairName
SecurityGroups:
- !Ref WSO2ISSecurityGroup
UserData: !Base64
'Fn::Sub': |
Content-Type: multipart/mixed; boundary="//"
MIME-Version: 1.0
--//
Content-Type: text/cloud-config; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment; filename="cloud-config.txt"
#cloud-config
cloud_final_modules:
- [scripts-user, always]
--//
Content-Type: text/x-shellscript; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment; filename="userdata.txt"
#!/bin/bash
exec > >(tee /var/log/user-data.log|logger -t user-data -s 2>/dev/console) 2>&1
export PATH=~/.local/bin:$PATH
if [[ ${OperatingSystem} == "Ubuntu1804" ]]; then
export DEBIAN_FRONTEND=noninteractive
apt-get update
apt install -y puppet nfs-common
apt install -y python-pip
sed -i '/\[main\]/a server=puppet' /etc/puppet/puppet.conf
fi
if [[ ${OperatingSystem} == "CentOS7" ]]; then
yum install -y epel-release zip unzip nfs-utils
yum install -y python-pip
rpm -Uvh https://yum.puppetlabs.com/puppet5/puppet5-release-el-7.noarch.rpm
yum install -y puppet-agent
echo $'[main]\nserver = puppet\ncertname = agent1\nenvironment = production\n\runinterval = 1h' > /etc/puppetlabs/puppet/puppet.conf
fi
pip install https://s3.amazonaws.com/cloudformation-examples/aws-cfn-bootstrap-latest.tar.gz
wget https://s3.amazonaws.com/wso2logarchiever/log_archiver/log_archiver.sh
mv log_archiver.sh /usr/lib/
export ProductVersion=5.11.0
sed -i "s/Product_Version/5.11.0/g" /usr/lib/logstash-6.5.1/logstash-IS.conf
sed -i "s^secret-key^${AWSAccessKeySecret}^g" /usr/lib/logstash-6.5.1/logstash-IS.conf
sed -i "s/access-key/${AWSAccessKeyId}/g" /usr/lib/logstash-6.5.1/logstash-IS.conf
sed -i "s^ELASTICSEARCH_ENDPOINT^${ElasticSearchEndpoint}^g" /usr/lib/logstash-6.5.1/logstash-IS.conf
export INSTANCEID=$(wget -q -O - http://169.254.169.254/latest/meta-data/instance-id)
sed -i "s/INSTANCE_ID/$INSTANCEID/g" /usr/lib/logstash-6.5.1/logstash-IS.conf
sed -i "s/STACK_NAME/${AWS::StackName}/g" /usr/lib/logstash-6.5.1/logstash-IS.conf
sed -i "s/REGION_NAME/${ElasticSearchRegion}/g" /usr/lib/logstash-6.5.1/logstash-IS.conf
nohup /usr/lib/logstash-6.5.1/bin/logstash -f /usr/lib/logstash-6.5.1/logstash-IS.conf &
export PuppetmasterIP=${PuppetMaster.PrivateIp}
echo "$PuppetmasterIP puppet puppetmaster" >> /etc/hosts
service puppet restart
mkdir -p /mnt/efs
mount -t nfs4 -o nfsvers=4.1 ${WSO2ISEFSFileSystem}.efs.${AWS::Region}.amazonaws.com:/ /mnt/efs
sleep 100
export FACTER_profile=is5110
if [[ ${OperatingSystem} == "Ubuntu1804" ]]; then
puppet agent -vt >> /var/log/puppetlog.log
fi
if [[ ${OperatingSystem} == "CentOS7" ]]; then
/opt/puppetlabs/bin/puppet agent -vt >> /var/log/puppetlog.log
fi
sleep 10
if [ ! -d "/mnt/efs/server/userstores" ]; then
mkdir -p /mnt/efs/server/userstores
cp -r /usr/lib/wso2/wso2is/5.11.0/wso2is-5.11.0/repository/deployment/server/userstores /mnt/efs/userstores
fi
rm -rf /usr/lib/wso2/wso2is/5.11.0/wso2is-5.11.0/repository/deployment/server/userstores
ln -s /mnt/efs/server/userstores /usr/lib/wso2/wso2is/5.11.0/wso2is-5.11.0/repository/deployment/server/userstores
if [ ! -d "/mnt/efs/tenants" ]; then
mkdir -p /mnt/efs/tenants
cp -r /usr/lib/wso2/wso2is/5.11.0/wso2is-5.11.0/repository/tenants /mnt/efs
fi
rm -rf /usr/lib/wso2/wso2is/5.11.0/wso2is-5.11.0/repository/tenants
ln -s /mnt/efs/tenants /usr/lib/wso2/wso2is/5.11.0/wso2is-5.11.0/repository/tenants
echo "${WSO2ISEFSFileSystem}:/ /mnt/efs efs defaults,_netdev 0 0" >> /etc/fstab
/usr/lib/wso2/wso2is/5.11.0/wso2is-5.11.0/bin/wso2server.sh start
${CustomUserData}
sleep 30
if [[ ${OperatingSystem} == "Ubuntu1804" ]]; then
end=$((SECONDS+1200))
while [ $SECONDS -lt $end ] ; do
sleep 10
wget --delete-after --server-response --no-check-certificate "https://localhost:9443/carbon/admin/login.jsp"
if [ $? -eq "0" ] ; then
/usr/local/bin/cfn-signal -e $? --stack ${AWS::StackName} --resource WSO2ISNode1AutoScalingGroup --region ${AWS::Region}
break
fi
done
fi
if [[ ${OperatingSystem} == "CentOS7" ]]; then
end=$((SECONDS+1200))
while [ $SECONDS -lt $end ] ; do
sleep 10
wget --delete-after --server-response --no-check-certificate "https://localhost:9443/carbon/admin/login.jsp"
if [ $? -eq "0" ] ; then
/usr/bin/cfn-signal -e $? --stack ${AWS::StackName} --resource WSO2ISNode1AutoScalingGroup --region ${AWS::Region}
break
fi
done
fi
echo 'export HISTTIMEFORMAT="%F %T "' >> /etc/profile.d/history.sh
cat /dev/null > ~/.bash_history && history -c
DependsOn:
- WSO2ISSecurityGroup
- WSO2ISLoadBalancer
- PuppetMaster
WSO2ISNode1AutoScalingGroup:
Type: 'AWS::AutoScaling::AutoScalingGroup'
Properties:
LaunchConfigurationName: !Ref WSO2ISNode1LaunchConfiguration
DesiredCapacity: 1
MinSize: 1
MaxSize: 2
TargetGroupARNs:
- !Ref WSO2ISALBTargetGroup
VPCZoneIdentifier:
- !Ref WSO2ISPrivateSubnet1
Tags:
- Key: Name
Value: !Sub ${EnvironmentName} WSO2ISInstance1
PropagateAtLaunch: 'true'
- Key: cluster
Value: is
PropagateAtLaunch: 'true'
CreationPolicy:
ResourceSignal:
Count: 1
Timeout: PT20M
UpdatePolicy:
AutoScalingRollingUpdate:
MaxBatchSize: '2'
MinInstancesInService: '1'
PauseTime: PT10M
SuspendProcesses:
- AlarmNotification
WaitOnResourceSignals: true
DependsOn:
- WSO2ISLoadBalancer
WSO2ISNode2LaunchConfiguration:
Type: 'AWS::AutoScaling::LaunchConfiguration'
Properties:
ImageId: !FindInMap
- WSO2ISAMIRegionMap
- !Ref 'AWS::Region'
- !Ref OperatingSystem
InstanceType: !Ref WSO2InstanceType
BlockDeviceMappings:
- DeviceName: /dev/sda1
Ebs:
VolumeSize: '20'
VolumeType: gp2
DeleteOnTermination: 'true'
KeyName: !Ref KeyPairName
SecurityGroups:
- !Ref WSO2ISSecurityGroup
UserData: !Base64
'Fn::Sub': |
Content-Type: multipart/mixed; boundary="//"
MIME-Version: 1.0
--//
Content-Type: text/cloud-config; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment; filename="cloud-config.txt"
#cloud-config
cloud_final_modules:
- [scripts-user, always]
--//
Content-Type: text/x-shellscript; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment; filename="userdata.txt"
#!/bin/bash
exec > >(tee /var/log/user-data.log|logger -t user-data -s 2>/dev/console) 2>&1
export PATH=~/.local/bin:$PATH
if [[ ${OperatingSystem} == "Ubuntu1804" ]]; then
export DEBIAN_FRONTEND=noninteractive
apt-get update
apt install -y puppet nfs-common
apt install -y python-pip
sed -i '/\[main\]/a server=puppet' /etc/puppet/puppet.conf
fi
if [[ ${OperatingSystem} == "CentOS7" ]]; then
yum install -y epel-release zip unzip nfs-utils
yum install -y python-pip
rpm -Uvh https://yum.puppetlabs.com/puppet5/puppet5-release-el-7.noarch.rpm
yum install -y puppet-agent
echo $'[main]\nserver = puppet\ncertname = agent2\nenvironment = production\n\runinterval = 1h' > /etc/puppetlabs/puppet/puppet.conf
fi
pip install https://s3.amazonaws.com/cloudformation-examples/aws-cfn-bootstrap-latest.tar.gz
wget https://s3.amazonaws.com/wso2logarchiever/log_archiver/log_archiver.sh
mv log_archiver.sh /usr/lib/
export ProductVersion=5.11.0
sed -i "s/Product_Version/5.11.0/g" /usr/lib/logstash-6.5.1/logstash-IS.conf
sed -i "s^secret-key^${AWSAccessKeySecret}^g" /usr/lib/logstash-6.5.1/logstash-IS.conf
sed -i "s/access-key/${AWSAccessKeyId}/g" /usr/lib/logstash-6.5.1/logstash-IS.conf
sed -i "s^ELASTICSEARCH_ENDPOINT^${ElasticSearchEndpoint}^g" /usr/lib/logstash-6.5.1/logstash-IS.conf
export INSTANCEID=$(wget -q -O - http://169.254.169.254/latest/meta-data/instance-id)
sed -i "s/INSTANCE_ID/$INSTANCEID/g" /usr/lib/logstash-6.5.1/logstash-IS.conf
sed -i "s/STACK_NAME/${AWS::StackName}/g" /usr/lib/logstash-6.5.1/logstash-IS.conf
sed -i "s/REGION_NAME/${ElasticSearchRegion}/g" /usr/lib/logstash-6.5.1/logstash-IS.conf
nohup /usr/lib/logstash-6.5.1/bin/logstash -f /usr/lib/logstash-6.5.1/logstash-IS.conf &
export PuppetmasterIP=${PuppetMaster.PrivateIp}
echo "$PuppetmasterIP puppet puppetmaster" >> /etc/hosts
service puppet restart
mkdir -p /mnt/efs
mount -t nfs4 -o nfsvers=4.1 ${WSO2ISEFSFileSystem}.efs.${AWS::Region}.amazonaws.com:/ /mnt/efs
sleep 300
export FACTER_profile=is5110
if [[ ${OperatingSystem} == "Ubuntu1804" ]]; then
puppet agent -vt >> /var/log/puppetlog.log
fi
if [[ ${OperatingSystem} == "CentOS7" ]]; then
/opt/puppetlabs/bin/puppet agent -vt >> /var/log/puppetlog.log
fi
sleep 10
if [ ! -d "/mnt/efs/server/userstores" ]; then
mkdir -p /mnt/efs/server/userstores
cp -r /usr/lib/wso2/wso2is/5.11.0/wso2is-5.11.0/repository/deployment/server/userstores /mnt/efs/userstores
fi
rm -rf /usr/lib/wso2/wso2is/5.11.0/wso2is-5.11.0/repository/deployment/server/userstores
ln -s /mnt/efs/server/userstores /usr/lib/wso2/wso2is/5.11.0/wso2is-5.11.0/repository/deployment/server/userstores
if [ ! -d "/mnt/efs/tenants" ]; then
mkdir -p /mnt/efs/tenants
cp -r /usr/lib/wso2/wso2is/5.11.0/wso2is-5.11.0/repository/tenants /mnt/efs
fi
rm -rf /usr/lib/wso2/wso2is/5.11.0/wso2is-5.11.0/repository/tenants
ln -s /mnt/efs/tenants /usr/lib/wso2/wso2is/5.11.0/wso2is-5.11.0/repository/tenants
echo "${WSO2ISEFSFileSystem}:/ /mnt/efs efs defaults,_netdev 0 0" >> /etc/fstab
/usr/lib/wso2/wso2is/5.11.0/wso2is-5.11.0/bin/wso2server.sh start
${CustomUserData}
sleep 30
if [[ ${OperatingSystem} == "Ubuntu1804" ]]; then
end=$((SECONDS+1200))
while [ $SECONDS -lt $end ] ; do
sleep 10
wget --delete-after --server-response --no-check-certificate "https://localhost:9443/carbon/admin/login.jsp"
if [ $? -eq "0" ] ; then
/usr/local/bin/cfn-signal -e $? --stack ${AWS::StackName} --resource WSO2ISNode2AutoScalingGroup --region ${AWS::Region}
break
fi
done
fi
if [[ ${OperatingSystem} == "CentOS7" ]]; then
end=$((SECONDS+1200))
while [ $SECONDS -lt $end ] ; do
sleep 10
wget --delete-after --server-response --no-check-certificate "https://localhost:9443/carbon/admin/login.jsp"
if [ $? -eq "0" ] ; then
/usr/bin/cfn-signal -e $? --stack ${AWS::StackName} --resource WSO2ISNode2AutoScalingGroup --region ${AWS::Region}
break
fi
done
fi
echo 'export HISTTIMEFORMAT="%F %T "' >> /etc/profile.d/history.sh
cat /dev/null > ~/.bash_history && history -c
DependsOn:
- WSO2ISSecurityGroup
- WSO2ISLoadBalancer
- PuppetMaster
WSO2ISNode2AutoScalingGroup:
Type: 'AWS::AutoScaling::AutoScalingGroup'
Properties:
LaunchConfigurationName: !Ref WSO2ISNode2LaunchConfiguration
DesiredCapacity: 1
MinSize: 1
MaxSize: 2
TargetGroupARNs:
- !Ref WSO2ISALBTargetGroup
VPCZoneIdentifier:
- !Ref WSO2ISPrivateSubnet2
Tags:
- Key: Name
Value: !Sub ${EnvironmentName} WSO2ISInstance2
PropagateAtLaunch: 'true'
- Key: cluster
Value: is
PropagateAtLaunch: 'true'
CreationPolicy:
ResourceSignal:
Count: 1
Timeout: PT20M
UpdatePolicy:
AutoScalingRollingUpdate:
MaxBatchSize: '2'
MinInstancesInService: '1'
PauseTime: PT10M
SuspendProcesses:
- AlarmNotification
WaitOnResourceSignals: true
DependsOn:
- WSO2ISLoadBalancer
WSO2ISLoadBalancerSecurityGroup:
Type: 'AWS::EC2::SecurityGroup'
Properties:
VpcId: !Ref WSO2ISVPC
GroupDescription: WSO2 IS ELB Security Group
SecurityGroupIngress:
- IpProtocol: tcp
FromPort: '9763'
ToPort: '9763'
CidrIp: 0.0.0.0/0
- IpProtocol: tcp
FromPort: '443'
ToPort: '443'
CidrIp: 0.0.0.0/0
- IpProtocol: tcp
FromPort: '9443'
ToPort: '9443'
CidrIp: 0.0.0.0/0
- IpProtocol: tcp
FromPort: '8243'
ToPort: '8243'
CidrIp: 0.0.0.0/0
- IpProtocol: tcp
FromPort: '8280'
ToPort: '8280'
CidrIp: 0.0.0.0/0
- IpProtocol: tcp
FromPort: '5701'
ToPort: '5701'
CidrIp: 0.0.0.0/0
SecurityGroupEgress:
- IpProtocol: tcp
FromPort: '9763'
ToPort: '9763'
CidrIp: 0.0.0.0/0
- IpProtocol: tcp
FromPort: '9443'
ToPort: '9443'
CidrIp: 0.0.0.0/0
- IpProtocol: tcp
FromPort: '443'
ToPort: '443'
CidrIp: 0.0.0.0/0
- IpProtocol: tcp
FromPort: '8243'
ToPort: '8243'
CidrIp: 0.0.0.0/0
- IpProtocol: tcp
FromPort: '8280'
ToPort: '8280'
CidrIp: 0.0.0.0/0
- IpProtocol: tcp
FromPort: '5701'
ToPort: '5701'
CidrIp: 0.0.0.0/0
Tags:
- Key: Name
Value: !Sub ${EnvironmentName} WSO2ISLoadBalancerSecurityGroup
WSO2ISLoadBalancer:
Type: AWS::ElasticLoadBalancingV2::LoadBalancer
Properties:
Name: IS
Scheme: internet-facing
Subnets:
- !Ref WSO2ISPublicSubnet1
- !Ref WSO2ISPublicSubnet2
SecurityGroups:
- !Ref WSO2ISLoadBalancerSecurityGroup
Tags:
- Key: Name
Value: !Sub ${EnvironmentName} WSO2ISLoadBalancer
WSO2ISALBTargetGroup:
Type: AWS::ElasticLoadBalancingV2::TargetGroup
Properties:
HealthCheckIntervalSeconds: 10
HealthCheckProtocol: HTTPS
HealthCheckTimeoutSeconds: 5
HealthyThresholdCount: 4
HealthCheckPath: /carbon/admin/login.jsp
HealthCheckPort: 9443
Matcher:
HttpCode: 200
Name: is-carbon-9443
Port: 9443
Protocol: HTTPS
TargetGroupAttributes:
- Key: deregistration_delay.timeout_seconds
Value: '20'
- Key: stickiness.enabled
Value: 'true'
UnhealthyThresholdCount: 3
VpcId:
Ref: WSO2ISVPC
Tags:
- Key: Name
Value: !Sub ${EnvironmentName} WSO2ISALBTargetGroup
WSO2ISALBListener:
Type: AWS::ElasticLoadBalancingV2::Listener
Properties:
DefaultActions:
- Type: forward
TargetGroupArn: !Ref WSO2ISALBTargetGroup
Certificates:
- CertificateArn: !Join
- ''
- - 'arn:aws:iam::'
- !Ref 'AWS::AccountId'
- ':server-certificate'
- /
- !Ref CertificateName
LoadBalancerArn: !Ref WSO2ISLoadBalancer
Port: 443
Protocol: HTTPS
SslPolicy: ELBSecurityPolicy-TLS-1-1-2017-01
DependsOn:
- WSO2ISLoadBalancerSecurityGroup
Outputs:
MgtConsoleUrl:
Value: !Join
- ''
- - 'https://'
- !GetAtt
- WSO2ISLoadBalancer
- DNSName
- '/carbon'
Description: Identity Server Management Console URL
CarbonServerUrl:
Value: !Join
- ''
- - 'https://'
- !GetAtt
- WSO2ISLoadBalancer
- DNSName
- '/services'
Description: Carbon Server URL
MyAccountUrl:
Value: !Join
- ''
- - 'https://'
- !GetAtt
- WSO2ISLoadBalancer
- DNSName
- '/myaccount'
Description: My Account URL
ConsoleUrl:
Value: !Join
- ''
- - 'https://'
- !GetAtt
- WSO2ISLoadBalancer
- DNSName
- '/console'
Description: Console URL
ISHttpUrl:
Value: !Join
- ''
- - 'http://'
- !GetAtt
- WSO2ISLoadBalancer
- DNSName
- ':80'
Description: IS HTTP Gateway endpoint
ISHttpsUrl:
Value: !Join
- ''
- - 'https://'
- !GetAtt
- WSO2ISLoadBalancer
- DNSName
- ':443'
Description: IS HTTPS Gateway endpoint
Parameters:
AWSAccessKeyId:
Type: String
AWSAccessKeySecret:
Type: String
KeyPairName:
Description: >-
The private key used to log in to instances through SSH
Type: 'AWS::EC2::KeyPair::KeyName'
CertificateName:
Description: A valid SSL certificate used for HTTPS
Type: String
MinLength: 1
WSO2InstanceType:
Type: String
Default: t2.medium
AllowedValues:
- t2.medium
- t2.large
- t2.xlarge
- t2.2xlarge
- m3.medium
- m3.large
- m3.xlarge
- m3.2xlarge
- m4.large
ConstraintDescription: Must be a valid EC2 instance type
CustomUserData:
Type: String
Default: "echo"
JDK:
Description: Choose preferred JDK from the list
Type: String
Default: "OPEN_JDK8"
AllowedValues:
- "OPEN_JDK8"
- "ORACLE_JDK8"
- "CORRETTO_JDK8"
- "ADOPT_OPEN_JDK11"
ElasticSearchEndpoint:
Description: If you have ElasticSearch endpoint to publish logs, else keep this empty
Type: String
Default: ""
EnvironmentName:
Description: An environment name that is prefixed to resource names
Type: String
Default: Dev
WSO2ISDBInstanceEndpointAddress:
Type: String
WSO2ISDBInstanceEndpointPort:
Type: String
DBUsername:
Type: String
MinLength: 4
AllowedPattern: '[A-Za-z0-9\-]+'
DBPassword:
Type: String
MinLength: 8
NoEcho: true
DB:
Description: Choose preferred Database from the list
Type: String
Default: MySQL-5.7
AllowedValues:
- MySQL-5.7
- Postgres-9.6
- Postgres-10.5
- Oracle-SE1-11.2
- Oracle-SE2-12.1
- SQLServer-SE-13.00
- SQLServer-SE-14.00
OperatingSystem:
Type: String
Default: Ubuntu1804
AllowedValues:
- Ubuntu1804
- CentOS7
ElasticSearchRegion:
Type: String
Default: "us-east-1"
AllowedValues:
- "us-east-1"
- "us-east-2"
- "us-west-1"
- "us-west-2"
- "ap-southeast-2"
- "eu-west-1"
WSO2ISVPC:
Type: AWS::EC2::VPC::Id
Description: VPC ID of your existing Virtual Private Cloud (VPC)
WSO2ISPrivateSubnet1:
Type: AWS::EC2::Subnet::Id
Description: Private Subnet for PuppetMaster, Prodcut Instance, EFS and the DB
WSO2ISPrivateSubnet2:
Type: AWS::EC2::Subnet::Id
Description: Private Subnet for Prodcut Instance and the DB
WSO2ISPublicSubnet1:
Type: AWS::EC2::Subnet::Id
Description: Public Subnet for NAT Gateway, Bastion Instance and Load Balancer
WSO2ISPublicSubnet2:
Type: AWS::EC2::Subnet::Id
Description: Public Subnet for Load Balancer
Mappings:
WSO2PuppetMasterRegionMap:
ap-southeast-2:
Ubuntu1804: ami-09b869981fbea67bb
eu-west-1:
Ubuntu1804: ami-054867ed960d0375d
us-east-1:
Ubuntu1804: ami-05e85c71f3ba10e9b
us-east-2:
Ubuntu1804: ami-0a2fa0ae50487b9c1
us-west-1:
Ubuntu1804: ami-089b8e786f95a931a
us-west-2:
Ubuntu1804: ami-01d34896c82581270
WSO2ISAMIRegionMap:
ap-southeast-2:
CentOS7: ami-0211f0ecd0e693937
Ubuntu1804: ami-0fc37bfc486b80d6d
eu-west-1:
CentOS7: ami-08137d567f9e9413e