in packages/aws-rfdk/lib/deadline/lib/version-query.ts [146:216]
constructor(scope: Construct, id: string, props?: VersionQueryProps) {
super(scope, id);
this.expression = props?.version;
const match = (props?.version ?? '').match(VersionQuery.EXPRESSION_REGEX);
if (match === null) {
throw new Error(`Invalid version expression "${props!.version}`);
}
this.pinnedVersionComponents = (
match
// First capture group is the entire matched string, so slice it off
.slice(1)
// Capture groups that are not matched return as undefined, so we filter them out
.filter(component => component)
// Parse strings to numbers
.map(component => Number(component))
);
const lambdaCode = Code.fromAsset(join(__dirname, '..', '..', 'lambdas', 'nodejs'));
const lambdaFunc = new SingletonFunction(this, 'VersionProviderFunction', {
uuid: '2e19e243-16ee-4d1a-a3c9-18d35eddd446',
description: 'Used by the Version construct to get installer locations for a specific Deadline version.',
code: lambdaCode,
runtime: Runtime.NODEJS_18_X,
handler: 'version-provider.handler',
timeout: Duration.seconds(30),
logRetention: RetentionDays.ONE_WEEK,
});
const deadlineProperties: IVersionProviderResourceProperties = {
versionString: props?.version,
// If we don't have a full static version string, create a random string that will force the Lambda to always
// run on redeploys, effectively checking for version updates.
forceRun: this.forceRun(props?.version),
};
this.deadlineResource = new CustomResource(this, 'DeadlineResource', {
serviceToken: lambdaFunc.functionArn,
properties: deadlineProperties,
resourceType: 'Custom::RFDK_DEADLINE_INSTALLERS',
});
this.majorVersion = this.versionComponent({
expressionIndex: 0,
customResourceAttribute: 'MajorVersion',
});
this.minorVersion = this.versionComponent({
expressionIndex: 1,
customResourceAttribute: 'MinorVersion',
});
this.releaseVersion = this.versionComponent({
expressionIndex: 2,
customResourceAttribute: 'ReleaseVersion',
});
const installerBucket = Bucket.fromBucketName(scope, 'InstallerBucket', this.deadlineResource.getAttString('S3Bucket'));
this.linuxInstallers = {
patchVersion: Token.asNumber(this.deadlineResource.getAtt('LinuxPatchVersion')),
repository: {
objectKey: this.deadlineResource.getAttString('LinuxRepositoryInstaller'),
s3Bucket: installerBucket,
},
client: {
objectKey: this.deadlineResource.getAttString('LinuxClientInstaller'),
s3Bucket: installerBucket,
},
};
}