Skip to content

Commit

Permalink
fix(deadline): WorkerFleet should not create a securitygroups when gi…
Browse files Browse the repository at this point in the history
…ven one (#78)
  • Loading branch information
ddneilson authored Aug 26, 2020
1 parent 6c23000 commit c07f9bd
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 7 deletions.
5 changes: 1 addition & 4 deletions packages/aws-rfdk/lib/deadline/lib/worker-fleet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -387,6 +387,7 @@ export class WorkerInstanceFleet extends WorkerInstanceFleetBase {
vpcSubnets: props.vpcSubnets ? props.vpcSubnets : {
subnetType: SubnetType.PRIVATE,
},
securityGroup: props.securityGroup,
minCapacity: props.minCapacity,
maxCapacity: props.maxCapacity,
desiredCapacity: props.desiredCapacity,
Expand Down Expand Up @@ -422,10 +423,6 @@ export class WorkerInstanceFleet extends WorkerInstanceFleetBase {
metrics: ['GroupDesiredCapacity'],
}];

if (props.securityGroup) {
this.fleet.addSecurityGroup(props.securityGroup);
}

this.grantPrincipal = this.fleet.grantPrincipal;
this.connections = this.fleet.connections;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -504,9 +504,7 @@ describe('UsageBasedLicensing', () => {
'GroupId',
],
},
SourceSecurityGroupId: {
'Fn::ImportValue': stringLike(`${Stack.of(workerFleet)}:ExportsOutputFnGetAttworkerFleetInstanceSecurityGroupB00C2885GroupId60416F0A`),
},
SourceSecurityGroupId: 'sg-123456789',
}));
});
});
Expand Down
21 changes: 21 additions & 0 deletions packages/aws-rfdk/lib/deadline/test/worker-fleet.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,27 @@ test('security group is added to fleet after its creation', () => {
}));
});

test('WorkerFleet uses given security group', () => {
// WHEN
new WorkerInstanceFleet(stack, 'workerFleet', {
vpc,
workerMachineImage: new GenericWindowsImage({
'us-east-1': 'ami-any',
}),
renderQueue,
securityGroup: SecurityGroup.fromSecurityGroupId(stack, 'SG', 'sg-123456789', {
allowAllOutbound: false,
}),
});

// THEN
expectCDK(stack).to(haveResourceLike('AWS::AutoScaling::LaunchConfiguration', {
SecurityGroups: [
'sg-123456789',
],
}));
});

test('default worker fleet is created correctly with linux image', () => {
// WHEN
new WorkerInstanceFleet(stack, 'workerFleet', {
Expand Down

0 comments on commit c07f9bd

Please sign in to comment.