async function startBuildCommand()

in lib/lambdas/stream-lambda/index.js [26:58]


async function startBuildCommand(image) {
    // For production use, implementing error handling for
    // the CodeBuild API calls is recommended. Transient errors, such as
    // reaching maximum number of allowed concurrent CodeBuild executions
    // may cause errors that require a retry.

    const env = [
        { name: 'DEPLOYMENT_ID', value: image.id.S },
    ];

    if ('type' in image) {
        env.push({ name: 'DEPLOYMENT_TYPE', value: image.type.S });
    }
    if ('account' in image) {
        env.push({ name: 'COMPONENT_ACCOUNT', value: image.account.S });
    }
    if ('region' in image) {
        env.push({ name: 'COMPONENT_REGION', value: image.region.S });
    }

    const params = {
        projectName: projectName,
        environmentVariablesOverride: env,
    };

    console.log('Calling startBuild() on CodeBuild project ' + projectName);
    try {
        const result = await codebuild.startBuild(params).promise();
        console.log(result);
    } catch (error) {
        console.error(error);
    }
}