Skip to content

Commit 011d542

Browse files
authored
Merge pull request #87 from RLOpenCatalyst/topic-release
Added cost_resource tag to all standard catalog
2 parents 7fe0168 + fb839d8 commit 011d542

10 files changed

Lines changed: 184 additions & 6 deletions

cft-templates/Rstudio.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,11 +98,14 @@ Resources:
9898
SecurityGroups: [!Ref 'RstudioEC2SecurityGroup']
9999
KeyName: !Ref 'KeyPair'
100100
IamInstanceProfile: !Ref InstanceProfile
101+
PropagateTagsToVolumeOnCreation: true
101102
Tags:
102103
- Key: Name
103104
Value: !Join ['-', [Ref: Namespace, 'rstudio-server']]
104105
- Key: Description
105106
Value: EC2 linux based Rstudio server
107+
- Key: cost_resource
108+
Value: !Sub ${AWS::StackName}
106109
UserData:
107110
Fn::Base64: !Sub |
108111
#!/bin/bash

cft-templates/cromwell-advanced.yaml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,16 @@ Resources:
127127
Value: !Ref ResearcherName
128128
- Key: project_name
129129
Value: !Ref ProjectId
130+
- ResourceType: volume
131+
Tags:
132+
- Key: cost_resource
133+
Value: !Sub ${AWS::StackName}
134+
- Key: Name
135+
Value: !Join ['-', [Ref: Namespace, 'cromwell-work-node']]
136+
- Key: researcher_name
137+
Value: !Ref ResearcherName
138+
- Key: project_name
139+
Value: !Ref ProjectId
130140
BlockDeviceMappings:
131141
- Ebs:
132142
DeleteOnTermination: True

cft-templates/ec2-EIP.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,11 +94,14 @@ Resources:
9494
KeyName: !Ref 'KeyPair'
9595
ImageId: !Ref 'LatestAmiId'
9696
IamInstanceProfile: !Ref InstanceProfile
97+
PropagateTagsToVolumeOnCreation: true
9798
Tags:
9899
- Key: Name
99100
Value: !Join ['-', [Ref: Namespace, 'ec2-linux']]
100101
- Key: Description
101102
Value: EC2 workspace instance
103+
- Key: cost_resource
104+
Value: !Sub ${AWS::StackName}
102105

103106
InstanceSecurityGroup:
104107
Type: AWS::EC2::SecurityGroup

cft-templates/ec2-linux-docker-mysql.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,11 +137,14 @@ Resources:
137137
KeyName: !Ref 'KeyPair'
138138
ImageId: !Ref 'LatestAmiId'
139139
IamInstanceProfile: !Ref InstanceProfile
140+
PropagateTagsToVolumeOnCreation: true
140141
Tags:
141142
- Key: Name
142143
Value: !Join ['-', [Ref: Namespace, 'ec2-linux']]
143144
- Key: Description
144145
Value: EC2 workspace instance
146+
- Key: cost_resource
147+
Value: !Sub ${AWS::StackName}
145148

146149
InstanceSecurityGroup:
147150
Type: AWS::EC2::SecurityGroup

cft-templates/ec2-linux-docker.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,12 +104,15 @@ Resources:
104104
SecurityGroups: [!Ref 'InstanceSecurityGroup']
105105
KeyName: !Ref 'KeyPair'
106106
ImageId: !Ref 'LatestAmiId'
107+
PropagateTagsToVolumeOnCreation: true
107108
IamInstanceProfile: !Ref InstanceProfile
108109
Tags:
109110
- Key: Name
110111
Value: !Join ['-', [Ref: Namespace, 'ec2-linux']]
111112
- Key: Description
112113
Value: EC2 workspace instance
114+
- Key: cost_resource
115+
Value: !Sub ${AWS::StackName}
113116

