Skip to content

Commit 42da60a

Browse files
authored
Merge pull request #816 from kasunbg/run-intg-tests
Provides AWS infrastructure provisioning scripts for APIM integration test jobs
2 parents f930e17 + 5ded812 commit 42da60a

File tree

1 file changed

+343
-0
lines changed

1 file changed

+343
-0
lines changed
Lines changed: 343 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,343 @@
1+
AWSTemplateFormatVersion: 2010-09-09
2+
Description: AWS CloudFormation Template with an EC2 instance and a RDS
3+
Parameters:
4+
AMI:
5+
Type: String
6+
Description: AMI of the region.
7+
DBEngine:
8+
Type: String
9+
Default: mysql
10+
Description: Database Engine
11+
AllowedValues:
12+
- mysql
13+
- postgres
14+
- mariadb
15+
- sqlserver-ex
16+
- sqlserver-ee
17+
- sqlserver-se
18+
- sqlserver-web
19+
- oracle-se
20+
- oracle-se2
21+
- oracle-ee
22+
- oracle-se1
23+
DBEngineVersion:
24+
Type: String
25+
Description: Database Engine version
26+
MinLength: 1
27+
DBUsername:
28+
Type: String
29+
Default: wso2carbon
30+
Description: Database master account username
31+
MinLength: 1
32+
MaxLength: 20
33+
ConstraintDescription: 'minimum - 1, maximum - 20 characters'
34+
DBPassword:
35+
Type: String
36+
NoEcho: true
37+
Description: Database master account password
38+
MinLength: 6
39+
ConstraintDescription: minimum - 6 characters
40+
DBClass:
41+
Default: db.t2.micro
42+
Description: Database instance class
43+
Type: String
44+
AllowedValues:
45+
- db.t2.micro
46+
- db.t2.small
47+
- db.t2.medium
48+
- db.t2.large
49+
- db.t2.xlarge
50+
- db.t2.2xlarge
51+
- db.m4.large
52+
- db.m4.xlarge
53+
- db.m4.2xlarge
54+
ConstraintDescription: must be a valid database instance type
55+
DBAllocatedStorage:
56+
Default: 20
57+
Description: Size of the database (GB)
58+
Type: Number
59+
MinValue: 20
60+
MaxValue: 6144
61+
ConstraintDescription: 'minimum - 20 GB, maximum - 6144 GB'
62+
EC2KeyPair:
63+
Description: >-
64+
This is used to ssh to the node. If you don't have a key, please create
65+
one from AWS console and rerun the script
66+
Type: 'AWS::EC2::KeyPair::KeyName'
67+
ALBCertificateARN:
68+
Type: String
69+
Description: >-
70+
Enter the ARN value of the certificate uploaded to ACM for Application
71+
Load Balancers
72+
WSO2InstanceType:
73+
Description: 'EC2 instance type of the WSO2 EI Node [t2.micro is the free tier]'
74+
Type: String
75+
Default: m4.large
76+
AllowedValues:
77+
- t2.nano
78+
- t1.micro
79+
- t2.micro
80+
- t2.small
81+
- t2.medium
82+
- t2.large
83+
- t2.xlarge
84+
- t2.2xlarge
85+
- m3.medium
86+
- m3.large
87+
- m3.xlarge
88+
- m3.2xlarge
89+
- m4.large
90+
ConstraintDescription: must be a valid EC2 instance type
91+
WUMUsername:
92+
Type: String
93+
Default: ''
94+
Description: Enter WUM user name
95+
WUMPassword:
96+
Type: String
97+
Default: ''
98+
NoEcho: true
99+
Description: >-
100+
Enter WUM user password to get the updated WSO2 products deployed. If not
101+
provided standard released pack will be deployed
102+
ProductName:
103+
Type: String
104+
Default: wso2apim
105+
Description: Enter product name
106+
ProductVersion:
107+
Type: String
108+
Default: 2.2.0
109+
Description: Enter product version
110+
OS:
111+
Type: String
112+
Default: ubuntu
113+
Description: >-
114+
Enter target OS. This will be the username of the created EC2 instances as
115+
well.
116+
OSVersion:
117+
Type: String
118+
Default: '16.04'
119+
Description: Enter target OS version.
120+
JDK:
121+
Type: String
122+
Default: ORACLE_JDK8
123+
Description: Enter target JDK version.
124+
AllowedValues:
125+
- OPEN_JDK8
126+
- ORACLE_JDK8
127+
Resources:
128+
WSO2InstanceSecurityGroup:
129+
Type: 'AWS::EC2::SecurityGroup'
130+
Properties:
131+
GroupDescription: Security group for IS EC2 compute instances
132+
SecurityGroupIngress:
133+
- IpProtocol: tcp
134+
FromPort: 22
135+
ToPort: 22
136+
CidrIp: 0.0.0.0/0
137+
- IpProtocol: tcp
138+
FromPort: 8140
139+
ToPort: 8140
140+
CidrIp: 0.0.0.0/0
141+
- IpProtocol: tcp
142+
FromPort: 9763
143+
ToPort: 9763
144+
CidrIp: 0.0.0.0/0
145+
- IpProtocol: tcp
146+
FromPort: 9443
147+
ToPort: 9443
148+
CidrIp: 0.0.0.0/0
149+
Metadata:
150+
'AWS::CloudFormation::Designer':
151+
id: abbdb5e8-f28b-4bc6-8b63-da9595b59c4a
152+
WSO2EnvDBSecurityGroup:
153+
Type: 'AWS::EC2::SecurityGroup'
154+
Properties:
155+
GroupDescription: Security group for RDS
156+
SecurityGroupIngress:
157+
- IpProtocol: tcp
158+
FromPort: 3306
159+
ToPort: 3306
160+
SourceSecurityGroupName: !Ref WSO2InstanceSecurityGroup
161+
- IpProtocol: tcp
162+
FromPort: 5432
163+
ToPort: 5432
164+
SourceSecurityGroupName: !Ref WSO2InstanceSecurityGroup
165+
- IpProtocol: tcp
166+
FromPort: 1433
167+
ToPort: 1433
168+
SourceSecurityGroupName: !Ref WSO2InstanceSecurityGroup
169+
- IpProtocol: tcp
170+
FromPort: 1521
171+
ToPort: 1521
172+
SourceSecurityGroupName: !Ref WSO2InstanceSecurityGroup
173+
Metadata:
174+
'AWS::CloudFormation::Designer':
175+
id: d0dcc88f-97f7-4d80-901a-f746d372a295
176+
WSO2Instance:
177+
Type: 'AWS::EC2::Instance'
178+
DependsOn:
179+
- WSO2DBInstance
180+
Properties:
181+
DisableApiTermination: 'false'
182+
InstanceInitiatedShutdownBehavior: stop
183+
ImageId: !Ref AMI
184+
InstanceType: !Ref WSO2InstanceType
185+
KeyName: !Ref EC2KeyPair
186+
Monitoring: 'false'
187+
"BlockDeviceMappings" : [
188+
{
189+
"DeviceName" : "/dev/sda1",
190+
"Ebs" : { "VolumeSize" : "50" }
191+
},
192+
]
193+
UserData: !Base64
194+
'Fn::Sub': |
195+
#!/bin/bash
196+
set -e
197+
set -o xtrace
198+
199+
setup_java_env() {
200+
source /etc/environment
201+
202+
echo JDK_PARAM=${JDK} >> /opt/wso2/java.txt
203+
REQUESTED_JDK_PRESENT=$(grep "^${JDK}=" /etc/environment | wc -l)
204+
if [ $REQUESTED_JDK_PRESENT = 0 ]; then
205+
printf "The requested JDK, ${JDK}, not found in /etc/environment: \n $(cat /etc/environment)."
206+
exit 1; // todo: inform via cfn-signal
207+
fi
208+
JAVA_HOME=$(grep "^${JDK}=" /etc/environment | head -1 | sed "s:${JDK}=\(.*\):\1:g" | sed 's:"::g')
209+
210+
echo ">> Setting up JAVA_HOME ..."
211+
JAVA_HOME_EXISTS=$(grep -r "JAVA_HOME=" /etc/environment | wc -l )
212+
if [ $JAVA_HOME_EXISTS = 0 ]; then
213+
echo ">> Adding JAVA_HOME entry."
214+
echo JAVA_HOME=$JAVA_HOME >> /etc/environment
215+
else
216+
echo ">> Updating JAVA_HOME entry."
217+
sed -i "/JAVA_HOME=/c\JAVA_HOME=$JAVA_HOME" /etc/environment
218+
fi
219+
source /etc/environment
220+
221+
echo "export JAVA_HOME=$JAVA_HOME" >> /etc/profile
222+
source /etc/profile
223+
}
224+
225+
apt-get -y install git
226+
mkdir -p /opt/wso2
227+
cd /opt/wso2
228+
229+
setup_java_env
230+
echo "Installing Apache Maven"
231+
wget https://archive.apache.org/dist/maven/maven-3/3.3.9/binaries/apache-maven-3.3.9-bin.tar.gz
232+
tar -xvzf apache-maven-3.3.9-bin.tar.gz
233+
ln -fs apache-maven-3.3.9 maven
234+
export MAVEN_OPTS="-Xmx2048m -Xms256m"
235+
export PATH=/opt/wso2/maven/bin/:$PATH
236+
237+
# echo "Cloning and running product-apim"
238+
# git clone --branch v2.2.0-update7 http://github.com/wso2/product-apim.git
239+
# cd product-apim
240+
# mvn clean install
241+
242+
apt-get --purge remove -y git
243+
cat /dev/null > ~/.bash_history && history -c
244+
Tags:
245+
- Key: Name
246+
Value: wso2-apim-intg-node
247+
SecurityGroups:
248+
- !Ref WSO2InstanceSecurityGroup
249+
Metadata:
250+
'AWS::CloudFormation::Designer':
251+
id: 8f512cce-69ee-45de-87ab-5aedd2a93d50
252+
"AWS::CloudFormation::Init" : {
253+
"config" : {
254+
"packages" : {
255+
"apt" : {
256+
}
257+
},
258+
"sources" : {
259+
},
260+
"files" : {
261+
}
262+
}
263+
}
264+
WSO2DBInstance:
265+
Type: 'AWS::RDS::DBInstance'
266+
Properties:
267+
AllocatedStorage: !Ref DBAllocatedStorage
268+
DBInstanceClass: !Ref DBClass
269+
Engine: !Ref DBEngine
270+
EngineVersion: !Ref DBEngineVersion
271+
DBInstanceIdentifier: !Join
272+
- ''
273+
- - !Ref 'AWS::StackName'
274+
- '-wso2-dbinstance'
275+
MasterUsername: !Ref DBUsername
276+
MasterUserPassword: !Ref DBPassword
277+
AutoMinorVersionUpgrade: false
278+
BackupRetentionPeriod: 0
279+
VPCSecurityGroups:
280+
- !GetAtt WSO2EnvDBSecurityGroup.GroupId
281+
AvailabilityZone: !Select
282+
- '0'
283+
- !GetAZs ''
284+
Metadata:
285+
'AWS::CloudFormation::Designer':
286+
id: 5352b4e9-46ed-4a23-8bdc-bafc3666cbbd
287+
Outputs:
288+
WSO2MgtConsoleURL:
289+
Value: !Sub 'https://${WSO2Instance.PublicDnsName}:9443/carbon'
290+
Description: Access URL of the Management Console
291+
WSO2PublicIP:
292+
Value: !Sub '${WSO2Instance.PublicIp}'
293+
Description: Private IP of the WSO2 IS Instance
294+
DatabaseHost:
295+
Value: !Sub '${WSO2DBInstance.Endpoint.Address}'
296+
Description: Database Host
297+
DatabasePort:
298+
Value: !Sub '${WSO2DBInstance.Endpoint.Port}'
299+
Description: Database Port
300+
Metadata:
301+
'AWS::CloudFormation::Designer':
302+
abbdb5e8-f28b-4bc6-8b63-da9595b59c4a:
303+
size:
304+
width: 60
305+
height: 60
306+
position:
307+
x: 60
308+
'y': 90
309+
z: 1
310+
embeds: []
311+
d0dcc88f-97f7-4d80-901a-f746d372a295:
312+
size:
313+
width: 60
314+
height: 60
315+
position:
316+
x: -80
317+
'y': 210
318+
z: 1
319+
embeds: []
320+
5352b4e9-46ed-4a23-8bdc-bafc3666cbbd:
321+
size:
322+
width: 60
323+
height: 60
324+
position:
325+
x: 60
326+
'y': 210
327+
z: 1
328+
embeds: []
329+
isassociatedwith:
330+
- d0dcc88f-97f7-4d80-901a-f746d372a295
331+
8f512cce-69ee-45de-87ab-5aedd2a93d50:
332+
size:
333+
width: 60
334+
height: 60
335+
position:
336+
x: 180
337+
'y': 210
338+
z: 1
339+
embeds: []
340+
isassociatedwith:
341+
- abbdb5e8-f28b-4bc6-8b63-da9595b59c4a
342+
dependson:
343+
- 5352b4e9-46ed-4a23-8bdc-bafc3666cbbd

0 commit comments

Comments
 (0)