Skip to content

Commit

Permalink
Merge pull request #191 from rstudio/create-sg-automatically-require-…
Browse files Browse the repository at this point in the history
…vpc-id

Switch to using vpcId and creating the security group directly from within serverless
  • Loading branch information
jforest authored Sep 8, 2023
2 parents b98e515 + 8c0af64 commit 3247926
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 3 deletions.
15 changes: 13 additions & 2 deletions serverless-resources.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
rBuildsSecurityGroup:
Type: AWS::EC2::SecurityGroup
Properties:
GroupDescription: RBuilds jobs - ${self:provider.stage}
GroupName: RBuildsJobs-${self:provider.stage}
VpcId: ${self:custom.vpcId}
Tags: ${self:provider.tagsList}


rBuildsBatchIamRole:
Type: AWS::IAM::Role
Properties:
Expand Down Expand Up @@ -97,13 +106,15 @@ rBuildsBatchComputeEnvironment:
ServiceRole:
"Fn::GetAtt": [ rBuildsBatchIamRole, Arn ]
ComputeResources:
AllocationStrategy: BEST_FIT_PROGRESSIVE
LaunchTemplate:
LaunchTemplateId:
Ref: rBuildsEcsLaunchTemplate
Version: '$Latest'
SpotIamFleetRole:
"Fn::GetAtt": [ rBuildsSpotFleetIamRole, Arn ]
SecurityGroupIds: ${self:custom.securityGroupIds}
SecurityGroupIds:
- "Fn::GetAtt": [ rBuildsSecurityGroup, GroupId ]
Subnets: ${self:custom.subnets}
Type: SPOT
BidPercentage: 100
Expand All @@ -120,7 +131,7 @@ rBuildsBatchComputeEnvironment:
- c5a.xlarge
- c5a.2xlarge
Ec2KeyPair: ${self:custom.ec2KeyPair}
Tags: ${self:provider.stackTags}
Tags: ${self:provider.tagsMap}
MinvCpus: 0
DesiredvCpus: 0
MaxvCpus: 256
Expand Down
12 changes: 11 additions & 1 deletion serverless.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,17 @@ provider:
stage: ${opt:stage, self:custom.defaultStage}
deploymentBucket:
name: ${self:custom.deploymentBucket}
stackTags: ${self:custom.${self:provider.stage}.stackTags}
tagsList:
- Key: rs:project
Value: ${self:custom.${self:provider.stage}.tags.project}
- Key: rs:owner
Value: ${self:custom.${self:provider.stage}.tags.owner}
- Key: rs:environment
Value: ${self:custom.${self:provider.stage}.tags.environment}
tagsMap:
"rs:owner": ${self:custom.${self:provider.stage}.tags.owner}
"rs:project": ${self:custom.${self:provider.stage}.tags.project}
"rs:environment": ${self:custom.${self:provider.stage}.tags.environment}
iamRoleStatements:
- Effect: Allow
Action:
Expand Down

0 comments on commit 3247926

Please sign in to comment.