-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.ts
74 lines (67 loc) · 1.68 KB
/
index.ts
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
import * as pulumi from "@pulumi/pulumi";
import * as aws from "@pulumi/aws";
const buildRole = new aws.iam.Role('build-setup-role', {
assumeRolePolicy: {
Version: '2012-10-17',
Statement: [
{
Effect: 'Allow',
Principal: {
Service: 'codebuild.amazonaws.com',
},
Action: 'sts:AssumeRole',
},
],
},
});
new aws.iam.RolePolicyAttachment('build-setup-policy', {
role: buildRole,
policyArn: 'arn:aws:iam::aws:policy/AdministratorAccess',
});
const config = new pulumi.Config();
new aws.codebuild.SourceCredential('github-token', {
authType: 'PERSONAL_ACCESS_TOKEN',
serverType: 'GITHUB',
token: config.requireSecret('github-token'),
});
const pulumiAccessToken = new aws.ssm.Parameter('pulumi-access-token', {
type: 'String',
value: config.requireSecret('pulumi-access-token'),
});
const buildProject = new aws.codebuild.Project("build-setup", {
serviceRole: buildRole.arn,
source: {
type: "GITHUB",
location: "https://github.com/danielrbradley/build-setup-example.git"
},
environment: {
type: "LINUX_CONTAINER",
computeType: "BUILD_GENERAL1_SMALL",
image: "aws/codebuild/standard:3.0",
environmentVariables: [
{
type: 'PARAMETER_STORE',
name: 'PULUMI_ACCESS_TOKEN',
value: pulumiAccessToken.name,
},
],
},
artifacts: { type: "NO_ARTIFACTS" }
});
new aws.codebuild.Webhook('build-setup-webhook', {
projectName: buildProject.name,
filterGroups: [
{
filters: [
{
type: 'EVENT',
pattern: 'PUSH',
},
{
type: 'HEAD_REF',
pattern: 'refs/heads/master',
},
],
},
],
});