dbt-platform-helper 12.6.0__py3-none-any.whl → 13.0.1__py3-none-any.whl

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.

Potentially problematic release.


This version of dbt-platform-helper might be problematic. Click here for more details.

Files changed (38) hide show
  1. dbt_platform_helper/COMMANDS.md +7 -7
  2. dbt_platform_helper/commands/codebase.py +2 -2
  3. dbt_platform_helper/commands/notify.py +5 -3
  4. dbt_platform_helper/commands/pipeline.py +17 -8
  5. dbt_platform_helper/constants.py +3 -1
  6. dbt_platform_helper/domain/codebase.py +35 -16
  7. dbt_platform_helper/domain/config_validator.py +5 -27
  8. dbt_platform_helper/domain/database_copy.py +6 -3
  9. dbt_platform_helper/domain/maintenance_page.py +94 -57
  10. dbt_platform_helper/domain/pipelines.py +53 -127
  11. dbt_platform_helper/domain/terraform_environment.py +4 -0
  12. dbt_platform_helper/providers/aws.py +5 -0
  13. dbt_platform_helper/providers/config.py +2 -2
  14. dbt_platform_helper/providers/ecr.py +20 -0
  15. dbt_platform_helper/providers/files.py +1 -1
  16. dbt_platform_helper/providers/load_balancers.py +4 -2
  17. dbt_platform_helper/providers/platform_config_schema.py +14 -15
  18. dbt_platform_helper/providers/terraform_manifest.py +120 -0
  19. dbt_platform_helper/providers/vpc.py +0 -5
  20. dbt_platform_helper/templates/environment-pipelines/main.tf +2 -2
  21. dbt_platform_helper/templates/environments/main.tf +3 -4
  22. dbt_platform_helper/utils/aws.py +16 -5
  23. {dbt_platform_helper-12.6.0.dist-info → dbt_platform_helper-13.0.1.dist-info}/METADATA +1 -1
  24. {dbt_platform_helper-12.6.0.dist-info → dbt_platform_helper-13.0.1.dist-info}/RECORD +27 -36
  25. dbt_platform_helper/templates/pipelines/codebase/manifest.yml +0 -56
  26. dbt_platform_helper/templates/pipelines/codebase/overrides/.gitignore +0 -12
  27. dbt_platform_helper/templates/pipelines/codebase/overrides/bin/override.ts +0 -8
  28. dbt_platform_helper/templates/pipelines/codebase/overrides/buildspec.deploy.yml +0 -29
  29. dbt_platform_helper/templates/pipelines/codebase/overrides/buildspec.image.yml +0 -48
  30. dbt_platform_helper/templates/pipelines/codebase/overrides/cdk.json +0 -20
  31. dbt_platform_helper/templates/pipelines/codebase/overrides/package-lock.json +0 -4428
  32. dbt_platform_helper/templates/pipelines/codebase/overrides/package.json +0 -27
  33. dbt_platform_helper/templates/pipelines/codebase/overrides/stack.ts +0 -521
  34. dbt_platform_helper/templates/pipelines/codebase/overrides/tsconfig.json +0 -30
  35. dbt_platform_helper/templates/pipelines/codebase/overrides/types.ts +0 -52
  36. {dbt_platform_helper-12.6.0.dist-info → dbt_platform_helper-13.0.1.dist-info}/LICENSE +0 -0
  37. {dbt_platform_helper-12.6.0.dist-info → dbt_platform_helper-13.0.1.dist-info}/WHEEL +0 -0
  38. {dbt_platform_helper-12.6.0.dist-info → dbt_platform_helper-13.0.1.dist-info}/entry_points.txt +0 -0
