-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
33 lines (27 loc) · 820 Bytes
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
const AWS = require('aws-sdk');
const codebuild = new AWS.CodeBuild();
exports.handler = async (event) => {
const s3Info = event.Records[0].s3;
const objectKey = s3Info.object.key;
const parts = objectKey.split('/');
const companyID = parts[1];
const gameID = parts[2];
const environmentVariables = [
{
name: 'COMPANY_ID',
value: companyID,
type: 'PLAINTEXT'
},
{
name: 'GAME_ID',
value: gameID,
type: 'PLAINTEXT'
}
];
const response = await codebuild.startBuild({
projectName: 'mole-build',
environmentVariablesOverride: environmentVariables
}).promise();
console.log("CodeBuild start response: ", JSON.stringify(response));
return response;
};