@devramps/cli 0.1.29 → 0.1.31

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.
Files changed (2) hide show
  1. package/dist/index.js +41 -18
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -1378,15 +1378,30 @@ async function parsePipeline(basePath, slug) {
1378
1378
  throw new PipelineParseError(slug, `Stage "${stage.name}" is missing region`);
1379
1379
  }
1380
1380
  }
1381
+ if (definition.pipeline.ephemeral_environments) {
1382
+ for (const [name, env] of Object.entries(definition.pipeline.ephemeral_environments)) {
1383
+ if (!env.account_id) {
1384
+ throw new PipelineParseError(slug, `Ephemeral environment "${name}" is missing account_id`);
1385
+ }
1386
+ if (!env.region) {
1387
+ throw new PipelineParseError(slug, `Ephemeral environment "${name}" is missing region`);
1388
+ }
1389
+ }
1390
+ }
1381
1391
  const targetAccountIds = extractTargetAccountIds(definition);
1382
1392
  const steps = extractSteps(definition);
1383
1393
  const additionalPolicies = await parseAdditionalPoliciesForPipeline(basePath, slug);
1384
- verbose(`Pipeline ${slug}: ${targetAccountIds.length} accounts, ${steps.length} steps`);
1394
+ const ephemeralStages = ephemeralEnvironmentsAsStages(definition);
1395
+ const allStages = [...definition.pipeline.stages, ...ephemeralStages];
1396
+ if (ephemeralStages.length > 0) {
1397
+ verbose(`Pipeline ${slug}: ${ephemeralStages.length} ephemeral environment(s) will be bootstrapped as stages`);
1398
+ }
1399
+ verbose(`Pipeline ${slug}: ${targetAccountIds.length} accounts, ${allStages.length} stages, ${steps.length} steps`);
1385
1400
  return {
1386
1401
  slug,
1387
1402
  definition,
1388
1403
  targetAccountIds,
1389
- stages: definition.pipeline.stages,
1404
+ stages: allStages,
1390
1405
  steps,
1391
1406
  additionalPolicies
1392
1407
  };
@@ -1398,8 +1413,26 @@ function extractTargetAccountIds(definition) {
1398
1413
  accountIds.add(stage.account_id);
1399
1414
  }
1400
1415
  }
1416
+ if (definition.pipeline.ephemeral_environments) {
1417
+ for (const env of Object.values(definition.pipeline.ephemeral_environments)) {
1418
+ if (env.account_id) {
1419
+ accountIds.add(env.account_id);
1420
+ }
1421
+ }
1422
+ }
1401
1423
  return Array.from(accountIds);
1402
1424
  }
1425
+ function ephemeralEnvironmentsAsStages(definition) {
1426
+ const envs = definition.pipeline.ephemeral_environments;
1427
+ if (!envs) return [];
1428
+ return Object.entries(envs).map(([name, env]) => ({
1429
+ name: `ephemeral-${name}`,
1430
+ account_id: env.account_id,
1431
+ region: env.region,
1432
+ skip: env.skip,
1433
+ vars: env.vars
1434
+ }));
1435
+ }
1403
1436
  function extractSteps(definition) {
1404
1437
  return definition.pipeline.steps || [];
1405
1438
  }
@@ -2116,6 +2149,12 @@ function buildOrgRolePolicies(orgSlug) {
2116
2149
  ],
2117
2150
  Resource: "*"
2118
2151
  },
2152
+ {
2153
+ Sid: "AllowEventBridgePutEvents",
2154
+ Effect: "Allow",
2155
+ Action: "events:PutEvents",
2156
+ Resource: "*"
2157
+ },
2119
2158
  {
2120
2159
  Sid: "AllowSecretsManagerOperations",
2121
2160
  Effect: "Allow",
@@ -2634,22 +2673,6 @@ function buildStagePolicies(steps, additionalPolicies, dockerArtifacts, bundleAr
2634
2673
  ]
2635
2674
  }
2636
2675
  });
2637
- policies.push({
2638
- PolicyName: "DevRampsEventBridgePolicy",
2639
- PolicyDocument: {
2640
- Version: "2012-10-17",
2641
- Statement: [
2642
- {
2643
- Sid: "AllowEventBridgePutEvents",
2644
- Effect: "Allow",
2645
- Action: [
2646
- "events:PutEvents"
2647
- ],
2648
- Resource: "*"
2649
- }
2650
- ]
2651
- }
2652
- });
2653
2676
  const tfStateBucketName = generateTerraformStateBucketName(orgSlug);
2654
2677
  policies.push({
2655
2678
  PolicyName: "DevRampsTerraformStatePolicy",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@devramps/cli",
3
- "version": "0.1.29",
3
+ "version": "0.1.31",
4
4
  "description": "DevRamps CLI - Bootstrap AWS infrastructure for CI/CD pipelines",
5
5
  "main": "dist/index.js",
6
6
  "bin": {