Skip to content

Commit bf353d8

Browse files
Merge pull request #5 from SanketD92/fix-version-template-update
fix: package version and template update
2 parents 366fb64 + a72aebe commit bf353d8

3 files changed

Lines changed: 79 additions & 46 deletions

File tree

RStudio/cfn-templates/ec2-rlstudio.yaml

Lines changed: 78 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -5,63 +5,87 @@ Metadata:
55
PartnerName: Relevance Lab
66
PartnerURL: https://relevancelab.com
77
KnowMore: https://github.com/RLOpenCatalyst/Service_Workbench_Templates/tree/main/RStudio
8-
8+
99
Parameters:
1010
Namespace:
1111
Type: String
1212
Description: An environment name that will be prefixed to resource names
13-
13+
SolutionNamespace:
14+
Type: String
15+
Description: The namespace value provided when onboarding the Member account
1416
AmiId:
1517
Type: String
1618
Description: Amazon Machine Image for the EC2 instance
17-
19+
IsAppStreamEnabled:
20+
Type: String
21+
AllowedValues: [true, false]
22+
Description: Is AppStream enabled for this workspace
1823
InstanceType:
1924
Type: String
2025
Description: EC2 instance type to launch
21-
2226
KeyName:
2327
Type: String
2428
Description: Keypair name for SSH access
25-
2629
AccessFromCIDRBlock:
2730
Type: String
2831
Description: The CIDR used to access the ec2 instances.
2932
Default: 0.0.0.0/0
30-
3133
S3Mounts:
3234
Type: String
3335
Description: A JSON array of objects with name, bucket, and prefix properties used to mount data
34-
3536
IamPolicyDocument:
3637
Type: String
3738
Description: The IAM policy to be associated with the launched workstation
38-
3939
VPC:
4040
Description: The VPC in which the EC2 instance will reside
4141
Type: AWS::EC2::VPC::Id
42-
43-
Subnet1:
42+
Subnet:
4443
Description: The VPC subnet in which the EC2 instance will reside
4544
Type: AWS::EC2::Subnet::Id
46-
4745
EnvironmentInstanceFiles:
4846
Type: String
4947
Description: >-
5048
An S3 URI (starting with "s3://") that specifies the location of files to be copied to
5149
the environment instance, including any bootstrap scripts
52-
5350
EncryptionKeyArn:
5451
Type: String
5552
Description: The ARN of the KMS encryption Key used to encrypt data in the instance
56-
5753
ACMSSLCertARN:
5854
Type: String
5955
Description: The ARN of the AWS Certificate Manager SSL Certificate to associate with the Load Balancer
56+
EgressStoreIamPolicyDocument:
57+
Type: String
58+
Description: The IAM policy for launched workstation to access egress store
6059

6160
Conditions:
6261
IamPolicyEmpty: !Equals [!Ref IamPolicyDocument, "{}"]
62+
EgressStoreIamPolicyEmpty: !Equals [!Ref EgressStoreIamPolicyDocument, "{}"]
63+
AppStreamEnabled: !Equals [!Ref IsAppStreamEnabled, "true"]
64+
AppStreamDisabled: !Equals [!Ref IsAppStreamEnabled, "false"]
6365

6466
Resources:
67+
InstanceRolePermissionBoundary:
68+
Type: AWS::IAM::ManagedPolicy
69+
Properties:
70+
Description: Permission boundary for EC2 instance role
71+
ManagedPolicyName:
72+
!Join ["-", [Ref: Namespace, "ec2-rstudio-permission-boundary"]]
73+
PolicyDocument:
74+
Version: "2012-10-17"
75+
Statement:
76+
- Effect: Allow
77+
Action:
78+
- "s3:*"
79+
- "ssm:*"
80+
Resource: "*"
81+
- Effect: Allow
82+
Action:
83+
- "kms:*"
84+
Resource: "*"
85+
- Effect: Allow
86+
Action:
87+
- "sts:AssumeRole"
88+
Resource: "arn:aws:iam::*:role/swb-*"
6589
IAMRole:
6690
Type: "AWS::IAM::Role"
6791
Properties:
@@ -83,6 +107,11 @@ Resources:
83107
- !Ref "AWS::NoValue"
84108
- PolicyName: !Join ["-", [Ref: Namespace, "s3-studydata-policy"]]
85109
PolicyDocument: !Ref IamPolicyDocument
110+
- !If
111+
- EgressStoreIamPolicyEmpty
112+
- !Ref "AWS::NoValue"
113+
- PolicyName: !Join ["-", [Ref: Namespace, "s3-egressstore-policy"]]
114+
PolicyDocument: !Ref EgressStoreIamPolicyDocument
86115
- PolicyName:
87116
!Join ["-", [Ref: Namespace, "s3-bootstrap-script-policy"]]
88117
PolicyDocument:
@@ -124,6 +153,7 @@ Resources:
124153
- "ssm:GetParameter"
125154
- "ssm:PutParameter"
126155
Resource: !Sub "arn:aws:ssm:${AWS::Region}:${AWS::AccountId}:parameter/*"
156+
PermissionsBoundary: !Ref InstanceRolePermissionBoundary
127157

