Skip to content

Commit

Permalink
feat: pre and post deployment commands
Browse files Browse the repository at this point in the history
  • Loading branch information
m-radzikowski committed Aug 13, 2024
1 parent e9c42f8 commit 374eb83
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 1 deletion.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -257,11 +257,15 @@ Commands executed on particular builds:
- `preInstall`
- `install`
- `buildAndTest`
- `preDeployEnvironment`
- `deployEnvironment`
- `postDeployEnvironment`
- feature branch environment destruction:
- `preInstall`
- `install`
- `preDestroyEnvironment`
- `destroyEnvironment`
- `postDestroyEnvironment`
</td>
</tr>
<tr>
Expand Down
37 changes: 36 additions & 1 deletion src/applicationProps.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import {Duration} from 'aws-cdk-lib';
import {ComputeType, LinuxBuildImage} from 'aws-cdk-lib/aws-codebuild';
import {IRole} from 'aws-cdk-lib/aws-iam';
import {CodeBuildOptions, DockerCredential} from 'aws-cdk-lib/pipelines';
Expand Down Expand Up @@ -110,12 +109,48 @@ export interface RepositoryProps {
}

export interface BuildCommands {
/**
* Executed at the beginning of the Build step and feature branch deployment and destruction.
*/
readonly preInstall?: string[];
/**
* Executed after `preInstall` in the Build step and feature branch deployment and destruction.
* By default, installs `aws-cdk@2` globally and `npm` or `pnpm` dependencies if `packageManager` is set.
*/
readonly install?: string[];
/**
* Executed after `install` in the Build step and feature branch deployment.
*/
readonly buildAndTest?: string[];
/**
* Executed after the Build step. By default, synths the CDK app.
*/
readonly synthPipeline?: string[];
/**
* Executed after `buildAndTest` in the feature branch deployment.
*/
readonly preDeployEnvironment?: string[];
/**
* Executed after `preDeployEnvironment` in the feature branch deployment.
* By default, deploys all CDK app stacks to the environment.
*/
readonly deployEnvironment?: string[];
/**
* Executed after `deployEnvironment` in the feature branch deployment.
*/
readonly postDeployEnvironment?: string[];
/**
* Executed after `install` in the feature branch destruction.
*/
readonly preDestroyEnvironment?: string[];
/**
* Executed after `preDestroyEnvironment` in the feature branch destruction.
*/
readonly destroyEnvironment?: string[];
/**
* Executed after `destroyEnvironment` in the feature branch destruction.
*/
readonly postDestroyEnvironment?: string[];
}

export interface WaveDeployment {
Expand Down
4 changes: 4 additions & 0 deletions src/constructs/featureBranchBuilds.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,9 @@ export class FeatureBranchBuilds extends Construct {
build: {
commands: [
...(commands.buildAndTest || []),
...(commands.preDeployEnvironment || []),
...commands.deployEnvironment,
...(commands.postDeployEnvironment || []),
],
},
},
Expand Down Expand Up @@ -135,7 +137,9 @@ export class FeatureBranchBuilds extends Construct {
},
build: {
commands: [
...(commands.preDestroyEnvironment || []),
...commands.destroyEnvironment,
...(commands.postDestroyEnvironment || []),
],
},
},
Expand Down

0 comments on commit 374eb83

Please sign in to comment.