114117
InstanceSecurityGroup:
115118
Type: AWS::EC2::SecurityGroup
Lines changed: 129 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,129 @@
1+
Metadata:
2+
License: Apache-2.0
3+
AWSTemplateFormatVersion: '2010-09-09'
4+
Description: 'AWS CloudFormation Template to create an EC2 instance
5+
**WARNING** This template creates an Amazon EC2 instance.
6+
You will be billed for the AWS resources used if you create a stack from this template.'
7+
8+
Parameters:
9+
Namespace:
10+
Type: String
11+
Description: An environment name that will be prefixed to resource names
12+
S3Mounts:
13+
Type: String
14+
Description: A JSON array of objects with name, bucket, and prefix properties used to mount data
15+
IamPolicyDocument:
16+
Type: String
17+
Description: The IAM policy to be associated with the launched workstation
18+
EnvironmentInstanceFiles:
19+
Type: String
20+
Description: >-
21+
An S3 URI (starting with "s3://") that specifies the location of files to be copied to
22+
the environment instance, including any bootstrap scripts
23+
InstanceType:
24+
Description: Choose the instance type for this instance. e.g. t2.small
25+
Type: String
26+
Default: t2.small
27+
AllowedValues: [t2.nano, t2.micro, t2.small, t2.medium]
28+
ConstraintDescription: must be a valid EC2 instance type.
29+
KeyPair:
30+
Description: Name of an existing EC2 KeyPair to enable SSH access to the instance. If no key pairs exist, please create one from the button next to the dropdown. Please contact your Administrator if you are unable to create one.
31+
Type: AWS::EC2::KeyPair::KeyName
32+
ConstraintDescription: must be the name of an existing EC2 KeyPair.
33+
AllowedSSHLocation:
34+
Description: The IP address range that can be used to SSH to the EC2 instances
35+
Type: String
36+
MinLength: '9'
37+
MaxLength: '18'
38+
Default: 0.0.0.0/0
39+
AllowedPattern: (\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})/(\d{1,2})
40+
ConstraintDescription: must be a valid IP CIDR range of the form x.x.x.x/x.
41+
LatestAmiId:
42+
Description: Enter an AMI-Id e.g. ami-12345. The AMI should exist in the same region as the project. Leave the default string to use the latest Canonical Ubuntu 20.04 image.
43+
Type: String
44+
Default: '/aws/service/canonical/ubuntu/server/20.04/stable/current/amd64/hvm/ebs-gp2/ami-id'
45+
46+
Conditions:
47+
IamPolicyEmpty: !Equals [!Ref IamPolicyDocument, '{}']
48+
UserProvidedAMI: !Equals [ 'ami', !Select [0, !Split ["-", !Ref LatestAmiId]]]
49+
50+
Resources:
51+
IAMRole:
52+
Type: 'AWS::IAM::Role'
53+
Properties:
54+
RoleName: !Join ['-', [Ref: Namespace, 'ec2-role']]
55+
Path: '/'
56+
AssumeRolePolicyDocument:
57+
Version: '2012-10-17'
58+
Statement:
59+
- Effect: 'Allow'
60+
Principal:
61+
Service:
62+
- 'ec2.amazonaws.com'
63+
Action:
64+
- 'sts:AssumeRole'
65+
Policies:
66+
- !If
67+
- IamPolicyEmpty
68+
- !Ref 'AWS::NoValue'
69+
- PolicyName: !Join ['-', [Ref: Namespace, 's3-studydata-policy']]
70+
PolicyDocument: !Ref IamPolicyDocument
71+
72+
InstanceProfile:
73+
Type: 'AWS::IAM::InstanceProfile'
74+
Properties:
75+
InstanceProfileName: !Join ['-', [Ref: Namespace, 'ec2-profile']]
76+
Path: '/'
77+
Roles:
78+
- Ref: IAMRole
79+
80+
EC2Instance:
81+
Type: AWS::EC2::Instance
82+
Properties:
83+
UserData:
84+
Fn::Base64: !Sub |
85+
#!/usr/bin/env bash
86+
exec > >(tee /var/log/user-data.log|logger -t user-data -s 2>/dev/console) 2>&1
87+
apt update
88+
apt install -y awscli jq
89+
# Download and execute bootstrap script
90+
aws s3 cp "${EnvironmentInstanceFiles}/get_bootstrap_ubuntu.sh" "/tmp"
91+
chmod 500 "/tmp/get_bootstrap_ubuntu.sh"
92+
/tmp/get_bootstrap_ubuntu.sh "${EnvironmentInstanceFiles}" '${S3Mounts}'
93+
94+
# Signal result to CloudFormation
95+
/opt/aws/bin/cfn-signal -e $? --stack "${AWS::StackName}" --resource "EC2Instance" --region "${AWS::Region}"
96+
InstanceType: !Ref 'InstanceType'
97+
SecurityGroups: [!Ref 'InstanceSecurityGroup']
98+
KeyName: !Ref 'KeyPair'
99+
ImageId: !If [ UserProvidedAMI,!Ref LatestAmiId,'{{resolve:ssm:/aws/service/canonical/ubuntu/server/20.04/stable/current/amd64/hvm/ebs-gp2/ami-id}}']
100+
IamInstanceProfile: !Ref InstanceProfile
101+
PropagateTagsToVolumeOnCreation: true
102+
Tags:
103+
- Key: Name
104+
Value: !Join ['-', [Ref: Namespace, 'ec2-linux']]
105+
- Key: Description
106+
Value: EC2 workspace instance
107+
- Key: cost_resource
108+
Value: !Sub ${AWS::StackName}
109+
110+
InstanceSecurityGroup:
111+
Type: AWS::EC2::SecurityGroup
112+
Properties:
113+
GroupDescription: Enable SSH access
114+
SecurityGroupIngress:
115+
- IpProtocol: tcp
116+
FromPort: '22'
117+
ToPort: '22'
118+
CidrIp: !Ref 'AllowedSSHLocation'
119+
120+
Outputs:
121+
InstanceId:
122+
Description: InstanceId of the newly created EC2 instance
123+
Value: !Ref 'EC2Instance'
124+
InstanceIPAddress:
125+
Description: IP address of the newly created EC2 instance
126+
Value: !GetAtt [EC2Instance, PublicIp]
127+
InstanceDNSName:
128+
Description: DNS name of the newly created EC2 instance
129+
Value: !GetAtt [EC2Instance, PublicDnsName]