128158
InstanceProfile:
129159
Type: "AWS::IAM::InstanceProfile"
@@ -137,27 +167,33 @@ Resources:
137167
Type: "AWS::EC2::SecurityGroup"
138168
Properties:
139169
GroupDescription: EC2 workspace security group
140-
141170
SecurityGroupEgress:
142171
- IpProtocol: tcp
143172
FromPort: 0
144173
ToPort: 65535
145174
CidrIp: 0.0.0.0/0
146-
- IpProtocol: icmp
147-
FromPort: -1
148-
ToPort: -1
149-
CidrIp: !Ref AccessFromCIDRBlock
150-
175+
- !If
176+
- AppStreamEnabled
177+
- !Ref "AWS::NoValue"
178+
- IpProtocol: icmp
179+
FromPort: -1
180+
ToPort: -1
181+
CidrIp: !Ref AccessFromCIDRBlock
151182
SecurityGroupIngress:
152-
- IpProtocol: tcp
153-
FromPort: 22
154-
ToPort: 22
155-
CidrIp: !Ref AccessFromCIDRBlock
156-
- IpProtocol: tcp
157-
FromPort: 80
158-
ToPort: 80
159-
CidrIp: !Ref AccessFromCIDRBlock
160-
183+
- !If
184+
- AppStreamEnabled
185+
- !Ref "AWS::NoValue"
186+
- IpProtocol: tcp
187+
FromPort: 22
188+
ToPort: 22
189+
CidrIp: !Ref AccessFromCIDRBlock
190+
- !If
191+
- AppStreamEnabled
192+
- !Ref "AWS::NoValue"
193+
- IpProtocol: tcp
194+
FromPort: 80
195+
ToPort: 80
196+
CidrIp: !Ref AccessFromCIDRBlock
161197
Tags:
162198
- Key: Name
163199
Value: !Join ["-", [Ref: Namespace, "ec2-sg"]]
@@ -181,11 +217,15 @@ Resources:
181217
KmsKeyId: !Ref EncryptionKeyArn
182218

183219
NetworkInterfaces:
184-
- AssociatePublicIpAddress: "true"
220+
- AssociatePublicIpAddress: !If [AppStreamEnabled, "false", "true"]
185221
DeviceIndex: "0"
186222
GroupSet:
187223
- !Ref SecurityGroup
188-
SubnetId: !Ref Subnet1
224+
- !If
225+
- AppStreamEnabled
226+
- Fn::ImportValue: !Sub "${SolutionNamespace}-WorkspaceSG"
227+
- !Ref "AWS::NoValue"
228+
SubnetId: !Ref Subnet
189229

190230
Tags:
191231
- Key: Name
@@ -195,22 +235,14 @@ Resources:
195235

196236
UserData:
197237
Fn::Base64: !Sub |
198-
199238
#!/usr/bin/env bash
200-
201239
# Download and execute bootstrap script
202-
203240
aws s3 cp "${EnvironmentInstanceFiles}/get_bootstrap.sh" "/tmp"
204-
205241
chmod 500 "/tmp/get_bootstrap.sh"
206-
207242
/tmp/get_bootstrap.sh "${EnvironmentInstanceFiles}" '${S3Mounts}'
208243

209-
210-
211244
# Signal result to CloudFormation
212-
213-
# /opt/aws/bin/cfn-signal -e $? --stack "${AWS::StackName}" --resource "EC2Instance" --region "${AWS::Region}"
245+
/opt/aws/bin/cfn-signal -e $? --stack "${AWS::StackName}" --resource "EC2Instance" --region "${AWS::Region}"
214246

215247
EC2TargetGroup:
216248
Type: AWS::ElasticLoadBalancingV2::TargetGroup
@@ -239,8 +271,13 @@ Outputs:
239271

240272
Ec2WorkspacePublicIp:
241273
Description: Public IP address of the EC2 workspace instance
274+
Condition: AppStreamDisabled
242275
Value: !GetAtt [EC2Instance, PublicIp]
243276

277+
Ec2WorkspacePrivateIp:
278+
Description: Private IP address of the EC2 workspace instance
279+
Value: !GetAtt [EC2Instance, PrivateIp]
280+
244281
Ec2WorkspaceInstanceId:
245282
Description: Instance Id for the EC2 workspace instance
246283
Value: !Ref EC2Instance
@@ -321,7 +358,7 @@ Outputs:
321358
MetaConnection1InstanceId:
322359
Description: EC2 Linux Instance Id
323360
Value: !Ref EC2Instance
324-
361+
325362
InstanceSecurityGroupId:
326363
Description: EC2 Instance Security Group Id
327364
Value: !Ref SecurityGroup
@@ -332,4 +369,4 @@ Outputs:
332369

333370
MaxCountALBDependentWorkspaces:
334371
Description: Maximum number of ALB dependent Workspaces
335-
Value: 100
372+
Value: 100

RStudio/machine-images/config/infra/files/rstudio/nginx.conf

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -84,10 +84,6 @@ http {
8484
proxy_set_body $query_string;
8585
}
8686

87-
location /auth-sign-in {
88-
return 403;
89-
}
90-
9187
}
9288

9389
}

RStudio/machine-images/config/infra/provisioners/provision-rstudio.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
sudo yum install -y gcc-7.3.* gcc-gfortran-7.3.* gcc-c++-7.3.*
55
sudo yum install -y java-1.8.0-openjdk-devel-1.8.0.*
66
sudo yum install -y readline-devel-6.2 zlib-devel-1.2.* bzip2-devel-1.0.* xz-devel-5.2.* pcre-devel-8.32
7-
sudo yum install -y libcurl-devel-7.61.* libpng-devel-1.5.* cairo-devel-1.15.* pango-devel-1.42.*
7+
sudo yum install -y libcurl-devel-7.76.1 libpng-devel-1.5.* cairo-devel-1.15.* pango-devel-1.42.*
88
sudo yum install -y xorg-x11-server-devel-1.20.* libX11-devel-1.6.* libXt-devel-1.1.*
99

1010
# Install R from source (https://docs.rstudio.com/resources/install-r-source/)

0 commit comments

Comments
 (0)