@fjall/components-infrastructure 3.0.0 → 3.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/lib/app.d.ts +24 -0
- package/dist/lib/app.js +46 -0
- package/dist/lib/config/aws/alarmTopic.d.ts +7 -0
- package/dist/lib/config/aws/alarmTopic.js +9 -2
- package/dist/lib/patterns/aws/apexDomainPattern.d.ts +7 -7
- package/dist/lib/patterns/aws/apexDomainPattern.js +10 -14
- package/dist/lib/patterns/aws/buildkite/alarms.d.ts +25 -0
- package/dist/lib/patterns/aws/buildkite/alarms.js +78 -0
- package/dist/lib/patterns/aws/buildkite/buildkite.d.ts +46 -0
- package/dist/lib/patterns/aws/buildkite/buildkite.js +240 -0
- package/dist/lib/patterns/aws/buildkite/iam.d.ts +35 -0
- package/dist/lib/patterns/aws/buildkite/iam.js +177 -0
- package/dist/lib/patterns/aws/buildkite/pins.d.ts +69 -0
- package/dist/lib/patterns/aws/buildkite/pins.js +80 -0
- package/dist/lib/patterns/aws/buildkite/schema.d.ts +81 -0
- package/dist/lib/patterns/aws/buildkite/schema.js +155 -0
- package/dist/lib/patterns/aws/buildkite/userData.d.ts +58 -0
- package/dist/lib/patterns/aws/buildkite/userData.js +226 -0
- package/dist/lib/patterns/aws/buildkite.d.ts +11 -59
- package/dist/lib/patterns/aws/buildkite.js +11 -310
- package/dist/lib/patterns/aws/devSubstrate.d.ts +26 -15
- package/dist/lib/patterns/aws/devSubstrate.js +47 -27
- package/dist/lib/resources/aws/compute/ec2.d.ts +15 -0
- package/dist/lib/resources/aws/compute/ec2.js +20 -1
- package/dist/lib/resources/aws/monitoring/buildkiteAlarms.d.ts +29 -0
- package/dist/lib/resources/aws/monitoring/buildkiteAlarms.js +90 -0
- package/dist/lib/resources/aws/monitoring/index.d.ts +1 -0
- package/dist/lib/resources/aws/monitoring/index.js +1 -0
- package/dist/lib/resources/aws/networking/hostedZone.js +23 -19
- package/package.json +4 -4
|
@@ -0,0 +1,226 @@
|
|
|
1
|
+
import { MultipartBody, MultipartUserData, UserData } from "aws-cdk-lib/aws-ec2";
|
|
2
|
+
import { BUILDKITE_STACK_PINS } from "./pins.js";
|
|
3
|
+
/**
|
|
4
|
+
* The pinned AMI's boot scripts run under `set -Eeuo pipefail` and
|
|
5
|
+
* dereference every variable the upstream template passes — an OMITTED key
|
|
6
|
+
* is not "use the default", it is an unbound-variable crash at boot and an
|
|
7
|
+
* ASG boot-loop. Each part therefore mirrors the upstream v6.68.1 user data
|
|
8
|
+
* env block EXACTLY (same keys, upstream parameter defaults where we expose
|
|
9
|
+
* no knob), and the parity test asserts set equality per part against the
|
|
10
|
+
* vendored template in both directions: a key we emit that upstream does not
|
|
11
|
+
* pass is silently ignored; a key upstream passes that we omit is the
|
|
12
|
+
* boot-loop. Bumping the pins regenerates the fixture
|
|
13
|
+
* (runbook: `aiDocs/runbooks/buildkite-stack-bump-runbook.md`).
|
|
14
|
+
*/
|
|
15
|
+
export const BUILDKITE_MOUNT_PART_ENV_KEYS = [
|
|
16
|
+
"BUILDKITE_ENABLE_INSTANCE_STORAGE",
|
|
17
|
+
"BUILDKITE_MOUNT_TMPFS_AT_TMP"
|
|
18
|
+
];
|
|
19
|
+
/**
|
|
20
|
+
* Docker-GC values upstream derives from a single CloudFormation parameter
|
|
21
|
+
* feeding BOTH the docker part and the install part — the two emissions must
|
|
22
|
+
* carry the same value or boot-time docker GC and the per-job disk-cleanup
|
|
23
|
+
* hooks silently disagree (coupled values, shared source at 2 occurrences).
|
|
24
|
+
*/
|
|
25
|
+
const DOCKER_PRUNE_UNTIL = "4h";
|
|
26
|
+
const ENABLE_PRE_EXIT_DISK_CLEANUP = "false";
|
|
27
|
+
const DOCKER_BUILDER_PRUNE_ENABLED = "false";
|
|
28
|
+
export const BUILDKITE_DOCKER_PART_ENV_KEYS = [
|
|
29
|
+
"DOCKER_USERNS_REMAP",
|
|
30
|
+
"DOCKER_EXPERIMENTAL",
|
|
31
|
+
"DOCKER_PRUNE_UNTIL",
|
|
32
|
+
"ENABLE_PRE_EXIT_DISK_CLEANUP",
|
|
33
|
+
"DOCKER_BUILDER_PRUNE_ENABLED",
|
|
34
|
+
"DOCKER_NETWORKING_PROTOCOL",
|
|
35
|
+
"DOCKER_IPV4_ADDRESS_POOL_1",
|
|
36
|
+
"DOCKER_IPV4_ADDRESS_POOL_2",
|
|
37
|
+
"DOCKER_IPV6_ADDRESS_POOL",
|
|
38
|
+
"DOCKER_FIXED_CIDR_V4",
|
|
39
|
+
"DOCKER_FIXED_CIDR_V6",
|
|
40
|
+
"BUILDKITE_ENABLE_INSTANCE_STORAGE"
|
|
41
|
+
];
|
|
42
|
+
export const BUILDKITE_USER_DATA_ENV_KEYS = [
|
|
43
|
+
"BUILDKITE_STACK_NAME",
|
|
44
|
+
"BUILDKITE_STACK_VERSION",
|
|
45
|
+
"BUILDKITE_STACK_DEPLOYED_BY",
|
|
46
|
+
"BUILDKITE_SCALE_IN_IDLE_PERIOD",
|
|
47
|
+
"BUILDKITE_SECRETS_BUCKET",
|
|
48
|
+
"BUILDKITE_SECRETS_BUCKET_REGION",
|
|
49
|
+
"BUILDKITE_SECRETS_PLUGIN_SKIP_SSH_KEY_NOT_FOUND_WARNING",
|
|
50
|
+
"BUILDKITE_ARTIFACTS_BUCKET",
|
|
51
|
+
"BUILDKITE_S3_DEFAULT_REGION",
|
|
52
|
+
"BUILDKITE_S3_ACL",
|
|
53
|
+
"BUILDKITE_AGENT_TOKEN_PATH",
|
|
54
|
+
"BUILDKITE_AGENTS_PER_INSTANCE",
|
|
55
|
+
"BUILDKITE_AGENT_ENDPOINT",
|
|
56
|
+
"BUILDKITE_AGENT_TAGS",
|
|
57
|
+
"BUILDKITE_AGENT_TIMESTAMP_LINES",
|
|
58
|
+
"BUILDKITE_AGENT_EXPERIMENTS",
|
|
59
|
+
"BUILDKITE_AGENT_TRACING_BACKEND",
|
|
60
|
+
"BUILDKITE_AGENT_SIGNING_KEY_PATH",
|
|
61
|
+
"BUILDKITE_AGENT_SIGNING_KEY_ID",
|
|
62
|
+
"BUILDKITE_AGENT_VERIFICATION_KEY_PATH",
|
|
63
|
+
"BUILDKITE_AGENT_RELEASE",
|
|
64
|
+
"BUILDKITE_AGENT_CANCEL_GRACE_PERIOD",
|
|
65
|
+
"BUILDKITE_AGENT_SIGNAL_GRACE_PERIOD_SECONDS",
|
|
66
|
+
"BUILDKITE_AGENT_SIGNING_KMS_KEY",
|
|
67
|
+
"BUILDKITE_AGENT_JOB_VERIFICATION_NO_SIGNATURE_BEHAVIOR",
|
|
68
|
+
"BUILDKITE_QUEUE",
|
|
69
|
+
"BUILDKITE_AGENT_ENABLE_GIT_MIRRORS",
|
|
70
|
+
"BUILDKITE_ELASTIC_BOOTSTRAP_SCRIPT",
|
|
71
|
+
"BUILDKITE_ENV_FILE_URL",
|
|
72
|
+
"BUILDKITE_ENABLE_INSTANCE_STORAGE",
|
|
73
|
+
"BUILDKITE_AUTHORIZED_USERS_URL",
|
|
74
|
+
"BUILDKITE_ECR_POLICY",
|
|
75
|
+
"BUILDKITE_TERMINATE_INSTANCE_AFTER_JOB",
|
|
76
|
+
"BUILDKITE_AGENT_DISCONNECT_AFTER_UPTIME",
|
|
77
|
+
"BUILDKITE_TERMINATE_INSTANCE_ON_DISK_FULL",
|
|
78
|
+
"BUILDKITE_PURGE_BUILDS_ON_DISK_FULL",
|
|
79
|
+
"BUILDKITE_ADDITIONAL_SUDO_PERMISSIONS",
|
|
80
|
+
"AWS_DEFAULT_REGION",
|
|
81
|
+
"SECRETS_PLUGIN_ENABLED",
|
|
82
|
+
"ECR_PLUGIN_ENABLED",
|
|
83
|
+
"ECR_CREDENTIAL_HELPER_ENABLED",
|
|
84
|
+
"DOCKER_LOGIN_PLUGIN_ENABLED",
|
|
85
|
+
"DOCKER_EXPERIMENTAL",
|
|
86
|
+
"DOCKER_PRUNE_UNTIL",
|
|
87
|
+
"ENABLE_PRE_EXIT_DISK_CLEANUP",
|
|
88
|
+
"DOCKER_BUILDER_PRUNE_ENABLED",
|
|
89
|
+
"DOCKER_USERNS_REMAP",
|
|
90
|
+
"AWS_REGION",
|
|
91
|
+
"ENABLE_RESOURCE_LIMITS",
|
|
92
|
+
"RESOURCE_LIMITS_MEMORY_HIGH",
|
|
93
|
+
"RESOURCE_LIMITS_MEMORY_MAX",
|
|
94
|
+
"RESOURCE_LIMITS_MEMORY_SWAP_MAX",
|
|
95
|
+
"RESOURCE_LIMITS_CPU_WEIGHT",
|
|
96
|
+
"RESOURCE_LIMITS_CPU_QUOTA",
|
|
97
|
+
"RESOURCE_LIMITS_IO_WEIGHT",
|
|
98
|
+
"ENABLE_EC2_LOG_RETENTION_POLICY",
|
|
99
|
+
"EC2_LOG_RETENTION_DAYS"
|
|
100
|
+
];
|
|
101
|
+
function shellScriptPart(commands) {
|
|
102
|
+
const userData = UserData.forLinux({ shebang: "#!/bin/bash -v" });
|
|
103
|
+
userData.addCommands(...commands);
|
|
104
|
+
return MultipartBody.fromUserData(userData, "text/x-shellscript; charset='us-ascii'");
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Build the agent instance's multipart user data against the pinned elastic
|
|
108
|
+
* stack's boot scripts (cloud-config re-run marker, storage mount, docker
|
|
109
|
+
* config, `bk-install-elastic-stack.sh`).
|
|
110
|
+
*/
|
|
111
|
+
export function buildBuildkiteUserData(props, context) {
|
|
112
|
+
const multipartUserData = new MultipartUserData();
|
|
113
|
+
const cloudConfigUserData = UserData.forLinux({ shebang: "#cloud-config" });
|
|
114
|
+
cloudConfigUserData.addCommands("cloud_final_modules:", " - [scripts-user, always]");
|
|
115
|
+
multipartUserData.addPart(MultipartBody.fromUserData(cloudConfigUserData, "text/cloud-config; charset='us-ascii'"));
|
|
116
|
+
multipartUserData.addPart(shellScriptPart(buildBuildkiteMountCommands(props)));
|
|
117
|
+
multipartUserData.addPart(shellScriptPart(buildBuildkiteDockerCommands(props)));
|
|
118
|
+
multipartUserData.addPart(shellScriptPart(buildBuildkiteInstallCommands(props, context)));
|
|
119
|
+
return multipartUserData;
|
|
120
|
+
}
|
|
121
|
+
/** Storage-mount part — `bk-mount-instance-storage.sh` env assignments. */
|
|
122
|
+
export function buildBuildkiteMountCommands(props) {
|
|
123
|
+
return [
|
|
124
|
+
`BUILDKITE_ENABLE_INSTANCE_STORAGE='${props.enableInstanceStorage}' \\`,
|
|
125
|
+
`BUILDKITE_MOUNT_TMPFS_AT_TMP='${props.mountTmpfsAtTmp}' \\`,
|
|
126
|
+
"/usr/local/bin/bk-mount-instance-storage.sh"
|
|
127
|
+
];
|
|
128
|
+
}
|
|
129
|
+
/** Docker-configure part — `bk-configure-docker.sh` env assignments. */
|
|
130
|
+
export function buildBuildkiteDockerCommands(props) {
|
|
131
|
+
return [
|
|
132
|
+
`DOCKER_USERNS_REMAP='${props.enableDockerUserNamespaceRemap}' \\`,
|
|
133
|
+
`DOCKER_EXPERIMENTAL='${props.enableDockerExperimental}' \\`,
|
|
134
|
+
`DOCKER_PRUNE_UNTIL='${DOCKER_PRUNE_UNTIL}' \\`,
|
|
135
|
+
`ENABLE_PRE_EXIT_DISK_CLEANUP='${ENABLE_PRE_EXIT_DISK_CLEANUP}' \\`,
|
|
136
|
+
`DOCKER_BUILDER_PRUNE_ENABLED='${DOCKER_BUILDER_PRUNE_ENABLED}' \\`,
|
|
137
|
+
`DOCKER_NETWORKING_PROTOCOL='${props.dockerNetworkingProtocol}' \\`,
|
|
138
|
+
"DOCKER_IPV4_ADDRESS_POOL_1='172.17.0.0/12' \\",
|
|
139
|
+
"DOCKER_IPV4_ADDRESS_POOL_2='192.168.0.0/16' \\",
|
|
140
|
+
"DOCKER_IPV6_ADDRESS_POOL='2001:db8:2::/104' \\",
|
|
141
|
+
"DOCKER_FIXED_CIDR_V4='' \\",
|
|
142
|
+
"DOCKER_FIXED_CIDR_V6='2001:db8:1::/64' \\",
|
|
143
|
+
`BUILDKITE_ENABLE_INSTANCE_STORAGE='${props.enableInstanceStorage}' \\`,
|
|
144
|
+
"/usr/local/bin/bk-configure-docker.sh"
|
|
145
|
+
];
|
|
146
|
+
}
|
|
147
|
+
/**
|
|
148
|
+
* Install part — the env assignments handed to the pinned
|
|
149
|
+
* `bk-install-elastic-stack.sh`, mirroring the upstream block key-for-key in
|
|
150
|
+
* upstream order (so a fixture-bump diff reads line-by-line). Keys with no
|
|
151
|
+
* schema knob carry the upstream v6.68.1 parameter default verbatim, with
|
|
152
|
+
* three deliberate deviations:
|
|
153
|
+
*
|
|
154
|
+
* - `BUILDKITE_S3_ACL`: our artifact bucket is BucketOwnerEnforced (ACLs
|
|
155
|
+
* disabled), where S3 rejects every canned ACL EXCEPT
|
|
156
|
+
* `bucket-owner-full-control` — upstream's `private` default would fail
|
|
157
|
+
* every artifact upload with AccessControlListNotSupported.
|
|
158
|
+
* - `BUILDKITE_ECR_POLICY`: hard-pinned `none` (design § D9 — the instance
|
|
159
|
+
* profile confers no registry credentials).
|
|
160
|
+
* - `BUILDKITE_AGENT_SIGNING_KMS_KEY`: hard-pinned empty. Pipeline signing
|
|
161
|
+
* is out of scope for the Phase-1 deploy fleet; a future signing knob must
|
|
162
|
+
* land WITH the kms:Sign/Verify/GetPublicKey grants it needs (the prior
|
|
163
|
+
* knob shipped without them — a dead toggle that broke agents when set).
|
|
164
|
+
*/
|
|
165
|
+
export function buildBuildkiteInstallCommands(props, context) {
|
|
166
|
+
return [
|
|
167
|
+
`BUILDKITE_STACK_NAME='${context.stackName}' \\`,
|
|
168
|
+
`BUILDKITE_STACK_VERSION='${BUILDKITE_STACK_PINS.elasticStackVersion}' \\`,
|
|
169
|
+
"BUILDKITE_STACK_DEPLOYED_BY='fjall' \\",
|
|
170
|
+
`BUILDKITE_SCALE_IN_IDLE_PERIOD='${props.scaleInIdlePeriodSeconds}' \\`,
|
|
171
|
+
`BUILDKITE_SECRETS_BUCKET='${context.secretsBucketName}' \\`,
|
|
172
|
+
`BUILDKITE_SECRETS_BUCKET_REGION='${context.region}' \\`,
|
|
173
|
+
"BUILDKITE_SECRETS_PLUGIN_SKIP_SSH_KEY_NOT_FOUND_WARNING='false' \\",
|
|
174
|
+
`BUILDKITE_ARTIFACTS_BUCKET='${context.artifactBucketName}' \\`,
|
|
175
|
+
`BUILDKITE_S3_DEFAULT_REGION='${context.region}' \\`,
|
|
176
|
+
"BUILDKITE_S3_ACL='bucket-owner-full-control' \\",
|
|
177
|
+
`BUILDKITE_AGENT_TOKEN_PATH='${props.agentTokenSsmParameterName}' \\`,
|
|
178
|
+
`BUILDKITE_AGENTS_PER_INSTANCE='${props.agentsPerInstance}' \\`,
|
|
179
|
+
"BUILDKITE_AGENT_ENDPOINT='https://agent-edge.buildkite.com/v3' \\",
|
|
180
|
+
`BUILDKITE_AGENT_TAGS='${props.buildkiteAgentTags}' \\`,
|
|
181
|
+
`BUILDKITE_AGENT_TIMESTAMP_LINES='${props.buildkiteAgentTimestampLines}' \\`,
|
|
182
|
+
`BUILDKITE_AGENT_EXPERIMENTS='${props.buildkiteAgentExperiments}' \\`,
|
|
183
|
+
`BUILDKITE_AGENT_TRACING_BACKEND='${props.buildkiteAgentTracingBackend}' \\`,
|
|
184
|
+
"BUILDKITE_AGENT_SIGNING_KEY_PATH='' \\",
|
|
185
|
+
"BUILDKITE_AGENT_SIGNING_KEY_ID='' \\",
|
|
186
|
+
"BUILDKITE_AGENT_VERIFICATION_KEY_PATH='' \\",
|
|
187
|
+
`BUILDKITE_AGENT_RELEASE='${props.buildkiteAgentRelease}' \\`,
|
|
188
|
+
`BUILDKITE_AGENT_CANCEL_GRACE_PERIOD='${props.buildkiteAgentCancelGracePeriodSeconds}' \\`,
|
|
189
|
+
"BUILDKITE_AGENT_SIGNAL_GRACE_PERIOD_SECONDS='-1' \\",
|
|
190
|
+
"BUILDKITE_AGENT_SIGNING_KMS_KEY='' \\",
|
|
191
|
+
"BUILDKITE_AGENT_JOB_VERIFICATION_NO_SIGNATURE_BEHAVIOR='block' \\",
|
|
192
|
+
`BUILDKITE_QUEUE='${props.buildkiteQueue}' \\`,
|
|
193
|
+
`BUILDKITE_AGENT_ENABLE_GIT_MIRRORS='${props.buildkiteAgentEnableGitMirrors}' \\`,
|
|
194
|
+
`BUILDKITE_ELASTIC_BOOTSTRAP_SCRIPT='${props.bootstrapScriptUrl}' \\`,
|
|
195
|
+
`BUILDKITE_ENV_FILE_URL='${props.agentEnvFileUrl}' \\`,
|
|
196
|
+
`BUILDKITE_ENABLE_INSTANCE_STORAGE='${props.enableInstanceStorage}' \\`,
|
|
197
|
+
"BUILDKITE_AUTHORIZED_USERS_URL='' \\",
|
|
198
|
+
"BUILDKITE_ECR_POLICY='none' \\",
|
|
199
|
+
`BUILDKITE_TERMINATE_INSTANCE_AFTER_JOB='${props.terminateInstanceAfterJob}' \\`,
|
|
200
|
+
`BUILDKITE_AGENT_DISCONNECT_AFTER_UPTIME='${props.disconnectAfterUptimeSeconds}' \\`,
|
|
201
|
+
`BUILDKITE_TERMINATE_INSTANCE_ON_DISK_FULL='${props.terminateInstanceOnDiskFull}' \\`,
|
|
202
|
+
`BUILDKITE_PURGE_BUILDS_ON_DISK_FULL='${props.purgeBuildsOnDiskFull}' \\`,
|
|
203
|
+
"BUILDKITE_ADDITIONAL_SUDO_PERMISSIONS='' \\",
|
|
204
|
+
`AWS_DEFAULT_REGION='${context.region}' \\`,
|
|
205
|
+
`SECRETS_PLUGIN_ENABLED='${props.enableSecretsPlugin}' \\`,
|
|
206
|
+
`ECR_PLUGIN_ENABLED='${props.enableEcrPlugin}' \\`,
|
|
207
|
+
"ECR_CREDENTIAL_HELPER_ENABLED='false' \\",
|
|
208
|
+
`DOCKER_LOGIN_PLUGIN_ENABLED='${props.enableDockerLoginPlugin}' \\`,
|
|
209
|
+
`DOCKER_EXPERIMENTAL='${props.enableDockerExperimental}' \\`,
|
|
210
|
+
`DOCKER_PRUNE_UNTIL='${DOCKER_PRUNE_UNTIL}' \\`,
|
|
211
|
+
`ENABLE_PRE_EXIT_DISK_CLEANUP='${ENABLE_PRE_EXIT_DISK_CLEANUP}' \\`,
|
|
212
|
+
`DOCKER_BUILDER_PRUNE_ENABLED='${DOCKER_BUILDER_PRUNE_ENABLED}' \\`,
|
|
213
|
+
`DOCKER_USERNS_REMAP='${props.enableDockerUserNamespaceRemap}' \\`,
|
|
214
|
+
`AWS_REGION='${context.region}' \\`,
|
|
215
|
+
"ENABLE_RESOURCE_LIMITS='false' \\",
|
|
216
|
+
"RESOURCE_LIMITS_MEMORY_HIGH='90%' \\",
|
|
217
|
+
"RESOURCE_LIMITS_MEMORY_MAX='90%' \\",
|
|
218
|
+
"RESOURCE_LIMITS_MEMORY_SWAP_MAX='90%' \\",
|
|
219
|
+
"RESOURCE_LIMITS_CPU_WEIGHT='100' \\",
|
|
220
|
+
"RESOURCE_LIMITS_CPU_QUOTA='90%' \\",
|
|
221
|
+
"RESOURCE_LIMITS_IO_WEIGHT='80' \\",
|
|
222
|
+
"ENABLE_EC2_LOG_RETENTION_POLICY='false' \\",
|
|
223
|
+
"EC2_LOG_RETENTION_DAYS='7' \\",
|
|
224
|
+
"/usr/local/bin/bk-install-elastic-stack.sh"
|
|
225
|
+
];
|
|
226
|
+
}
|
|
@@ -1,59 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
}
|
|
10
|
-
export
|
|
11
|
-
|
|
12
|
-
elasticStackVersion: string;
|
|
13
|
-
keyName: string;
|
|
14
|
-
buildkiteAgentRelease: AgentRelease;
|
|
15
|
-
buildkiteAgentTags: string;
|
|
16
|
-
buildkiteAgentTimestampLines: boolean;
|
|
17
|
-
buildkiteAgentExperiments: string;
|
|
18
|
-
buildkiteAgentScalerVersion: string;
|
|
19
|
-
logRetentionDays: number;
|
|
20
|
-
buildkiteAgentTracingBackend: "" | "datadog" | "opentelemetry";
|
|
21
|
-
buildkiteAgentCancelGracePeriod: number;
|
|
22
|
-
buildkiteTerminateInstanceAfterJob: boolean;
|
|
23
|
-
buildkiteAdditionalSudoPermissions: string;
|
|
24
|
-
buildkiteQueue: string;
|
|
25
|
-
agentsPerInstance: number;
|
|
26
|
-
bootstrapScriptUrl: string;
|
|
27
|
-
agentEnvFileUrl: string;
|
|
28
|
-
authorizedUsersUrl: string;
|
|
29
|
-
agentInstanceType: InstanceType;
|
|
30
|
-
agentVolumeSize: number;
|
|
31
|
-
agentMinInstances: number;
|
|
32
|
-
agentMaxInstances: number;
|
|
33
|
-
scalerEventSchedulePeriod: string;
|
|
34
|
-
scalerMinPollInterval: string;
|
|
35
|
-
spotCapacityPercentage: number;
|
|
36
|
-
scaleOutFactor: string;
|
|
37
|
-
ecrAccessPolicy: string;
|
|
38
|
-
scaleInIdlePeriod: number;
|
|
39
|
-
scaleOutWaitingForJobs: boolean;
|
|
40
|
-
dockerNetworkingProtocol: "ipv4" | "dualstack";
|
|
41
|
-
enableSecretsPlugin: boolean;
|
|
42
|
-
enableEcrPlugin: boolean;
|
|
43
|
-
enableDockerLoginPlugin: boolean;
|
|
44
|
-
enableDockerUserNamespaceRemap: boolean;
|
|
45
|
-
enableDockerExperimental: boolean;
|
|
46
|
-
enableInstanceStorage: boolean;
|
|
47
|
-
mountTmpfsAtTmp: boolean;
|
|
48
|
-
buildkiteAgentEnableGitMirrors: boolean;
|
|
49
|
-
pipelineSigningKMSKey: string;
|
|
50
|
-
pipelineSigningVerificationFailureBehavior: "block" | "warn";
|
|
51
|
-
tags: KeyValue;
|
|
52
|
-
environment: string;
|
|
53
|
-
owner?: string;
|
|
54
|
-
}
|
|
55
|
-
export declare const BuildkiteDefaultProps: Pick<BuildkiteProps, "elasticStackVersion" | "keyName" | "buildkiteAgentRelease" | "buildkiteAgentTags" | "buildkiteAgentTimestampLines" | "buildkiteAgentExperiments" | "buildkiteAgentScalerVersion" | "logRetentionDays" | "buildkiteAgentTracingBackend" | "buildkiteAgentCancelGracePeriod" | "buildkiteTerminateInstanceAfterJob" | "buildkiteAdditionalSudoPermissions" | "buildkiteQueue" | "agentsPerInstance" | "bootstrapScriptUrl" | "agentEnvFileUrl" | "authorizedUsersUrl" | "agentInstanceType" | "agentVolumeSize" | "agentMinInstances" | "agentMaxInstances" | "scalerEventSchedulePeriod" | "scalerMinPollInterval" | "spotCapacityPercentage" | "scaleOutFactor" | "scaleInIdlePeriod" | "scaleOutWaitingForJobs" | "ecrAccessPolicy" | "dockerNetworkingProtocol" | "enableSecretsPlugin" | "enableEcrPlugin" | "enableDockerLoginPlugin" | "enableDockerUserNamespaceRemap" | "enableDockerExperimental" | "enableInstanceStorage" | "mountTmpfsAtTmp" | "buildkiteAgentEnableGitMirrors" | "pipelineSigningKMSKey" | "pipelineSigningVerificationFailureBehavior" | "environment" | "owner">;
|
|
56
|
-
export declare class Buildkite extends Stack {
|
|
57
|
-
constructor(scope: Construct, id: string, props: BuildkiteProps);
|
|
58
|
-
}
|
|
59
|
-
export default Buildkite;
|
|
1
|
+
/**
|
|
2
|
+
* Self-hosted Buildkite agent fleet — barrel for the `buildkite/` modules.
|
|
3
|
+
* The pre-2026-07 `Buildkite extends Stack` implementation is replaced by a
|
|
4
|
+
* Construct instantiated via `App.addBuildkite()`; design:
|
|
5
|
+
* `aiDocs/designs/2026-07-18-buildkite-selfhosted-agents.md`.
|
|
6
|
+
*/
|
|
7
|
+
export { Buildkite, FJALL_ENV_HOOK_OBJECT_KEY, buildFjallApiKeyEnvHookScript, type BuildkiteConstructProps } from "./buildkite/buildkite.js";
|
|
8
|
+
export { BUILDKITE_AMI_OWNER_ACCOUNT_ID, BUILDKITE_CPU_ARCHITECTURES, BUILDKITE_STACK_PINS, resolvePinnedAmiId, resolveScalerSarApplicationArn, type BuildkiteCpuArchitecture } from "./buildkite/pins.js";
|
|
9
|
+
export { BuildkitePropsSchema, validateBuildkiteProps, type BuildkiteProps, type BuildkitePropsInput } from "./buildkite/schema.js";
|
|
10
|
+
export { BUILDKITE_AGENT_IAM_ACTION_ALLOWLIST, buildAgentRole, type BuildkiteAgentRoleParams } from "./buildkite/iam.js";
|
|
11
|
+
export { BUILDKITE_DOCKER_PART_ENV_KEYS, BUILDKITE_MOUNT_PART_ENV_KEYS, BUILDKITE_USER_DATA_ENV_KEYS, buildBuildkiteDockerCommands, buildBuildkiteInstallCommands, buildBuildkiteMountCommands, buildBuildkiteUserData, type BuildkiteUserDataContext } from "./buildkite/userData.js";
|
|
@@ -1,310 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
import { SamApplication } from "../../resources/aws/compute/samApplication.js";
|
|
13
|
-
import { applyCostAllocationTags } from "../../utils/costAllocationTags.js";
|
|
14
|
-
export var AgentRelease;
|
|
15
|
-
(function (AgentRelease) {
|
|
16
|
-
AgentRelease["STABLE"] = "stable";
|
|
17
|
-
AgentRelease["BETA"] = "beta";
|
|
18
|
-
AgentRelease["EDGE"] = "edge";
|
|
19
|
-
})(AgentRelease || (AgentRelease = {}));
|
|
20
|
-
export const BuildkiteDefaultProps = {
|
|
21
|
-
// Buildkite Agent Configuration
|
|
22
|
-
elasticStackVersion: "v6.30.0",
|
|
23
|
-
keyName: "",
|
|
24
|
-
buildkiteAgentRelease: AgentRelease.STABLE,
|
|
25
|
-
buildkiteAgentTags: "",
|
|
26
|
-
buildkiteAgentTimestampLines: false,
|
|
27
|
-
buildkiteAgentExperiments: "",
|
|
28
|
-
buildkiteAgentScalerVersion: "1.8.0",
|
|
29
|
-
logRetentionDays: 1,
|
|
30
|
-
buildkiteAgentTracingBackend: "",
|
|
31
|
-
buildkiteAgentCancelGracePeriod: 60,
|
|
32
|
-
buildkiteTerminateInstanceAfterJob: false,
|
|
33
|
-
buildkiteAdditionalSudoPermissions: "",
|
|
34
|
-
buildkiteQueue: "default",
|
|
35
|
-
agentsPerInstance: 1,
|
|
36
|
-
bootstrapScriptUrl: "",
|
|
37
|
-
agentEnvFileUrl: "",
|
|
38
|
-
authorizedUsersUrl: "",
|
|
39
|
-
// Infrastructure
|
|
40
|
-
agentInstanceType: InstanceType.of(InstanceClass.M5, InstanceSize.LARGE),
|
|
41
|
-
agentMinInstances: 0,
|
|
42
|
-
agentMaxInstances: 10,
|
|
43
|
-
agentVolumeSize: 250,
|
|
44
|
-
scalerEventSchedulePeriod: "1 minute",
|
|
45
|
-
scalerMinPollInterval: "10s",
|
|
46
|
-
spotCapacityPercentage: 75,
|
|
47
|
-
scaleOutFactor: "1.0",
|
|
48
|
-
scaleInIdlePeriod: 600,
|
|
49
|
-
scaleOutWaitingForJobs: false,
|
|
50
|
-
ecrAccessPolicy: "",
|
|
51
|
-
dockerNetworkingProtocol: "ipv4",
|
|
52
|
-
enableSecretsPlugin: true,
|
|
53
|
-
enableEcrPlugin: true,
|
|
54
|
-
enableDockerLoginPlugin: true,
|
|
55
|
-
enableDockerUserNamespaceRemap: true,
|
|
56
|
-
enableDockerExperimental: false,
|
|
57
|
-
enableInstanceStorage: false,
|
|
58
|
-
mountTmpfsAtTmp: true,
|
|
59
|
-
buildkiteAgentEnableGitMirrors: false,
|
|
60
|
-
pipelineSigningKMSKey: "",
|
|
61
|
-
pipelineSigningVerificationFailureBehavior: "block",
|
|
62
|
-
// Tags
|
|
63
|
-
environment: "platform",
|
|
64
|
-
owner: "engineer"
|
|
65
|
-
};
|
|
66
|
-
export class Buildkite extends Stack {
|
|
67
|
-
constructor(scope, id, props) {
|
|
68
|
-
super(scope, id, props);
|
|
69
|
-
applyCostAllocationTags(this, {
|
|
70
|
-
service: "buildkite",
|
|
71
|
-
domain: "platform",
|
|
72
|
-
environment: props.environment || "platform",
|
|
73
|
-
owner: props.owner ?? "engineer"
|
|
74
|
-
});
|
|
75
|
-
const tags = { ...props.tags };
|
|
76
|
-
// VPC
|
|
77
|
-
const vpc = new Vpc(this, `${id}Vpc`, {
|
|
78
|
-
accountId: props.accountId,
|
|
79
|
-
subnetConfiguration: [
|
|
80
|
-
{
|
|
81
|
-
name: `${id}`,
|
|
82
|
-
subnetType: SubnetType.PUBLIC
|
|
83
|
-
}
|
|
84
|
-
]
|
|
85
|
-
});
|
|
86
|
-
// Artifacts Bucket
|
|
87
|
-
const artifactBucket = new S3Bucket(this, `${id}ArtifactBucket`);
|
|
88
|
-
const managedSecretsBucket = new S3Bucket(this, `${id}ManagedSecretsBucket`);
|
|
89
|
-
const buildkitePrivateSshKey = process.env.BUILDKITE_PRIVATE_SSH_KEY;
|
|
90
|
-
const hasBuildkitePrivateSshKey = buildkitePrivateSshKey !== undefined && buildkitePrivateSshKey !== "";
|
|
91
|
-
if (hasBuildkitePrivateSshKey) {
|
|
92
|
-
// Synth-time secret bake: Source.data() inlines the env var into the
|
|
93
|
-
// CDK asset bundle uploaded to the bootstrap S3 staging bucket. The
|
|
94
|
-
// synth host MUST hold the secret in env, and the CDK staging bucket
|
|
95
|
-
// inherits the secret's blast radius. Treat as Buildkite-only opt-in.
|
|
96
|
-
new BucketDeployment(this, `${id}SshKeyDeployment`, {
|
|
97
|
-
sources: [Source.data("private_ssh_key", buildkitePrivateSshKey)],
|
|
98
|
-
destinationBucket: managedSecretsBucket
|
|
99
|
-
});
|
|
100
|
-
}
|
|
101
|
-
else {
|
|
102
|
-
FjallLogger.warn("'BUILDKITE_PRIVATE_SSH_KEY' environment variable not declared. Skipping upload of private SSH key.");
|
|
103
|
-
}
|
|
104
|
-
const buildkiteAgentToken = process.env.BUILDKITE_AGENT_TOKEN;
|
|
105
|
-
const hasBuildkiteAgentToken = buildkiteAgentToken !== undefined && buildkiteAgentToken !== "";
|
|
106
|
-
const agentToken = new SecureStringParameter(this, `${id}AgentToken`, {
|
|
107
|
-
name: `/buildkite/agentToken`,
|
|
108
|
-
aliasName: `buildkiteAgentToken`,
|
|
109
|
-
value: buildkiteAgentToken,
|
|
110
|
-
overwrite: hasBuildkiteAgentToken,
|
|
111
|
-
tags: tags,
|
|
112
|
-
accountId: this.account,
|
|
113
|
-
region: this.region
|
|
114
|
-
});
|
|
115
|
-
// Buildkite Agent Execution Role
|
|
116
|
-
const agentRole = new Role(this, `${id}AgentRole`, {
|
|
117
|
-
roleName: `${id}AgentRole`,
|
|
118
|
-
description: "Buildkite Agent IAM Role",
|
|
119
|
-
inlinePolicies: {
|
|
120
|
-
["decryptBuildkiteAgentToken"]: new PolicyDocument({
|
|
121
|
-
statements: [
|
|
122
|
-
new PolicyStatement({
|
|
123
|
-
actions: ["kms:Decrypt"],
|
|
124
|
-
resources: [agentToken.cmk.key.keyArn]
|
|
125
|
-
})
|
|
126
|
-
]
|
|
127
|
-
}),
|
|
128
|
-
["readBuildkiteAgentToken"]: new PolicyDocument({
|
|
129
|
-
statements: [
|
|
130
|
-
new PolicyStatement({
|
|
131
|
-
actions: ["ssm:GetParameter"],
|
|
132
|
-
resources: [
|
|
133
|
-
`arn:${this.partition}:ssm:${this.region}:${this.account}:parameter${agentToken.name}`
|
|
134
|
-
]
|
|
135
|
-
})
|
|
136
|
-
]
|
|
137
|
-
}),
|
|
138
|
-
["readManagedSecretsBucket"]: new PolicyDocument({
|
|
139
|
-
statements: [
|
|
140
|
-
new PolicyStatement({
|
|
141
|
-
actions: ["s3:Get*", "s3:List*"],
|
|
142
|
-
resources: [
|
|
143
|
-
managedSecretsBucket.bucketArn,
|
|
144
|
-
`${managedSecretsBucket.bucketArn}/*`
|
|
145
|
-
]
|
|
146
|
-
})
|
|
147
|
-
]
|
|
148
|
-
}),
|
|
149
|
-
["writeArtifactBucket"]: new PolicyDocument({
|
|
150
|
-
statements: [
|
|
151
|
-
new PolicyStatement({
|
|
152
|
-
actions: [
|
|
153
|
-
"s3:GetObject",
|
|
154
|
-
"s3:GetObjectAcl",
|
|
155
|
-
"s3:GetObjectVersion",
|
|
156
|
-
"s3:GetObjectVersionAcl",
|
|
157
|
-
"s3:ListBucket",
|
|
158
|
-
"s3:PutObject",
|
|
159
|
-
"s3:PutObjectAcl",
|
|
160
|
-
"s3:PutObjectVersionAcl"
|
|
161
|
-
],
|
|
162
|
-
resources: [
|
|
163
|
-
artifactBucket.bucketArn,
|
|
164
|
-
`${artifactBucket.bucketArn}/*`
|
|
165
|
-
]
|
|
166
|
-
})
|
|
167
|
-
]
|
|
168
|
-
}),
|
|
169
|
-
["describeInstance"]: new PolicyDocument({
|
|
170
|
-
statements: [
|
|
171
|
-
new PolicyStatement({
|
|
172
|
-
actions: [
|
|
173
|
-
"autoscaling:DescribeAutoScalingInstances",
|
|
174
|
-
"cloudwatch:PutMetricData",
|
|
175
|
-
"cloudformation:DescribeStackResource",
|
|
176
|
-
"ec2:DescribeTags"
|
|
177
|
-
],
|
|
178
|
-
resources: ["*"]
|
|
179
|
-
})
|
|
180
|
-
]
|
|
181
|
-
}),
|
|
182
|
-
["logging"]: new PolicyDocument({
|
|
183
|
-
statements: [
|
|
184
|
-
new PolicyStatement({
|
|
185
|
-
actions: [
|
|
186
|
-
"logs:CreateLogGroup",
|
|
187
|
-
"logs:CreateLogStream",
|
|
188
|
-
"logs:PutLogEvents",
|
|
189
|
-
"logs:DescribeLogGroups",
|
|
190
|
-
"logs:DescribeLogStreams"
|
|
191
|
-
],
|
|
192
|
-
resources: ["*"]
|
|
193
|
-
})
|
|
194
|
-
]
|
|
195
|
-
}),
|
|
196
|
-
["ssm"]: new PolicyDocument({
|
|
197
|
-
statements: [
|
|
198
|
-
new PolicyStatement({
|
|
199
|
-
actions: [
|
|
200
|
-
"ssm:DescribeInstanceProperties",
|
|
201
|
-
"ssm:ListAssociations",
|
|
202
|
-
"ssm:PutInventory",
|
|
203
|
-
"ssm:UpdateInstanceInformation",
|
|
204
|
-
"ssmmessages:CreateControlChannel",
|
|
205
|
-
"ssmmessages:CreateDataChannel",
|
|
206
|
-
"ssmmessages:OpenControlChannel",
|
|
207
|
-
"ssmmessages:OpenDataChannel",
|
|
208
|
-
"ec2messages:AcknowledgeMessage",
|
|
209
|
-
"ec2messages:DeleteMessage",
|
|
210
|
-
"ec2messages:FailMessage",
|
|
211
|
-
"ec2messages:GetEndpoint",
|
|
212
|
-
"ec2messages:GetMessages",
|
|
213
|
-
"ec2messages:SendReply"
|
|
214
|
-
],
|
|
215
|
-
resources: ["*"]
|
|
216
|
-
})
|
|
217
|
-
]
|
|
218
|
-
})
|
|
219
|
-
},
|
|
220
|
-
assumedBy: new CompositePrincipal(new ServicePrincipal("autoscaling.amazonaws.com"), new ServicePrincipal("ec2.amazonaws.com"))
|
|
221
|
-
});
|
|
222
|
-
// Buildkite Agent EC2 User Data
|
|
223
|
-
const multipartUserData = new MultipartUserData();
|
|
224
|
-
// Cloud Config
|
|
225
|
-
const cloudConfigUserData = UserData.forLinux({
|
|
226
|
-
shebang: "#cloud-config"
|
|
227
|
-
});
|
|
228
|
-
cloudConfigUserData.addCommands("cloud_final_modules:", " - [scripts-user, always]");
|
|
229
|
-
multipartUserData.addPart(MultipartBody.fromUserData(cloudConfigUserData, "text/cloud-config; charset='us-ascii'"));
|
|
230
|
-
// Mount Storage
|
|
231
|
-
const mountStorageUserData = UserData.forLinux({
|
|
232
|
-
shebang: "#!/bin/bash -v"
|
|
233
|
-
});
|
|
234
|
-
mountStorageUserData.addCommands(`BUILDKITE_ENABLE_INSTANCE_STORAGE='${props.enableInstanceStorage}' \\`, `BUILDKITE_MOUNT_TMPFS_AT_TMP='${props.mountTmpfsAtTmp}' \\`, "/usr/local/bin/bk-mount-instance-storage.sh");
|
|
235
|
-
multipartUserData.addPart(MultipartBody.fromUserData(mountStorageUserData, "text/x-shellscript; charset='us-ascii'"));
|
|
236
|
-
// Configure Docker
|
|
237
|
-
const configureDockerUserData = UserData.forLinux({
|
|
238
|
-
shebang: "#!/bin/bash -v"
|
|
239
|
-
});
|
|
240
|
-
configureDockerUserData.addCommands(`DOCKER_USERNS_REMAP='${props.enableDockerUserNamespaceRemap}' \\`, `DOCKER_EXPERIMENTAL='${props.enableDockerExperimental}' \\`, `DOCKER_NETWORKING_PROTOCOL='${props.dockerNetworkingProtocol}' \\`, `BUILDKITE_ENABLE_INSTANCE_STORAGE='${props.enableInstanceStorage}' \\`, "/usr/local/bin/bk-configure-docker.sh");
|
|
241
|
-
multipartUserData.addPart(MultipartBody.fromUserData(configureDockerUserData, "text/x-shellscript; charset='us-ascii'"));
|
|
242
|
-
const installElasticStackUserData = UserData.forLinux({
|
|
243
|
-
shebang: "#!/bin/bash -v"
|
|
244
|
-
});
|
|
245
|
-
installElasticStackUserData.addCommands(`BUILDKITE_STACK_NAME='${id}' \\`, `BUILDKITE_STACK_VERSION='${props.elasticStackVersion}' \\`, `BUILDKITE_SCALE_IN_IDLE_PERIOD='${props.scaleInIdlePeriod}' \\`, `BUILDKITE_SECRETS_BUCKET='${managedSecretsBucket.bucketName}' \\`, `BUILDKITE_SECRETS_BUCKET_REGION='${props.env?.region}' \\`, `BUILDKITE_AGENT_TOKEN_PATH='${agentToken.name}' \\`, `BUILDKITE_AGENTS_PER_INSTANCE='${props.agentsPerInstance}' \\`, `BUILDKITE_AGENT_TAGS='${props.buildkiteAgentTags}' \\`, `BUILDKITE_AGENT_TIMESTAMP_LINES='${props.buildkiteAgentTimestampLines}' \\`, `BUILDKITE_AGENT_EXPERIMENTS='${props.buildkiteAgentExperiments}' \\`, `BUILDKITE_AGENT_TRACING_BACKEND='${props.buildkiteAgentTracingBackend}' \\`, `BUILDKITE_AGENT_RELEASE='${props.buildkiteAgentRelease}' \\`, `BUILDKITE_AGENT_CANCEL_GRACE_PERIOD='${props.buildkiteAgentCancelGracePeriod}' \\`, `BUILDKITE_AGENT_SIGNING_KMS_KEY='${props.pipelineSigningKMSKey}' \\`, `BUILDKITE_AGENT_SIGNING_FAILURE_BEHAVIOR='${props.pipelineSigningVerificationFailureBehavior}' \\`, `BUILDKITE_QUEUE='${props.buildkiteQueue}' \\`, `BUILDKITE_AGENT_ENABLE_GIT_MIRRORS='${props.buildkiteAgentEnableGitMirrors}' \\`, `BUILDKITE_ELASTIC_BOOTSTRAP_SCRIPT='${props.bootstrapScriptUrl}' \\`, `BUILDKITE_ENV_FILE_URL='${props.agentEnvFileUrl}' \\`, `BUILDKITE_ENABLE_INSTANCE_STORAGE='${props.enableInstanceStorage}' \\`, `BUILDKITE_AUTHORIZED_USERS_URL='${props.authorizedUsersUrl}' \\`, `BUILDKITE_ECR_POLICY='${props.ecrAccessPolicy}' \\`, `BUILDKITE_TERMINATE_INSTANCE_AFTER_JOB='${props.buildkiteTerminateInstanceAfterJob}' \\`, `BUILDKITE_ADDITIONAL_SUDO_PERMISSIONS='${props.buildkiteAdditionalSudoPermissions}' \\`, `AWS_DEFAULT_REGION='${props.env?.region}' \\`, `SECRETS_PLUGIN_ENABLED='${props.enableSecretsPlugin}' \\`, `ECR_PLUGIN_ENABLED='${props.enableEcrPlugin}' \\`, `DOCKER_LOGIN_PLUGIN_ENABLED='${props.enableDockerLoginPlugin}' \\`, `DOCKER_EXPERIMENTAL='${props.enableDockerExperimental}' \\`, `DOCKER_USERNS_REMAP='${props.enableDockerUserNamespaceRemap}' \\`, `AWS_REGION='${props.env?.region}' \\`, "/usr/local/bin/bk-install-elastic-stack.sh");
|
|
246
|
-
// Merge User Data
|
|
247
|
-
multipartUserData.addPart(MultipartBody.fromUserData(installElasticStackUserData, "text/x-shellscript; charset='us-ascii'"));
|
|
248
|
-
const ec2Instance = new Ec2Instance(this, `${id}Agent`, {
|
|
249
|
-
serviceName: `${id}Agent`,
|
|
250
|
-
vpc,
|
|
251
|
-
vpcSubnets: { subnetType: SubnetType.PUBLIC },
|
|
252
|
-
instanceType: props.agentInstanceType.toString(),
|
|
253
|
-
machineImage: MachineImage.lookup({
|
|
254
|
-
name: "buildkite-stack-linux-x86_64-*",
|
|
255
|
-
owners: ["172840064832"],
|
|
256
|
-
filters: {
|
|
257
|
-
["block-device-mapping.volume-type"]: ["gp3"]
|
|
258
|
-
}
|
|
259
|
-
}),
|
|
260
|
-
userData: multipartUserData,
|
|
261
|
-
role: agentRole,
|
|
262
|
-
blockDevices: [
|
|
263
|
-
{
|
|
264
|
-
deviceName: "/dev/xvda",
|
|
265
|
-
volume: safeEbs(props.agentVolumeSize)
|
|
266
|
-
}
|
|
267
|
-
],
|
|
268
|
-
minCapacity: props.agentMinInstances,
|
|
269
|
-
maxCapacity: props.agentMaxInstances,
|
|
270
|
-
spotCapacityPercentage: props.spotCapacityPercentage
|
|
271
|
-
});
|
|
272
|
-
Tags.of(ec2Instance).add("Role", "buildkiteAgent");
|
|
273
|
-
Tags.of(ec2Instance).add("BuildkiteAgentRelease", props.buildkiteAgentRelease);
|
|
274
|
-
Tags.of(ec2Instance).add("BuildkiteQueue", props.buildkiteQueue);
|
|
275
|
-
const autoScalingGroup = ec2Instance.getAutoScalingGroup();
|
|
276
|
-
agentRole.attachInlinePolicy(new Policy(this, `${id}UpdateAutoScalingGroupPolicy`, {
|
|
277
|
-
statements: [
|
|
278
|
-
new PolicyStatement({
|
|
279
|
-
actions: [
|
|
280
|
-
"autoscaling:SetInstanceHealth",
|
|
281
|
-
"autoscaling:TerminateInstanceInAutoScalingGroup"
|
|
282
|
-
],
|
|
283
|
-
resources: [`${autoScalingGroup.autoScalingGroupArn}`]
|
|
284
|
-
})
|
|
285
|
-
]
|
|
286
|
-
}));
|
|
287
|
-
new SamApplication(this, `${id}AgentScaler`, {
|
|
288
|
-
applicationId: "arn:aws:serverlessrepo:us-east-1:172840064832:applications/buildkite-agent-scaler",
|
|
289
|
-
semanticVersion: props.buildkiteAgentScalerVersion,
|
|
290
|
-
parameters: {
|
|
291
|
-
BuildkiteAgentTokenParameter: `${agentToken.name}`,
|
|
292
|
-
BuildkiteAgentTokenParameterStoreKMSKey: agentToken.cmk.key.keyId,
|
|
293
|
-
RolePermissionsBoundaryARN: "",
|
|
294
|
-
BuildkiteQueue: props.buildkiteQueue,
|
|
295
|
-
AgentsPerInstance: `${props.agentsPerInstance}`,
|
|
296
|
-
MinSize: `${props.agentMinInstances}`,
|
|
297
|
-
MaxSize: `${props.agentMaxInstances}`,
|
|
298
|
-
AgentAutoScaleGroup: autoScalingGroup.autoScalingGroupName,
|
|
299
|
-
ScaleOutFactor: props.scaleOutFactor,
|
|
300
|
-
ScaleOutForWaitingJobs: `${props.scaleOutWaitingForJobs}`,
|
|
301
|
-
EventSchedulePeriod: props.scalerEventSchedulePeriod,
|
|
302
|
-
MinPollInterval: props.scalerMinPollInterval,
|
|
303
|
-
LogRetentionDays: `${props.logRetentionDays}`
|
|
304
|
-
},
|
|
305
|
-
costAllocationService: "buildkite",
|
|
306
|
-
costAllocationDomain: "buildkite-agent-scaler"
|
|
307
|
-
});
|
|
308
|
-
}
|
|
309
|
-
}
|
|
310
|
-
export default Buildkite;
|
|
1
|
+
/**
|
|
2
|
+
* Self-hosted Buildkite agent fleet — barrel for the `buildkite/` modules.
|
|
3
|
+
* The pre-2026-07 `Buildkite extends Stack` implementation is replaced by a
|
|
4
|
+
* Construct instantiated via `App.addBuildkite()`; design:
|
|
5
|
+
* `aiDocs/designs/2026-07-18-buildkite-selfhosted-agents.md`.
|
|
6
|
+
*/
|
|
7
|
+
export { Buildkite, FJALL_ENV_HOOK_OBJECT_KEY, buildFjallApiKeyEnvHookScript } from "./buildkite/buildkite.js";
|
|
8
|
+
export { BUILDKITE_AMI_OWNER_ACCOUNT_ID, BUILDKITE_CPU_ARCHITECTURES, BUILDKITE_STACK_PINS, resolvePinnedAmiId, resolveScalerSarApplicationArn } from "./buildkite/pins.js";
|
|
9
|
+
export { BuildkitePropsSchema, validateBuildkiteProps } from "./buildkite/schema.js";
|
|
10
|
+
export { BUILDKITE_AGENT_IAM_ACTION_ALLOWLIST, buildAgentRole } from "./buildkite/iam.js";
|
|
11
|
+
export { BUILDKITE_DOCKER_PART_ENV_KEYS, BUILDKITE_MOUNT_PART_ENV_KEYS, BUILDKITE_USER_DATA_ENV_KEYS, buildBuildkiteDockerCommands, buildBuildkiteInstallCommands, buildBuildkiteMountCommands, buildBuildkiteUserData } from "./buildkite/userData.js";
|