cft-templates/ec2-ubuntu.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,11 +98,14 @@ Resources:
9898
KeyName: !Ref 'KeyPair'
9999
ImageId: !If [ UserProvidedAMI,!Ref LatestAmiId,'{{resolve:ssm:/aws/service/canonical/ubuntu/server/20.04/stable/current/amd64/hvm/ebs-gp2/ami-id}}']
100100
IamInstanceProfile: !Ref InstanceProfile
101+
PropagateTagsToVolumeOnCreation: true
101102
Tags:
102103
- Key: Name
103104
Value: !Join ['-', [Ref: Namespace, 'ec2-linux']]
104105
- Key: Description
105106
Value: EC2 workspace instance
107+
- Key: cost_resource
108+
Value: !Sub ${AWS::StackName}
106109

107110
InstanceSecurityGroup:
108111
Type: AWS::EC2::SecurityGroup

cft-templates/nextflow-advanced.yaml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,16 @@ Resources:
194194
Value: !Ref ResearcherName
195195
- Key: project_name
196196
Value: !Ref ProjectId
197+
- ResourceType: volume
198+
Tags:
199+
- Key: cost_resource
200+
Value: !Sub ${AWS::StackName}
201+
- Key: Name
202+
Value: !Sub worker-node-${AWS::StackName}
203+
- Key: researcher_name
204+
Value: !Ref ResearcherName
205+
- Key: project_name
206+
Value: !Ref ProjectId
197207
BlockDeviceMappings:
198208
- Ebs:
199209
DeleteOnTermination: True

cft-templates/windows-ec2.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,17 @@ Resources:
3636
Properties:
3737
UserData: !Base64
3838
InstanceType: !Ref 'InstanceType'
39+
PropagateTagsToVolumeOnCreation: true
3940
SecurityGroups: [!Ref 'InstanceSecurityGroup']
4041
KeyName: !Ref 'KeyPair'
4142
ImageId: !Ref 'LatestAmiId'
43+
Tags:
44+
- Key: Name
45+
Value: !Join ['-', [Ref: AWS::StackName, 'windows-server']]
46+
- Key: Description
47+
Value: windows workspace instance
48+
- Key: cost_resource
49+
Value: !Sub ${AWS::StackName}
4250
InstanceSecurityGroup:
4351
Type: AWS::EC2::SecurityGroup
4452
Properties:

dump/standardcatalogitems.json

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,8 @@
9898
"post_provisioning": [],
9999
"checks_before_assigning_product": [],
100100
"checks_after_assigning_product": [],
101-
"permission_required": {}
101+
"permission_required": {},
102+
"cost_resource": true
102103
}
103104
},
104105
{
@@ -157,7 +158,8 @@
157158
"post_provisioning": [],
158159
"checks_before_assigning_product": [],
159160
"checks_after_assigning_product": [],
160-
"permission_required": {}
161+
"permission_required": {},
162+
"cost_resource": true
161163
}
162164
},
163165

@@ -217,7 +219,8 @@
217219
"post_provisioning": [],
218220
"checks_before_assigning_product": [],
219221
"checks_after_assigning_product": [],
220-
"permission_required": {}
222+
"permission_required": {},
223+
"cost_resource": true
221224
}
222225
},
223226
{
@@ -350,7 +353,8 @@
350353
}
351354
],
352355
"checks_after_assigning_product": [],
353-
"permission_required": {}
356+
"permission_required": {},
357+
"cost_resource": true
354358
}
355359
},
356360
{
@@ -387,7 +391,8 @@
387391
"post_provisioning": [],
388392
"checks_before_assigning_product": [],
389393
"checks_after_assigning_product": [],
390-
"permission_required": {}
394+
"permission_required": {},
395+
"cost_resource": true
391396
}
392397
},
393398
{
@@ -448,7 +453,8 @@
448453
"checks_after_assigning_product" : [ ],
449454
"permission_required" : {
450455

451-
}
456+
},
457+
"cost_resource": true
452458
}
453459
},
454460
{

0 commit comments

Comments
 (0)