Skip to content

Commit

Permalink
feat(deadline): add WorkerInstanceConfiguration construct (#209)
Browse files Browse the repository at this point in the history
This is a construct for configuring a Deadline Worker in the RFDK context.
  • Loading branch information
ddneilson authored Nov 6, 2020
1 parent 78dcd86 commit bbb82b0
Show file tree
Hide file tree
Showing 12 changed files with 1,116 additions and 140 deletions.
5 changes: 5 additions & 0 deletions packages/aws-rfdk/lib/core/lib/script-assets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,11 @@ export interface ConventionalScriptPathParams {
*/
function getConventionalScriptPath(params: ConventionalScriptPathParams): string {
const { rootDir: scriptDir, baseName: scriptName, osType } = params;
// Make sure we have a known osType. The error message is pretty obtuse if we don't:
// The "path" argument must be of type string. Received undefined
if (ScriptPathPrefix[osType] === undefined || ScriptExtension[osType] == undefined) {
throw Error(`Unknown osType: ${osType}`);
}
return path.join(
scriptDir,
ScriptPathPrefix[osType],
Expand Down
225 changes: 225 additions & 0 deletions packages/aws-rfdk/lib/core/test/asset-constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,228 @@ export const INSTALL_MONGODB_3_6_SCRIPT_LINUX = {
export const MONGODB_INSTANCE_3_6_SCRIPT = {
Bucket: stringLike('AssetParameters*S3Bucket352E624B'),
};

export function linuxDownloadRunScriptBoilerplate(script: { Bucket: string, Key: string }) {
return [
{
'Fn::Select': [
0,
{
'Fn::Split': [
'||',
{Ref: script.Key},
],
},
],
},
{
'Fn::Select': [
1,
{
'Fn::Split': [
'||',
{Ref: script.Key},
],
},
],
},
'\')\naws s3 cp \'s3://',
{Ref: script.Bucket},
'/',
{
'Fn::Select': [
0,
{
'Fn::Split': [
'||',
{Ref: script.Key},
],
},
],
},
{
'Fn::Select': [
1,
{
'Fn::Split': [
'||',
{Ref: script.Key},
],
},
],
},
'\' \'/tmp/',
{
'Fn::Select': [
0,
{
'Fn::Split': [
'||',
{Ref: script.Key},
],
},
],
},
{
'Fn::Select': [
1,
{
'Fn::Split': [
'||',
{Ref: script.Key},
],
},
],
},
'\'\n' +
'set -e\n' +
'chmod +x \'/tmp/',
{
'Fn::Select': [
0,
{
'Fn::Split': [
'||',
{
Ref: script.Key,
},
],
},
],
},
{
'Fn::Select': [
1,
{
'Fn::Split': [
'||',
{Ref: script.Key},
],
},
],
},
'\'\n\'/tmp/',
{
'Fn::Select': [
0,
{
'Fn::Split': [
'||',
{Ref: script.Key},
],
},
],
},
{
'Fn::Select': [
1,
{
'Fn::Split': [
'||',
{Ref: script.Key},
],
},
],
},
];
}

export function windowsDownloadRunScriptBoilerplate(script: { Bucket: string, Key: string }) {
return [
{
'Fn::Select': [
0,
{
'Fn::Split': [
'||',
{Ref: script.Key},
],
},
],
},
{
'Fn::Select': [
1,
{
'Fn::Split': [
'||',
{Ref: script.Key},
],
},
],
},
'\' ) -ea 0\nRead-S3Object -BucketName \'',
{Ref: script.Bucket},
'\' -key \'',
{
'Fn::Select': [
0,
{
'Fn::Split': [
'||',
{Ref: script.Key},
],
},
],
},
{
'Fn::Select': [
1,
{
'Fn::Split': [
'||',
{Ref: script.Key},
],
},
],
},
'\' -file \'C:/temp/',
{
'Fn::Select': [
0,
{
'Fn::Split': [
'||',
{Ref: script.Key},
],
},
],
},
{
'Fn::Select': [
1,
{
'Fn::Split': [
'||',
{Ref: script.Key},
],
},
],
},
'\' -ErrorAction Stop\n&\'C:/temp/',
{
'Fn::Select': [
0,
{
'Fn::Split': [
'||',
{
Ref: script.Key,
},
],
},
],
},
{
'Fn::Select': [
1,
{
'Fn::Split': [
'||',
{Ref: script.Key},
],
},
],
},
];
}
1 change: 1 addition & 0 deletions packages/aws-rfdk/lib/deadline/lib/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,4 @@ export * from './thinkbox-docker-recipes';
export * from './version';
export * from './version-query';
export * from './version-ref';
export * from './worker-configuration';
Loading

0 comments on commit bbb82b0

Please sign in to comment.