@@ -1,27 +0,0 @@
1
- {
2
- "name": "override",
3
- "version": "0.1.1",
4
- "bin": {
5
- "override": "bin/override.js"
6
- },
7
- "scripts": {
8
- "build": "tsc",
9
- "watch": "tsc -w",
10
- "cdk": "cdk"
11
- },
12
- "devDependencies": {
13
- "@types/jest": "^29.2.4",
14
- "@types/node": "18.11.15",
15
- "aws-cdk": "2.137.0",
16
- "jest": "^29.3.1",
17
- "ts-jest": "^29.0.3",
18
- "ts-node": "^10.9.1",
19
- "typescript": "~4.9.4"
20
- },
21
- "dependencies": {
22
- "aws-cdk-lib": "2.137.0",
23
- "constructs": "^10.0.0",
24
- "source-map-support": "^0.5.21",
25
- "yaml": "^2.3.4"
26
- }
27
- }
@@ -1,521 +0,0 @@
1
- import * as path from 'path';
2
- import {readFileSync} from "fs";
3
- import {execSync} from "child_process";
4
-
5
- import {parse, stringify} from 'yaml';
6
- import * as cdk from 'aws-cdk-lib';
7
-
8
- import {
9
- CodeStarConnectionListConnectionsOutput,
10
- PipelineManifest,
11
- PipelinesConfiguration,
12
- TransformedStackProps
13
- } from "./types";
14
-
15
- export class TransformedStack extends cdk.Stack {
16
- public readonly template: cdk.cloudformation_include.CfnInclude;
17
- public readonly appName: string;
18
- private pipelineManifest: PipelineManifest;
19
- private codestarConnection: { arn: string; id: string; };
20
- private deployRepository: string;
21
- private codebaseConfiguration: PipelinesConfiguration['codebase_pipelines'][0];
22
- private pipelinesFile: PipelinesConfiguration;
23
-
24
- constructor(scope: cdk.App, id: string, props: TransformedStackProps) {
25
- super(scope, id, props);
26
- this.template = new cdk.cloudformation_include.CfnInclude(this, 'Template', {
27
- templateFile: path.join('.build', 'in.yml'),
28
- });
29
- this.appName = props.appName;
30
-
31
- // Load external configuration
32
- this.loadManifestFiles();
33
- this.loadCodestarConnection();
34
- this.loadGitRemote();
35
-
36
- // Alter cloudformation template
37
- this.createImageBuildProject();
38
- this.createECRRepository();
39
- this.createEventRuleRole();
40
- this.updatePipelineBuildProject();
41
- this.updatePipelines();
42
- this.allowBuildProjectToUseCodestarConnection();
43
- this.allowPipelineToDescribeECRImages();
44
- this.allowPipelineToUseEnvManagerRole();
45
- this.allowBuildProjectToUseEnvManagerRole();
46
- this.uploadPipelineConfiguration();
47
- }
48
-
49
- private createImageBuildProject() {
50
- const filterGroups: Array<Array<{ type: string, pattern: string; }>> = [];
51
- const watchedBranches = new Set(
52
- this.codebaseConfiguration.pipelines.map(p => p.branch)
53
- .filter(p => !!p),
54
- );
55
-
56
- for (const branch of watchedBranches) {
57
- let sanitisedBranch = branch;
58
-
59
- if (branch?.endsWith('*')){
60
- sanitisedBranch?.replace('*', '.*');
61
- } else {
62
- sanitisedBranch = sanitisedBranch?.concat('$');
63
- }
64
-
65
- filterGroups.push([
66
- {type: 'EVENT', pattern: 'PUSH'},
67
- {type: 'HEAD_REF', pattern: `^refs/heads/${sanitisedBranch}`},
68
- ]);
69
- }
70
-
71
- if (this.codebaseConfiguration.pipelines.some(p => p.tag)) {
72
- filterGroups.push([
73
- {type: 'EVENT', pattern: 'PUSH'},
74
- {type: 'HEAD_REF', pattern: '^refs/tags/.*'},
75
- ]);
76
- }
77
-
78
- const envVars = [
79
- {name: 'AWS_ACCOUNT_ID', value: this.account},
80
- {name: 'ECR_REPOSITORY', value: this.ecrRepository()},
81
- {name: 'CODESTAR_CONNECTION_ARN', value: this.codestarConnection.arn},
82
- ];
83
- if (this.additionalEcrRepository()){
84
- envVars.push({name: 'ADDITIONAL_ECR_REPOSITORY', value: this.additionalEcrRepository()});
85
- }
86
-
87
- const imageBuildProject: cdk.aws_codebuild.CfnProject = new cdk.aws_codebuild.CfnProject(this, 'ImageBuildProject', {
88
- name: `codebuild-${this.appName}-${this.pipelineManifest.name}`,
89
- description: `Publish images on push to ${this.codebaseConfiguration.repository}`,
90
- badgeEnabled: true,
91
- encryptionKey: cdk.Fn.importValue(`${this.appName}-ArtifactKey`),
92
- serviceRole: this.template.getResource('BuildProjectRole').getAtt('Arn').toString(),
93
- timeoutInMinutes: 30,
94
- visibility: 'PRIVATE',
95
- artifacts: {
96
- type: 'NO_ARTIFACTS',
97
- },
98
- cache: {
99
- modes: ['LOCAL_DOCKER_LAYER_CACHE'],
100
- type: 'LOCAL',
101
- },
102
- triggers: {
103
- buildType: 'BUILD',
104
- filterGroups,
105
- webhook: true,
106
- },
107
- environment: {
108
- type: 'LINUX_CONTAINER',
109
- computeType: 'BUILD_GENERAL1_SMALL',
110
- privilegedMode: true,
111
- image: 'public.ecr.aws/uktrade/ci-image-builder:tag-latest',
112
- environmentVariables: envVars,
113
- },
114
- source: {
115
- type: 'GITHUB',
116
- location: `https://github.com/${this.codebaseConfiguration.repository}.git`,
117
- gitCloneDepth: 0,
118
- auth: {type: 'OAUTH'},
119
- gitSubmodulesConfig: {fetchSubmodules: false},
120
- buildSpec: stringify(parse(
121
- readFileSync(path.join(__dirname, 'buildspec.image.yml')).toString('utf-8'),
122
- )),
123
- },
124
- });
125
-
126
- imageBuildProject.node.addDependency(this.template.getResource("BuildProjectRole") as cdk.aws_iam.CfnRole);
127
- imageBuildProject.node.addDependency(this.template.getResource("BuildProjectPolicy") as cdk.aws_iam.CfnPolicy);
128
- }
129
-
130
- private createECRRepository() {
131
- new cdk.aws_ecr.CfnRepository(this, 'ECRRepository', {
132
- repositoryName: `${this.appName}/${this.codebaseConfiguration.name}`,
133
- imageTagMutability: 'MUTABLE',
134
- imageScanningConfiguration: {
135
- scanOnPush: true,
136
- },
137
- lifecyclePolicy: {
138
- lifecyclePolicyText: JSON.stringify({
139
- rules: [
140
- {
141
- rulePriority: 1,
142
- description: "Delete untagged images after 7 days",
143
- selection: {
144
- tagStatus: "untagged",
145
- countType: "sinceImagePushed",
146
- countUnit: "days",
147
- countNumber: 7,
148
- },
149
- action: {
150
- type: "expire"
151
- },
152
- },
153
- ],
154
- }),
155
- },
156
- repositoryPolicyText: this.pipelinesFile.accounts ? {
157
- Statement: [
158
- {
159
- Effect: "Allow",
160
- Principal: {
161
- AWS: this.pipelinesFile.accounts?.map(a => `arn:aws:iam::${a}:root`) || [],
162
- },
163
- Action: [
164
- "ecr:BatchCheckLayerAvailability",
165
- "ecr:BatchGetImage",
166
- "ecr:CompleteLayerUpload",
167
- "ecr:GetDownloadUrlForLayer",
168
- "ecr:InitiateLayerUpload",
169
- "ecr:PutImage",
170
- "ecr:UploadLayerPart"
171
- ]
172
- }
173
- ]
174
- } : undefined,
175
- });
176
- }
177
-
178
- private updatePipelineBuildProject() {
179
- const buildProject = this.template.getResource("BuildProject") as cdk.aws_codebuild.CfnProject;
180
-
181
- const currentEnvironment = buildProject.environment as cdk.aws_codebuild.CfnProject.EnvironmentProperty;
182
- const currentEnvironmentVariables = currentEnvironment.environmentVariables as Array<cdk.aws_codebuild.CfnProject.EnvironmentVariableProperty>;
183
- const deployEnvironmentVariables = [
184
- ...currentEnvironmentVariables,
185
- {
186
- name: 'CODESTAR_CONNECTION_ID',
187
- value: this.codestarConnection.id
188
- },
189
- {
190
- name: 'DEPLOY_REPOSITORY',
191
- value: this.deployRepository
192
- },
193
- {
194
- name: 'CODEBASE_REPOSITORY',
195
- value: this.codebaseConfiguration.repository
196
- },
197
- {
198
- name: 'COPILOT_SERVICES',
199
- value: this.codebaseConfiguration.services.join(' ')
200
- },
201
- {
202
- name: 'ECR_REPOSITORY',
203
- value: this.ecrRepository()
204
- },
205
- ];
206
-
207
- if (this.codebaseConfiguration.deploy_repository_branch){
208
- deployEnvironmentVariables.push({name: 'DEPLOY_REPOSITORY_BRANCH', value: this.codebaseConfiguration.deploy_repository_branch})
209
- }
210
-
211
- buildProject.environment = {
212
- ...buildProject.environment,
213
- image: 'public.ecr.aws/uktrade/ci-image-builder:tag-latest',
214
- environmentVariables: deployEnvironmentVariables
215
- } as cdk.aws_codebuild.CfnProject.EnvironmentProperty;
216
-
217
- const currentSource = buildProject.source as cdk.aws_codebuild.CfnProject.SourceProperty;
218
-
219
- buildProject.source = {
220
- ...currentSource,
221
- buildSpec: stringify(parse(
222
- readFileSync(path.join(__dirname, 'buildspec.deploy.yml')).toString('utf-8'),
223
- )),
224
- };
225
- }
226
-
227
- private updatePipelines() {
228
- const existingPipeline = this.template.getResource("Pipeline") as cdk.aws_codepipeline.CfnPipeline;
229
-
230
- // Here we co-opt the existing pipeline resource to alter covering our first pipeline.
231
- const [firstPipelineConfiguration] = this.codebaseConfiguration.pipelines.splice(0, 1);
232
- this.updateExistingPipeline(existingPipeline, firstPipelineConfiguration);
233
-
234
- for (const [index, pipelineConfiguration] of this.codebaseConfiguration.pipelines.entries()) {
235
- this.createPipeline(index, pipelineConfiguration, existingPipeline);
236
- }
237
- }
238
-
239
- private ecrRepository(){
240
- return cdk.Fn.ref('ECRRepository');
241
- }
242
-
243
- private additionalEcrRepository(){
244
- return this.codebaseConfiguration.additional_ecr_repository || "";
245
- }
246
-
247
- private createPipeline(index: number, pipelineConfig: PipelinesConfiguration['codebase_pipelines'][0]['pipelines'][0], existingPipeline: cdk.aws_codepipeline.CfnPipeline) {
248
- const pipeline = new cdk.aws_codepipeline.CfnPipeline(this, `Pipeline${index + 1}`, {
249
- name: `pipeline-${this.appName}-${this.codebaseConfiguration.name}-${pipelineConfig.name}`,
250
- roleArn: cdk.Fn.getAtt('PipelineRole', 'Arn').toString(),
251
- artifactStores: existingPipeline.artifactStores,
252
- stages: [
253
- {
254
- name: "Source",
255
- actions: [
256
- {
257
- name: 'ImagePublished',
258
- runOrder: 1,
259
- configuration: {
260
- RepositoryName: this.ecrRepository(),
261
- ImageTag: pipelineConfig.tag ? 'tag-latest' : `branch-${pipelineConfig.branch?.replace(/\//gi, '-')}`,
262
- },
263
- outputArtifacts: [{name: 'ECRMetadata'}],
264
- actionTypeId: {
265
- category: 'Source',
266
- owner: 'AWS',
267
- version: '1',
268
- provider: 'ECR',
269
- },
270
- },
271
- ],
272
- },
273
- ],
274
- });
275
-
276
- this.addPipelineStages(pipelineConfig, pipeline);
277
- this.createEventRule(pipeline, pipelineConfig, (index + 1).toString());
278
- }
279
-
280
- private updateExistingPipeline(pipeline: cdk.aws_codepipeline.CfnPipeline, pipelineConfig: typeof this.codebaseConfiguration['pipelines'][0]) {
281
- // Update the pipeline name
282
- pipeline.name = `pipeline-${this.appName}-${this.codebaseConfiguration.name}-${pipelineConfig.name}`;
283
-
284
- // Replace source code action trigger with ECR push
285
- pipeline.stages[0].actions[0] = {
286
- name: 'ImagePublished',
287
- runOrder: 1,
288
- configuration: {
289
- RepositoryName: this.ecrRepository(),
290
- ImageTag: pipelineConfig.tag ? 'tag-latest' : `branch-${pipelineConfig.branch}`,
291
- },
292
- outputArtifacts: [{name: 'ECRMetadata'}],
293
- actionTypeId: {
294
- category: 'Source',
295
- owner: 'AWS',
296
- version: '1',
297
- provider: 'ECR',
298
- },
299
- };
300
-
301
- // Remove all other stages
302
- (pipeline.stages as Array<unknown>).splice(1, (pipeline.stages as Array<unknown>).length - 1);
303
-
304
- this.addPipelineStages(pipelineConfig, pipeline);
305
- this.createEventRule(pipeline, pipelineConfig);
306
- }
307
-
308
- private addPipelineStages(pipelineConfig: typeof this.codebaseConfiguration['pipelines'][0], pipeline: cdk.aws_codepipeline.CfnPipeline) {
309
- for (const environment of pipelineConfig.environments) {
310
- const environmentStage: {
311
- name: string;
312
- actions: Array<cdk.aws_codepipeline.CfnPipeline.ActionDeclarationProperty>;
313
- } = {name: `DeployTo-${environment.name}`, actions: []};
314
-
315
- if (environment.requires_approval) {
316
- environmentStage.actions.push({
317
- actionTypeId: {
318
- category: "Approval",
319
- owner: "AWS",
320
- provider: "Manual",
321
- version: "1"
322
- },
323
- name: `ApprovePromotionTo-${environment.name}`,
324
- runOrder: 1
325
- });
326
- }
327
-
328
- environmentStage.actions.push({
329
- name: 'Deploy',
330
- runOrder: environment.requires_approval ? 2 : 1,
331
- inputArtifacts: [
332
- {name: 'ECRMetadata'},
333
- ],
334
- actionTypeId: {
335
- category: 'Build',
336
- owner: 'AWS',
337
- version: '1',
338
- provider: 'CodeBuild',
339
- },
340
- configuration: {
341
- ProjectName: cdk.Fn.ref('BuildProject'),
342
- PrimarySource: 'ECRMetadata',
343
- EnvironmentVariables: JSON.stringify([
344
- {name: 'COPILOT_ENVIRONMENT', value: environment.name},
345
- {
346
- name: 'ECR_TAG_PATTERN',
347
- value: pipelineConfig.tag ? 'tag-latest' : `branch-${pipelineConfig.branch}`
348
- },
349
- ]),
350
- },
351
- });
352
-
353
- (pipeline.stages as Array<cdk.aws_codepipeline.CfnPipeline.StageDeclarationProperty>).push(environmentStage);
354
- }
355
- }
356
-
357
- private createEventRuleRole() {
358
- new cdk.aws_iam.CfnRole(this, 'EventRole', {
359
- roleName: `${this.appName}-${this.codebaseConfiguration.name}-pipeline-trigger-role`,
360
- assumeRolePolicyDocument: {
361
- Statement: [{
362
- Effect: "Allow",
363
- Principal: {
364
- Service: "events.amazonaws.com"
365
- },
366
- Action: "sts:AssumeRole"
367
- }],
368
- },
369
- policies: [{
370
- policyName: `${this.appName}-${this.codebaseConfiguration.name}-pipeline-trigger-policy`,
371
- policyDocument: {
372
- Statement: [{
373
- Effect: 'Allow',
374
- Action: ["codepipeline:StartPipelineExecution"],
375
- Resource: ["*"],
376
- }],
377
- }
378
- }]
379
- });
380
- }
381
-
382
- private createEventRule(pipeline: cdk.aws_codepipeline.CfnPipeline, pipelineConfig: PipelinesConfiguration['codebase_pipelines'][0]['pipelines'][0], suffix: string = '') {
383
- const watchImageTag = pipelineConfig.tag ? 'tag-latest' : `branch-${pipelineConfig.branch}`;
384
- const ecrRepository = `${this.appName}/${this.codebaseConfiguration.name}`;
385
- new cdk.aws_events.CfnRule(this, `EventRule${suffix}`, {
386
- name: `trigger-${pipeline.name}`,
387
- description: `Trigger the ${pipeline.name} pipeline when a tag called '${watchImageTag}' is pushed to the repo '${ecrRepository}'`,
388
- eventPattern: {
389
- source: ["aws.ecr"],
390
- detail: {
391
- 'action-type': ["PUSH"],
392
- 'image-tag': [watchImageTag],
393
- 'repository-name': [ecrRepository],
394
- result: ["SUCCESS"],
395
- },
396
- },
397
- targets: [{
398
- id: `${pipeline.name}`,
399
- arn: `arn:aws:codepipeline:${this.region}:${this.account}:${pipeline.name}`,
400
- roleArn: cdk.Fn.getAtt('EventRole', 'Arn').toString(),
401
- }]
402
- });
403
- }
404
-
405
- private allowBuildProjectToUseCodestarConnection() {
406
- const buildProjectPolicy = this.template.getResource("BuildProjectPolicy") as cdk.aws_iam.CfnPolicy;
407
- (buildProjectPolicy.policyDocument.Statement as Array<any>).push({
408
- Effect: 'Allow',
409
- Action: [
410
- 'codestar-connections:GetConnectionToken',
411
- 'codestar-connections:UseConnection',
412
- ],
413
- Resource: [this.codestarConnection.arn],
414
- });
415
- }
416
-
417
- private allowPipelineToUseEnvManagerRole() {
418
- const pipelineRolePolicy = this.template.getResource("PipelineRolePolicy") as cdk.aws_iam.CfnPolicy;
419
- (pipelineRolePolicy.policyDocument.Statement as Array<any>).push(
420
- this.getEnvManagerRolePolicyDoc()
421
- );
422
- }
423
-
424
- private allowBuildProjectToUseEnvManagerRole() {
425
- const buildProjectPolicy = this.template.getResource("BuildProjectPolicy") as cdk.aws_iam.CfnPolicy;
426
- (buildProjectPolicy.policyDocument.Statement as Array<any>).push(
427
- this.getEnvManagerRolePolicyDoc()
428
- );
429
- (buildProjectPolicy.policyDocument.Statement as Array<any>).push(
430
- this.addECRBatchDeleteToBuildProjectRolePolicyDoc()
431
- );
432
- }
433
-
434
- private getEnvManagerRolePolicyDoc() {
435
- return {
436
- Effect: 'Allow',
437
- Action: ['sts:AssumeRole'],
438
- Resource: [`arn:aws:iam::${this.account}:role/${this.appName}-*-EnvManagerRole`],
439
- };
440
- }
441
-
442
- private addECRBatchDeleteToBuildProjectRolePolicyDoc() {
443
- return {
444
- Effect: 'Allow',
445
- Action: ['ecr:BatchDeleteImage'],
446
- Resource: ['*'],
447
- };
448
- }
449
-
450
- private allowPipelineToDescribeECRImages() {
451
- const pipelineRolePolicy = this.template.getResource("PipelineRolePolicy") as cdk.aws_iam.CfnPolicy;
452
- pipelineRolePolicy.policyDocument.Statement[0].Action.push('ecr:DescribeImages');
453
- }
454
-
455
- private loadManifestFiles() {
456
- const pipelineRoot = path.join(process.cwd(), '..');
457
- const deployRepoRoot = path.join(pipelineRoot, '..', '..', '..');
458
-
459
- // Load copilot pipeline manifest
460
- this.pipelineManifest = parse(readFileSync(
461
- path.join(pipelineRoot, 'manifest.yml'),
462
- ).toString('utf-8')) as PipelineManifest;
463
-
464
- // Load dbt-platform-helper pipelines configurations
465
- this.pipelinesFile = parse(readFileSync(
466
- path.join(deployRepoRoot, 'platform-config.yml'),
467
- ).toString('utf-8')) as PipelinesConfiguration;
468
-
469
- this.codebaseConfiguration = this.getFullCodebaseConfiguration();
470
- }
471
-
472
- private getFullCodebaseConfiguration() {
473
- const pipelineRoot = path.join(process.cwd(), '..');
474
- const deployRepoRoot = path.join(pipelineRoot, '..', '..', '..');
475
- const pipelinesFile = parse(readFileSync(
476
- path.join(deployRepoRoot, 'platform-config.yml'),
477
- ).toString('utf-8')) as PipelinesConfiguration;
478
-
479
- const codebaseConfiguration = pipelinesFile.codebase_pipelines.find(c => c.name === this.pipelineManifest.name);
480
-
481
- if (!codebaseConfiguration) {
482
- throw new Error(`Could not find a codebase configuration for ${this.pipelineManifest.name}, ensure ./platform-config.yml is up to date`);
483
- }
484
-
485
- return codebaseConfiguration
486
- }
487
-
488
- private loadCodestarConnection() {
489
- const codestarConnections = JSON.parse(execSync('aws codestar-connections list-connections').toString('utf-8')) as CodeStarConnectionListConnectionsOutput;
490
- const codestarConnectionArn = codestarConnections.Connections
491
- .find(c => c.ConnectionName === this.pipelineManifest.source.properties.connection_name)?.ConnectionArn;
492
-
493
- const codestarConnectionId = codestarConnectionArn?.split('/').pop();
494
-
495
- if (!codestarConnectionArn || !codestarConnectionId) {
496
- throw new Error(`Could not find a codestar connection called ${this.pipelineManifest.source.properties.connection_name}, have you created it?`);
497
- }
498
-
499
- this.codestarConnection = {arn: codestarConnectionArn, id: codestarConnectionId};
500
- }
501
-
502
- private loadGitRemote() {
503
- const output = execSync('git remote get-url origin').toString('utf-8');
504
-
505
- if (!output.startsWith('git@')) throw new URIError("Git remote is not an SSH URL.");
506
-
507
- const deployRepository = output.split(':').pop()?.replace('.git', '').replace('\n', '');
508
-
509
- if (!deployRepository) throw new Error("Could not find Git remote.");
510
-
511
- this.deployRepository = deployRepository;
512
- }
513
-
514
- private uploadPipelineConfiguration() {
515
- new cdk.aws_ssm.CfnParameter(this, 'CodebaseConfiguration', {
516
- name: `/copilot/applications/${this.appName}/codebases/${this.codebaseConfiguration.name}`,
517
- type: "String",
518
- value: JSON.stringify(this.getFullCodebaseConfiguration()),
519
- });
520
- }
521
- }
@@ -1,30 +0,0 @@
1
- {
2
- "compilerOptions": {
3
- "target": "ES2020",
4
- "module": "commonjs",
5
- "lib": [
6
- "es2020"
7
- ],
8
- "declaration": true,
9
- "strict": true,
10
- "noImplicitAny": false,
11
- "strictNullChecks": true,
12
- "noImplicitThis": true,
13
- "alwaysStrict": true,
14
- "noUnusedLocals": false,
15
- "noUnusedParameters": false,
16
- "noImplicitReturns": true,
17
- "noFallthroughCasesInSwitch": false,
18
- "inlineSourceMap": true,
19
- "inlineSources": true,
20
- "experimentalDecorators": true,
21
- "strictPropertyInitialization": false,
22
- "typeRoots": [
23
- "./node_modules/@types"
24
- ]
25
- },
26
- "exclude": [
27
- "node_modules",
28
- "cdk.out"
29
- ]
30
- }
@@ -1,52 +0,0 @@
1
- import * as cdk from "aws-cdk-lib";
2
-
3
- export interface TransformedStackProps extends cdk.StackProps {
4
- readonly appName: string;
5
- }
6
-
7
- export interface PipelineManifest {
8
- name: string;
9
- version: 1;
10
- source: {
11
- provider: 'GitHub';
12
- properties: {
13
- branch: string;
14
- repository: string;
15
- connection_name: string;
16
- };
17
- };
18
- stages: Array<{
19
- name: string;
20
- requires_approval?: boolean;
21
- }>;
22
- }
23
-
24
- export interface PipelinesConfiguration {
25
- accounts?: Array<string>;
26
- codebase_pipelines: Array<{
27
- name: string;
28
- repository: string;
29
- deploy_repository_branch?: string;
30
- additional_ecr_repository?: string;
31
- services: Array<string>;
32
- pipelines: Array<{
33
- name: string;
34
- branch?: string;
35
- tag?: boolean;
36
- environments: Array<{
37
- name: string;
38
- requires_approval?: boolean;
39
- }>;
40
- }>;
41
- }>;
42
- }
43
-
44
- export interface CodeStarConnectionListConnectionsOutput {
45
- Connections: Array<{
46
- ConnectionName: string;
47
- ConnectionArn: string;
48
- ProviderType: string;
49
- OwnerAccountId: string;
50
- ConnectionStatus: string;
51
- }>;
52
- }