@xube/kit-aws-infrastructure 0.0.101 → 0.0.102

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.
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=helpers.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../src/helpers.ts"],"names":[],"mappings":""}
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
package/dist/index.d.ts CHANGED
@@ -1,3 +1,9 @@
1
1
  export * from "./api/rest-api";
2
2
  export * from "./cognito/pool";
3
+ export * from "./pipeline/constants";
4
+ export * from "./pipeline/helpers";
5
+ export * from "./pipeline/source";
6
+ export * from "./pipeline/xube-build-step";
7
+ export * from "./pipeline/xube-deploy-stage";
8
+ export * from "./pipeline/xube-pipeline";
3
9
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAC;AAC/B,cAAc,gBAAgB,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAC;AAC/B,cAAc,gBAAgB,CAAC;AAE/B,cAAc,sBAAsB,CAAC;AACrC,cAAc,oBAAoB,CAAC;AACnC,cAAc,mBAAmB,CAAC;AAClC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,8BAA8B,CAAC;AAC7C,cAAc,0BAA0B,CAAC"}
package/dist/index.js CHANGED
@@ -16,3 +16,9 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./api/rest-api"), exports);
18
18
  __exportStar(require("./cognito/pool"), exports);
19
+ __exportStar(require("./pipeline/constants"), exports);
20
+ __exportStar(require("./pipeline/helpers"), exports);
21
+ __exportStar(require("./pipeline/source"), exports);
22
+ __exportStar(require("./pipeline/xube-build-step"), exports);
23
+ __exportStar(require("./pipeline/xube-deploy-stage"), exports);
24
+ __exportStar(require("./pipeline/xube-pipeline"), exports);
@@ -0,0 +1,5 @@
1
+ export declare const DEFAULT_CDK_OUTPUT_PATH = "./services/cdk.out";
2
+ export declare const NPM_AUTH_TOKEN_ENV_VAR_NAME = "NPM_AUTH_TOKEN";
3
+ export declare const DEFAULT_INSTALL_COMMANDS: string[];
4
+ export declare const DEFAULT_BUILD_COMMANDS: string[];
5
+ //# sourceMappingURL=constants.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../src/pipeline/constants.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,uBAAuB,uBAAuB,CAAC;AAE5D,eAAO,MAAM,2BAA2B,mBAAmB,CAAC;AAE5D,eAAO,MAAM,wBAAwB,UAsBpC,CAAC;AAEF,eAAO,MAAM,sBAAsB,UAKlC,CAAA"}
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.DEFAULT_BUILD_COMMANDS = exports.DEFAULT_INSTALL_COMMANDS = exports.NPM_AUTH_TOKEN_ENV_VAR_NAME = exports.DEFAULT_CDK_OUTPUT_PATH = void 0;
4
+ exports.DEFAULT_CDK_OUTPUT_PATH = "./services/cdk.out";
5
+ exports.NPM_AUTH_TOKEN_ENV_VAR_NAME = "NPM_AUTH_TOKEN";
6
+ exports.DEFAULT_INSTALL_COMMANDS = [
7
+ "n 18",
8
+ "corepack enable",
9
+ "yarn set version 3.6.1",
10
+ "node --version",
11
+ "npm --version",
12
+ "yarn --version",
13
+ 'yarn config set "nodeLinker" "node-modules"',
14
+ 'yarn config set "npmScopes.inside-labs.npmRegistryServer" "https://npm.pkg.github.com"',
15
+ 'yarn config set "npmScopes.inside-labs.npmPublishRegistry" "https://npm.pkg.github.com"',
16
+ 'yarn config set "npmScopes.inside-labs.npmAlwaysAuth" "true"',
17
+ `yarn config set "npmScopes.inside-labs.npmAuthToken" "\${${exports.NPM_AUTH_TOKEN_ENV_VAR_NAME}}"`,
18
+ "yarn plugin import workspace-tools",
19
+ // "yarn install --immutable",
20
+ "YARN_ENABLE_IMMUTABLE_INSTALLS=false yarn install",
21
+ ];
22
+ exports.DEFAULT_BUILD_COMMANDS = [
23
+ "yarn build",
24
+ "yarn test",
25
+ "cd services",
26
+ "npx cdk synth",
27
+ ];
@@ -0,0 +1,3 @@
1
+ import { XubeEnvironment } from "@xube/kit-aws-schema";
2
+ export declare const getPipelineArn: (env: XubeEnvironment, name: string) => string;
3
+ //# sourceMappingURL=helpers.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../../src/pipeline/helpers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAEvD,eAAO,MAAM,cAAc,QACpB,eAAe,QACd,MAAM,KACX,MAC0D,CAAC"}
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getPipelineArn = void 0;
4
+ const getPipelineArn = (env, name) => `arn:aws:codepipeline:${env.region}:${env.account}:${name}`;
5
+ exports.getPipelineArn = getPipelineArn;
@@ -0,0 +1,16 @@
1
+ import { Construct } from "constructs";
2
+ import { CodePipelineSource } from "aws-cdk-lib/pipelines";
3
+ import { XubeEnvironment } from "@xube/kit-aws-schema";
4
+ import { CfnConnection } from "aws-cdk-lib/aws-codeconnections";
5
+ interface XubeBuildGithubSourceProps extends XubeEnvironment {
6
+ codeStarConnection?: CfnConnection;
7
+ org: string;
8
+ repo: string;
9
+ branch: string;
10
+ }
11
+ export declare class XubeBuildSource extends Construct {
12
+ pipelineSource: CodePipelineSource;
13
+ constructor(scope: Construct, id: string, props: XubeBuildGithubSourceProps);
14
+ }
15
+ export {};
16
+ //# sourceMappingURL=source.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"source.d.ts","sourceRoot":"","sources":["../../src/pipeline/source.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AACvC,OAAO,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAC3D,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,EAAE,aAAa,EAAE,MAAM,iCAAiC,CAAC;AAEhE,UAAU,0BAA2B,SAAQ,eAAe;IAC1D,kBAAkB,CAAC,EAAE,aAAa,CAAC;IACnC,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,qBAAa,eAAgB,SAAQ,SAAS;IAC5C,cAAc,EAAE,kBAAkB,CAAC;gBACvB,KAAK,EAAE,SAAS,EAAE,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,0BAA0B;CAkB5E"}
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.XubeBuildSource = void 0;
4
+ const constructs_1 = require("constructs");
5
+ const pipelines_1 = require("aws-cdk-lib/pipelines");
6
+ const aws_codeconnections_1 = require("aws-cdk-lib/aws-codeconnections");
7
+ class XubeBuildSource extends constructs_1.Construct {
8
+ constructor(scope, id, props) {
9
+ super(scope, id);
10
+ const codeStarConnection = props.codeStarConnection ??
11
+ new aws_codeconnections_1.CfnConnection(scope, id + "codestar-connection", {
12
+ providerType: "GitHub",
13
+ connectionName: "xube-conns",
14
+ });
15
+ this.pipelineSource = pipelines_1.CodePipelineSource.connection(`${props.org}/${props.repo}`, props.branch, {
16
+ connectionArn: codeStarConnection.attrConnectionArn,
17
+ });
18
+ }
19
+ }
20
+ exports.XubeBuildSource = XubeBuildSource;
@@ -0,0 +1,39 @@
1
+ import { Construct } from "constructs";
2
+ import { CodeBuildStep, CodePipelineSource } from "aws-cdk-lib/pipelines";
3
+ import { XubeEnvironment } from "@xube/kit-aws-schema";
4
+ /**
5
+ * In order for the Build to Run there needs to be a secret value added to secrets manager containing the github auth token for inside labs
6
+ * with the name: "il-github-auth-token"
7
+ *
8
+ * @param repository
9
+ * The repository name for the domain that owns this pipeline.
10
+ *
11
+ * @param installCommands
12
+ * The commands that must be run in preparation for build commands.
13
+ *
14
+ * @param commands
15
+ * The commands that must be run after install has been completed.
16
+ *
17
+ * @param branchName
18
+ * The branch name to trigger this pipeline deployment.
19
+ *
20
+ * default: the deploymentEnvironment
21
+ *
22
+ * @param cdkOutPath
23
+ * Location of the cdk output when synth is completed (generally in cdk.out in the cdk directory)
24
+ */
25
+ interface XubeBuildStepProps extends XubeEnvironment {
26
+ repository: string;
27
+ installCommands?: string[];
28
+ commands?: string[];
29
+ branchName?: string;
30
+ cdkOutPath?: string;
31
+ pipelineSource: CodePipelineSource;
32
+ name: string;
33
+ }
34
+ export declare class XubeBuildStep extends Construct {
35
+ synthCodeBuildStep: CodeBuildStep;
36
+ constructor(scope: Construct, id: string, props: XubeBuildStepProps);
37
+ }
38
+ export {};
39
+ //# sourceMappingURL=xube-build-step.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"xube-build-step.d.ts","sourceRoot":"","sources":["../../src/pipeline/xube-build-step.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AACvC,OAAO,EAAE,aAAa,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAY1E,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAQvD;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,UAAU,kBAAmB,SAAQ,eAAe;IAClD,UAAU,EAAE,MAAM,CAAC;IACnB,eAAe,CAAC,EAAE,MAAM,EAAE,CAAC;IAC3B,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;IACpB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,cAAc,EAAE,kBAAkB,CAAC;IACnC,IAAI,EAAE,MAAM,CAAC;CACd;AAED,qBAAa,aAAc,SAAQ,SAAS;IAC1C,kBAAkB,EAAE,aAAa,CAAC;gBACtB,KAAK,EAAE,SAAS,EAAE,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,kBAAkB;CAkCpE"}
@@ -0,0 +1,38 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.XubeBuildStep = void 0;
4
+ const constructs_1 = require("constructs");
5
+ const pipelines_1 = require("aws-cdk-lib/pipelines");
6
+ const aws_iam_1 = require("aws-cdk-lib/aws-iam");
7
+ const constants_1 = require("./constants");
8
+ class XubeBuildStep extends constructs_1.Construct {
9
+ constructor(scope, id, props) {
10
+ super(scope, id);
11
+ this.synthCodeBuildStep = new pipelines_1.CodeBuildStep(id + "synth-step", {
12
+ input: props.pipelineSource,
13
+ env: {},
14
+ role: new aws_iam_1.Role(scope, id + "-build-synth-role", {
15
+ assumedBy: new aws_iam_1.ServicePrincipal("codebuild.amazonaws.com"),
16
+ managedPolicies: [
17
+ new aws_iam_1.ManagedPolicy(scope, id + "-build-synth-policy", {
18
+ managedPolicyName: id + '-policy',
19
+ statements: [
20
+ new aws_iam_1.PolicyStatement({
21
+ actions: ["cognito-idp:*"],
22
+ effect: aws_iam_1.Effect.ALLOW,
23
+ resources: ["*"],
24
+ }),
25
+ ],
26
+ }),
27
+ ],
28
+ }),
29
+ buildEnvironment: {
30
+ environmentVariables: {},
31
+ },
32
+ installCommands: props.installCommands ?? constants_1.DEFAULT_INSTALL_COMMANDS,
33
+ commands: props.commands ?? constants_1.DEFAULT_BUILD_COMMANDS,
34
+ primaryOutputDirectory: props.cdkOutPath ?? constants_1.DEFAULT_CDK_OUTPUT_PATH,
35
+ });
36
+ }
37
+ }
38
+ exports.XubeBuildStep = XubeBuildStep;
@@ -0,0 +1,13 @@
1
+ import { XubeEnvironment } from "@xube/kit-aws-schema";
2
+ import { Stack, Stage } from "aws-cdk-lib";
3
+ import { Construct } from "constructs";
4
+ interface XubeDeploymentStageProps extends XubeEnvironment {
5
+ generateStacks: ((stage: Stage, props: XubeEnvironment) => Stack)[];
6
+ stageName: string;
7
+ }
8
+ export declare class XubeDeploymentStage extends Stage {
9
+ readonly stacks: Stack[];
10
+ constructor(scope: Construct, id: string, props: XubeDeploymentStageProps);
11
+ }
12
+ export {};
13
+ //# sourceMappingURL=xube-deploy-stage.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"xube-deploy-stage.d.ts","sourceRoot":"","sources":["../../src/pipeline/xube-deploy-stage.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AAC3C,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAEvC,UAAU,wBAAyB,SAAQ,eAAe;IACxD,cAAc,EAAE,CAAC,CAAC,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,eAAe,KAAK,KAAK,CAAC,EAAE,CAAC;IACpE,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,qBAAa,mBAAoB,SAAQ,KAAK;IAC5C,SAAgB,MAAM,EAAE,KAAK,EAAE,CAAM;gBAEzB,KAAK,EAAE,SAAS,EAAE,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,wBAAwB;CAU1E"}
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.XubeDeploymentStage = void 0;
4
+ const aws_cdk_lib_1 = require("aws-cdk-lib");
5
+ class XubeDeploymentStage extends aws_cdk_lib_1.Stage {
6
+ constructor(scope, id, props) {
7
+ super(scope, id, {
8
+ env: props,
9
+ stageName: props.stageName,
10
+ });
11
+ this.stacks = [];
12
+ for (const stackGenerator of props.generateStacks) {
13
+ this.stacks.push(stackGenerator(this, props));
14
+ }
15
+ }
16
+ }
17
+ exports.XubeDeploymentStage = XubeDeploymentStage;
@@ -0,0 +1,14 @@
1
+ import { Construct } from "constructs";
2
+ import { XubeEnvironment } from "@xube/kit-aws-schema";
3
+ import { XubeBuildStep } from "./xube-build-step";
4
+ import { XubeDeploymentStage } from "./xube-deploy-stage";
5
+ interface XubeDeployPipelineProps extends XubeEnvironment {
6
+ name: string;
7
+ xubeBuildStep: XubeBuildStep;
8
+ xubeDeployStage: XubeDeploymentStage;
9
+ }
10
+ export declare class XubeDeployPipeline extends Construct {
11
+ constructor(scope: Construct, id: string, props: XubeDeployPipelineProps);
12
+ }
13
+ export {};
14
+ //# sourceMappingURL=xube-pipeline.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"xube-pipeline.d.ts","sourceRoot":"","sources":["../../src/pipeline/xube-pipeline.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAGvC,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAClD,OAAO,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAE1D,UAAU,uBAAwB,SAAQ,eAAe;IACvD,IAAI,EAAE,MAAM,CAAC;IACb,aAAa,EAAE,aAAa,CAAC;IAC7B,eAAe,EAAE,mBAAmB,CAAC;CACtC;AAED,qBAAa,kBAAmB,SAAQ,SAAS;gBACnC,KAAK,EAAE,SAAS,EAAE,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,uBAAuB;CAYzE"}
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.XubeDeployPipeline = void 0;
4
+ const constructs_1 = require("constructs");
5
+ const pipelines_1 = require("aws-cdk-lib/pipelines");
6
+ class XubeDeployPipeline extends constructs_1.Construct {
7
+ constructor(scope, id, props) {
8
+ super(scope, id);
9
+ const pipeline = new pipelines_1.CodePipeline(this, id + "Pipeline", {
10
+ pipelineName: props.name,
11
+ synth: props.xubeBuildStep.synthCodeBuildStep,
12
+ dockerEnabledForSynth: true,
13
+ dockerEnabledForSelfMutation: true,
14
+ });
15
+ pipeline.addStage(props.xubeDeployStage);
16
+ }
17
+ }
18
+ exports.XubeDeployPipeline = XubeDeployPipeline;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xube/kit-aws-infrastructure",
3
- "version": "0.0.101",
3
+ "version": "0.0.102",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {
@@ -17,12 +17,13 @@
17
17
  },
