in integ/lib/testing-tier.ts [202:283]
public configureBastionUserData(props: UserDataConfigProps) {
this.testInstance.instance.instance.cfnOptions.creationPolicy = {
...this.testInstance.instance.instance.cfnOptions.creationPolicy,
resourceSignal: {
timeout: Duration.minutes(5).toIsoString(),
count: 1,
},
};
const userDataCommands = [];
userDataCommands.push(
'set -xeou pipefail',
);
const instanceSetupScripts = new Asset(this, 'SetupScripts', {
path: path.join(__dirname, '..', 'components', 'deadline', 'common', 'scripts', 'bastion', 'setup'),
});
instanceSetupScripts.grantRead(this.testInstance);
const setupZipPath: string = this.testInstance.instance.userData.addS3DownloadCommand({
bucket: instanceSetupScripts.bucket,
bucketKey: instanceSetupScripts.s3ObjectKey,
});
userDataCommands.push(
// Unzip the utility scripts to: ~ec2-user/setupScripts/
'cd ~ec2-user',
'mkdir -p setupScripts',
'cd setupScripts',
`unzip ${setupZipPath}`,
`rm -f ${setupZipPath}`,
'chmod +x *.sh',
'./install_jq.sh',
);
const instanceUtilScripts = new Asset(this, 'UtilScripts', {
path: path.join(__dirname, '..', 'components', 'deadline', 'common', 'scripts', 'bastion', 'utils'),
});
instanceUtilScripts.grantRead(this.testInstance);
const utilZipPath: string = this.testInstance.instance.userData.addS3DownloadCommand({
bucket: instanceUtilScripts.bucket,
bucketKey: instanceUtilScripts.s3ObjectKey,
});
userDataCommands.push(
// Unzip the utility scripts to: ~ec2-user/utilScripts/
'cd ~ec2-user',
'mkdir -p utilScripts',
'cd utilScripts',
`unzip ${utilZipPath}`,
`rm -f ${utilZipPath}`,
'chmod +x *.sh',
);
const testingScripts = new Asset(this, 'TestingScripts', {
path: props.testingScriptPath,
});
testingScripts.grantRead(this.testInstance);
const testsZipPath: string = this.testInstance.instance.userData.addS3DownloadCommand({
bucket: testingScripts.bucket,
bucketKey: testingScripts.s3ObjectKey,
});
userDataCommands.push(
// Unzip the testing scripts to: ~ec2-user/testScripts/
'cd ~ec2-user',
'mkdir -p testScripts',
'cd testScripts',
`unzip ${testsZipPath}`,
`rm -f ${testsZipPath}`,
'chmod +x *.sh',
);
userDataCommands.push(
// Everything will be owned by root, by default (UserData runs as root)
'cd ~ec2-user',
'chown ec2-user.ec2-user -R *',
);
this.testInstance.instance.userData.addCommands( ...userDataCommands );
this.testInstance.instance.userData.addSignalOnExitCommand( this.testInstance.instance );
}