-
Notifications
You must be signed in to change notification settings - Fork 1
/
oc-cf-template-original.yml
166 lines (166 loc) · 5.19 KB
/
oc-cf-template-original.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
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: Instance type for OpenCravat run. Default is m5.2xlarge.
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: >-
Pre-built image id, centos with extra disks
#Default: ami-0d0d81bd434795b20
Default: ami-032104653c3315aca
VpcId:
Type: 'AWS::EC2::VPC::Id'
Description: VPC this server will reside in
OCInputFile:
Type: String
Description: Your data file
OCYMLFile:
Type: String
Description: >-
Your YML File to control the OC Run. Be sure this has been uploaded to the S3 bucket
OCS3Bucket:
Type: String
Description: Name of the S3 bucket for your source files and output file. If your files are nested in a "directory", append the full path after the bucket name.
KeyPair:
Type: 'AWS::EC2::KeyPair::KeyName'
Description: Amazon EC2 Key Pair
SubnetId:
Type: 'AWS::EC2::Subnet::Id'
Description: >-
Subnet ID your instance will launch in. Should be Internet accessible for
the purposes of this demo.
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