18
18
  "homepage": "https://github.com/XubeLtd/dev-kit#readme",
19
19
  "devDependencies": {
20
- "@xube/kit-build": "^0.0.101",
20
+ "@xube/kit-build": "^0.0.102",
21
21
  "aws-cdk": "^2.159.1"
22
22
  },
23
23
  "dependencies": {
24
- "@xube/kit-log": "^0.0.101",
25
- "@xube/kit-request": "^0.0.101",
24
+ "@xube/kit-aws-schema": "^0.0.102",
25
+ "@xube/kit-log": "^0.0.102",
26
+ "@xube/kit-request": "^0.0.102",
26
27
  "aws-cdk-lib": "^2.159.1",
27
28
  "aws-lambda": "^1.0.7",
28
29
  "constructs": "^10.3.0"
package/src/helpers.ts ADDED
@@ -0,0 +1 @@
1
+ import { XubeEnvironment } from "@xube/kit-aws-schema";
package/src/index.ts CHANGED
@@ -1,2 +1,9 @@
1
1
  export * from "./api/rest-api";
2
- export * from "./cognito/pool"
2
+ export * from "./cognito/pool";
3
+
4
+ export * from "./pipeline/constants";
5
+ export * from "./pipeline/helpers";
6
+ export * from "./pipeline/source";
7
+ export * from "./pipeline/xube-build-step";
8
+ export * from "./pipeline/xube-deploy-stage";
9
+ export * from "./pipeline/xube-pipeline";
@@ -0,0 +1,34 @@
1
+ export const DEFAULT_CDK_OUTPUT_PATH = "./services/cdk.out";
2
+
3
+ export const NPM_AUTH_TOKEN_ENV_VAR_NAME = "NPM_AUTH_TOKEN";
4
+
5
+ export const DEFAULT_INSTALL_COMMANDS = [
6
+ "n 18",
7
+
8
+ "corepack enable",
9
+
10
+ "yarn set version 3.6.1",
11
+
12
+ "node --version",
13
+ "npm --version",
14
+ "yarn --version",
15
+
16
+ 'yarn config set "nodeLinker" "node-modules"',
17
+
18
+ 'yarn config set "npmScopes.inside-labs.npmRegistryServer" "https://npm.pkg.github.com"',
19
+ 'yarn config set "npmScopes.inside-labs.npmPublishRegistry" "https://npm.pkg.github.com"',
20
+ 'yarn config set "npmScopes.inside-labs.npmAlwaysAuth" "true"',
21
+ `yarn config set "npmScopes.inside-labs.npmAuthToken" "\${${NPM_AUTH_TOKEN_ENV_VAR_NAME}}"`,
22
+
23
+ "yarn plugin import workspace-tools",
24
+
25
+ // "yarn install --immutable",
26
+ "YARN_ENABLE_IMMUTABLE_INSTALLS=false yarn install",
27
+ ];
28
+
29
+ export const DEFAULT_BUILD_COMMANDS = [
30
+ "yarn build",
31
+ "yarn test",
32
+ "cd services",
33
+ "npx cdk synth",
34
+ ]
@@ -0,0 +1,7 @@
1
+ import { XubeEnvironment } from "@xube/kit-aws-schema";
2
+
3
+ export const getPipelineArn = (
4
+ env: XubeEnvironment,
5
+ name: string
6
+ ): string =>
7
+ `arn:aws:codepipeline:${env.region}:${env.account}:${name}`;
@@ -0,0 +1,33 @@
1
+ import { Construct } from "constructs";
2
+ import { CodePipelineSource } from "aws-cdk-lib/pipelines";
3
+ import { XubeEnvironment } from "@xube/kit-aws-schema";
4
+ import { CfnConnection } from "aws-cdk-lib/aws-codeconnections";
5
+
6
+ interface XubeBuildGithubSourceProps extends XubeEnvironment {
7
+ codeStarConnection?: CfnConnection;
8
+ org: string;
9
+ repo: string;
10
+ branch: string;
11
+ }
12
+
13
+ export class XubeBuildSource extends Construct {
14
+ pipelineSource: CodePipelineSource;
15
+ constructor(scope: Construct, id: string, props: XubeBuildGithubSourceProps) {
16
+ super(scope, id);
17
+
18
+ const codeStarConnection =
19
+ props.codeStarConnection ??
20
+ new CfnConnection(scope, id + "codestar-connection", {
21
+ providerType: "GitHub",
22
+ connectionName: "xube-conns",
23
+ });
24
+
25
+ this.pipelineSource = CodePipelineSource.connection(
26
+ `${props.org}/${props.repo}`,
27
+ props.branch,
28
+ {
29
+ connectionArn: codeStarConnection.attrConnectionArn,
30
+ }
31
+ );
32
+ }
33
+ }
@@ -0,0 +1,89 @@
1
+ import { Construct } from "constructs";
2
+ import { CodeBuildStep, CodePipelineSource } from "aws-cdk-lib/pipelines";
3
+ import { aws_codestarconnections } from "aws-cdk-lib";
4
+ import { Secret } from "aws-cdk-lib/aws-secretsmanager";
5
+ import { BuildEnvironmentVariableType } from "aws-cdk-lib/aws-codebuild";
6
+ import {
7
+ Effect,
8
+ ManagedPolicy,
9
+ PolicyStatement,
10
+ Role,
11
+ ServicePrincipal,
12
+ } from "aws-cdk-lib/aws-iam";
13
+ import { CustomPolicy } from "aws-cdk-lib/aws-config";
14
+ import { XubeEnvironment } from "@xube/kit-aws-schema";
15
+ import { CfnConnection } from "aws-cdk-lib/aws-codeconnections";
16
+ import {
17
+ DEFAULT_BUILD_COMMANDS,
18
+ DEFAULT_CDK_OUTPUT_PATH,
19
+ DEFAULT_INSTALL_COMMANDS,
20
+ } from "./constants";
21
+
22
+ /**
23
+ * In order for the Build to Run there needs to be a secret value added to secrets manager containing the github auth token for inside labs
24
+ * with the name: "il-github-auth-token"
25
+ *
26
+ * @param repository
27
+ * The repository name for the domain that owns this pipeline.
28
+ *
29
+ * @param installCommands
30
+ * The commands that must be run in preparation for build commands.
31
+ *
32
+ * @param commands
33
+ * The commands that must be run after install has been completed.
34
+ *
35
+ * @param branchName
36
+ * The branch name to trigger this pipeline deployment.
37
+ *
38
+ * default: the deploymentEnvironment
39
+ *
40
+ * @param cdkOutPath
41
+ * Location of the cdk output when synth is completed (generally in cdk.out in the cdk directory)
42
+ */
43
+ interface XubeBuildStepProps extends XubeEnvironment {
44
+ repository: string;
45
+ installCommands?: string[];
46
+ commands?: string[];
47
+ branchName?: string;
48
+ cdkOutPath?: string;
49
+ pipelineSource: CodePipelineSource;
50
+ name: string;
51
+ }
52
+
53
+ export class XubeBuildStep extends Construct {
54
+ synthCodeBuildStep: CodeBuildStep;
55
+ constructor(scope: Construct, id: string, props: XubeBuildStepProps) {
56
+ super(scope, id);
57
+
58
+ this.synthCodeBuildStep = new CodeBuildStep(id + "synth-step", {
59
+ input: props.pipelineSource,
60
+ env: {},
61
+
62
+ role: new Role(scope, id + "-build-synth-role", {
63
+ assumedBy: new ServicePrincipal("codebuild.amazonaws.com"),
64
+ managedPolicies: [
65
+ new ManagedPolicy(
66
+ scope,
67
+ id + "-build-synth-policy",
68
+ {
69
+ managedPolicyName: id + '-policy',
70
+ statements: [
71
+ new PolicyStatement({
72
+ actions: ["cognito-idp:*"],
73
+ effect: Effect.ALLOW,
74
+ resources: ["*"],
75
+ }),
76
+ ],
77
+ }
78
+ ),
79
+ ],
80
+ }),
81
+ buildEnvironment: {
82
+ environmentVariables: {},
83
+ },
84
+ installCommands: props.installCommands ?? DEFAULT_INSTALL_COMMANDS,
85
+ commands: props.commands ?? DEFAULT_BUILD_COMMANDS,
86
+ primaryOutputDirectory: props.cdkOutPath ?? DEFAULT_CDK_OUTPUT_PATH,
87
+ });
88
+ }
89
+ }
@@ -0,0 +1,23 @@
1
+ import { XubeEnvironment } from "@xube/kit-aws-schema";
2
+ import { Stack, Stage } from "aws-cdk-lib";
3
+ import { Construct } from "constructs";
4
+
5
+ interface XubeDeploymentStageProps extends XubeEnvironment {
6
+ generateStacks: ((stage: Stage, props: XubeEnvironment) => Stack)[];
7
+ stageName: string;
8
+ }
9
+
10
+ export class XubeDeploymentStage extends Stage {
11
+ public readonly stacks: Stack[] = [];
12
+
13
+ constructor(scope: Construct, id: string, props: XubeDeploymentStageProps) {
14
+ super(scope, id, {
15
+ env: props,
16
+ stageName: props.stageName,
17
+ });
18
+
19
+ for (const stackGenerator of props.generateStacks) {
20
+ this.stacks.push(stackGenerator(this, props));
21
+ }
22
+ }
23
+ }
@@ -0,0 +1,27 @@
1
+ import { Construct } from "constructs";
2
+ import { CodePipeline } from "aws-cdk-lib/pipelines";
3
+ import { pipelines } from "aws-cdk-lib";
4
+ import { XubeEnvironment } from "@xube/kit-aws-schema";
5
+ import { XubeBuildStep } from "./xube-build-step";
6
+ import { XubeDeploymentStage } from "./xube-deploy-stage";
7
+
8
+ interface XubeDeployPipelineProps extends XubeEnvironment {
9
+ name: string;
10
+ xubeBuildStep: XubeBuildStep;
11
+ xubeDeployStage: XubeDeploymentStage;
12
+ }
13
+
14
+ export class XubeDeployPipeline extends Construct {
15
+ constructor(scope: Construct, id: string, props: XubeDeployPipelineProps) {
16
+ super(scope, id);
17
+
18
+ const pipeline = new CodePipeline(this, id + "Pipeline", {
19
+ pipelineName: props.name,
20
+ synth: props.xubeBuildStep.synthCodeBuildStep,
21
+ dockerEnabledForSynth: true,
22
+ dockerEnabledForSelfMutation: true,
23
+ });
24
+
25
+ pipeline.addStage(props.xubeDeployStage);
26
+ }
27
+ }
File without changes