Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(deadline): adds UserData property to WorkerInstanceFleet #781

Merged
merged 1 commit into from
Aug 22, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions packages/aws-rfdk/lib/deadline/lib/worker-fleet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import {
Port,
SubnetSelection,
SubnetType,
UserData,
} from 'aws-cdk-lib/aws-ec2';
import {IApplicationLoadBalancerTarget} from 'aws-cdk-lib/aws-elasticloadbalancingv2';
import {
Expand Down Expand Up @@ -223,6 +224,15 @@ export interface WorkerInstanceFleetProps extends WorkerSettings {
*/
readonly blockDevices?: BlockDevice[];

/**
* The specific UserData to use.
*
* The UserData will be mutated by this construct and may be mutated afterwards as well.
*
* @default A UserData object appropriate for the MachineImage's Operating System is created.
*/
readonly userData?: UserData;

/**
* An optional provider of user data commands to be injected at various points during the Worker configuration lifecycle.
* You can provide a subclass of InstanceUserDataProvider with the methods overridden as desired.
Expand Down Expand Up @@ -455,6 +465,7 @@ export class WorkerInstanceFleet extends WorkerInstanceFleetBase {
role: props.role,
spotPrice: props.spotPrice?.toString(),
blockDevices: props.blockDevices,
userData: props.userData,
});

this.targetCapacity = parseInt((this.fleet.node.defaultChild as CfnAutoScalingGroup).maxSize, 10);
Expand Down
20 changes: 20 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 @@ -28,6 +28,7 @@ import {
Peer,
SecurityGroup,
SubnetType,
UserData,
Vpc,
} from 'aws-cdk-lib/aws-ec2';
import {
Expand Down Expand Up @@ -477,6 +478,25 @@ test.each([
});
});

test('worker fleet uses given UserData', () => {
// GIVEN
const id = 'workerFleet';
const userData = UserData.forLinux();

// WHEN
const workerFleet = new WorkerInstanceFleet(stack, id, {
vpc,
workerMachineImage: new GenericLinuxImage({
'us-east-1': '123',
}),
renderQueue,
userData,
});

// THEN
expect(workerFleet.fleet.userData).toBe(userData);
});

test('default linux worker fleet is created correctly custom subnet values', () => {
vpc = new Vpc(stack, 'VPC1Az', {
maxAzs: 1,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -273,5 +273,7 @@ test('decrypt private key', async () => {
// THEN
expect(decryptedKey).toEqual(expectedDecryptedKey);
// Must have the decrypted private key
expect(decryptedKey).toContain('-----BEGIN RSA PRIVATE KEY-----');
// OpenSSL 1.0.x: -----BEGIN RSA PRIVATE KEY-----
// OpenSSL 1.1.x: -----BEGIN PRIVATE KEY-----
expect(decryptedKey).toMatch(/-----BEGIN (?:RSA )?PRIVATE KEY-----/);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was developing this on an Ubuntu 22.04 machine that uses OpenSSL 1.1.x, so I fixed this up while I was at it.

});