-
Notifications
You must be signed in to change notification settings - Fork 1
/
oc-cf-template.yml
212 lines (210 loc) · 6.39 KB
/
oc-cf-template.yml
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
AWSTemplateFormatVersion: "2010-09-09"
Description: Deploys opencravat software and full complement of annotators on separate volume, takes in 2 files and processes based on parameters in YML file
Parameters:
InstanceType:
Type: String
Description: 'The default, m5.2xlarge, should be fine unless you have millions of RSIDs'
AllowedValues:
- m5.large
- m5.xlarge
- m5.2xlarge
- m5.4xlarge
- m5.8xlarge
ConstraintDescription: 'Valid instance type in m5 family which will appropriately handle workload'
Default: m5.2xlarge
ImageId:
Type: 'AWS::EC2::Image::Id'
Description: >-
OpenCRAVAT AMI with all modules installed.
Default: ami-0894930d2a802712f
VpcId:
Type: 'AWS::EC2::VPC::Id'
Description: Any should work, we just can't pick this for you!
OCS3Bucket:
Type: String
Description: 'Name of your s3 bucket, ex. "haplocravat2". If your files are nested inside the bucket ex. "haplocravat2/files/", append the full path after the bucket name. No need to add any protocol such as s3://'
OCInputFile:
Type: String
Description: "List of rsIDs or VCF file"
OCYMLFile:
Type: String
Description: >-
Your YML File to control the OC Run. Be sure this has been uploaded to the S3 bucket
KeyPair:
Type: 'AWS::EC2::KeyPair::KeyName'
Description: Amazon EC2 Key Pair
Default: 0
SubnetId:
Type: 'AWS::EC2::Subnet::Id'
Description: >-
Subnet ID your instance will launch in. Should be Internet accessible for
the purposes of this demo.
Metadata:
AWS::CloudFormation::Interface:
ParameterGroups:
-
Label:
default: "Bucket Configuration"
Parameters:
- OCS3Bucket
-
Label:
default: "Input File Configuration"
Parameters:
- OCInputFile
- OCYMLFile
-
Label:
default: "Run Size Configuration"
Parameters:
- InstanceType
-
Label:
default: "Amazon EC2 Configuration Specifics"
Parameters:
- ImageId
- KeyPair
- VpcId
- SubnetId
ParameterLabels:
VpcId:
default: "Which VPC should this be deployed to?"
OCS3Bucket:
default: "Your S3 Bucket"
OCYMLFile:
default: "Your configuration file"
OCInputFile:
default: "Your input file"
InstanceType:
default: "What size instance do you need?"
ImageId:
default: "Select the correct AMI"
KeyPair:
default: "Which of your Amazon keys do you want to use?"
SubnetId:
default: "Select one of your subnets for the computation"
Resources:
OCS3ReadProfile:
DependsOn: OCS3ReadRole
Type: 'AWS::IAM::InstanceProfile'
Properties:
Path: "/"
Roles:
#- OCS3ReadRole
- !Ref OCS3ReadRole
OCS3ReadPolicy:
Type: 'AWS::IAM::Policy'
Properties:
PolicyName: !Join
- "-"
- - "name"
- !Select
- 0
- !Split
- "-"
- !Select
- 2
- !Split
- "/"
- !Ref "AWS::StackId"
PolicyDocument:
Version: "2012-10-17"
Statement:
- Effect: Allow
Action:
- 's3:ListBucket'
Resource:
- !Sub 'arn:aws:s3:::${OCS3Bucket}'
- Effect: Allow
Action:
- 's3:PutObject'
- 's3:GetObject'
- 's3:DeleteObject'
Resource:
- !Sub 'arn:aws:s3:::${OCS3Bucket}/*'
Roles:
- !Ref OCS3ReadRole
OCS3ReadRole:
Type: 'AWS::IAM::Role'
Properties:
RoleName: !Join
- "-"
- - "name"
- !Select
- 0
- !Split
- "-"
- !Select
- 2
- !Split
- "/"
- !Ref "AWS::StackId"
AssumeRolePolicyDocument:
Version: "2012-10-17"
Statement:
- Effect: Allow
Principal:
Service:
- ec2.amazonaws.com
Action:
- 'sts:AssumeRole'
OCEC2SecurityGroup:
Type: 'AWS::EC2::SecurityGroup'
Properties:
SecurityGroupIngress:
- CidrIp: 0.0.0.0/0
FromPort: 22
ToPort: 22
IpProtocol: tcp
- CidrIp: 0.0.0.0/0
FromPort: 8060
ToPort: 8060
IpProtocol: tcp
GroupDescription: SSH access for TS and cravat-view ports
VpcId: !Ref VpcId
OCNetworkInterface:
Type: 'AWS::EC2::NetworkInterface'
Properties:
SubnetId: !Ref SubnetId
Description: Interface for OC Machine
GroupSet:
- !Ref OCEC2SecurityGroup
SourceDestCheck: true
OCEC2Instance:
Type: 'AWS::EC2::Instance'
DependsOn: OCS3ReadProfile
Properties:
ImageId: !Ref ImageId
InstanceType: !Ref InstanceType
KeyName: !Ref KeyPair
NetworkInterfaces:
- NetworkInterfaceId: !Ref OCNetworkInterface
DeviceIndex: 0
Tags:
- Key: Name
Value: OpenCravat-Machine
IamInstanceProfile: !Ref OCS3ReadProfile
UserData:
'Fn::Base64': !Sub |
#!/bin/bash
# Download the source files to the local machine
cd /tmp
aws s3 cp s3://${OCS3Bucket}/${OCInputFile} .
aws s3 cp s3://${OCS3Bucket}/${OCYMLFile} .
#Establish some time stamping
stamp=`date +%s`
# Run the cravat command based on parameters in YAML file
cravat /tmp/${OCInputFile} -c /tmp/${OCYMLFile} 2>&1 | tee OCrun-$stamp-commandout.txt
# Upload the sqlite output and log file to s3 using s3cmd
aws s3api put-object --bucket ${OCS3Bucket} --key ${OCInputFile}-$stamp/
aws s3 cp ${OCInputFile}.sqlite s3://${OCS3Bucket}/${OCInputFile}-$stamp/
aws s3 cp ${OCInputFile}.log s3://${OCS3Bucket}/${OCInputFile}-$stamp/
aws s3 cp ${OCInputFile}.err s3://${OCS3Bucket}/${OCInputFile}-$stamp/
aws s3 cp OCrun-$stamp-commandout.txt s3://${OCS3Bucket}/${OCInputFile}-$stamp/
# Wait 1 minute just to make sure the uploads complete
sleep 60
# Shut the instance down
/sbin/shutdown -h now
Outputs:
PublicIp:
Value: !GetAtt OCEC2Instance.PublicIp