Skip to content

Commit

Permalink
codepipeline notication (#130)
Browse files Browse the repository at this point in the history
  • Loading branch information
williamputraintan authored Mar 6, 2024
1 parent 76a9fa4 commit b0e5509
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 1 deletion.
26 changes: 26 additions & 0 deletions lib/pipeline/orcabus-stateful-pipeline-stack.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ import * as ssm from 'aws-cdk-lib/aws-ssm';
import * as pipelines from 'aws-cdk-lib/pipelines';
import * as codebuild from 'aws-cdk-lib/aws-codebuild';
import * as iam from 'aws-cdk-lib/aws-iam';
import * as codepipeline from 'aws-cdk-lib/aws-codepipeline';
import * as chatbot from 'aws-cdk-lib/aws-chatbot';
import * as codestarnotifications from 'aws-cdk-lib/aws-codestarnotifications';
import { OrcaBusStatefulConfig, OrcaBusStatefulStack } from '../workload/orcabus-stateful-stack';
import { getEnvironmentConfig } from '../../config/constants';

Expand Down Expand Up @@ -108,6 +111,29 @@ export class StatefulPipelineStack extends cdk.Stack {
}),
{ pre: [new pipelines.ManualApprovalStep('PromoteToProd')] }
);

// need to build pipeline so we could add notification at the pipeline construct
pipeline.buildPipeline();

// notification for success/failure
const arteriaDevSlackConfigArn = ssm.StringParameter.valueForStringParameter(
this,
'/chatbot_arn/slack/arteria-dev'
);
const target = chatbot.SlackChannelConfiguration.fromSlackChannelConfigurationArn(
this,
'SlackChannelConfiguration',
arteriaDevSlackConfigArn
);

pipeline.pipeline.notifyOn('PipelineSlackNotification', target, {
events: [
codepipeline.PipelineNotificationEvents.PIPELINE_EXECUTION_FAILED,
codepipeline.PipelineNotificationEvents.PIPELINE_EXECUTION_SUCCEEDED,
],
detailType: codestarnotifications.DetailType.BASIC,
notificationRuleName: 'orcabus_stateful_pipeline_notification',
});
}
}

Expand Down
28 changes: 27 additions & 1 deletion lib/pipeline/orcabus-stateless-pipeline-stack.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ import * as ssm from 'aws-cdk-lib/aws-ssm';
import * as pipelines from 'aws-cdk-lib/pipelines';
import * as codebuild from 'aws-cdk-lib/aws-codebuild';
import * as iam from 'aws-cdk-lib/aws-iam';
import * as chatbot from 'aws-cdk-lib/aws-chatbot';
import * as codepipeline from 'aws-cdk-lib/aws-codepipeline';
import * as codestarnotifications from 'aws-cdk-lib/aws-codestarnotifications';
import { OrcaBusStatelessConfig, OrcaBusStatelessStack } from '../workload/orcabus-stateless-stack';
import { getEnvironmentConfig } from '../../config/constants';

Expand Down Expand Up @@ -129,10 +132,33 @@ export class StatelessPipelineStack extends cdk.Stack {
// if (!prodConfig) throw new Error(`No 'Prod' account configuration`);
// pipeline.addStage(
// new OrcaBusStatelessDeploymentStage(this, 'ProdStatelessDeployment', prodConfig.stackProps, {
// account: gammaConfig?.accountId,
// account: prodConfig?.accountId,
// }),
// { pre: [new pipelines.ManualApprovalStep('PromoteToProd')] }
// );

// need to build pipeline so we could add notification at the pipeline construct
pipeline.buildPipeline();

// notification for success/failure
const arteriaDevSlackConfigArn = ssm.StringParameter.valueForStringParameter(
this,
'/chatbot_arn/slack/arteria-dev'
);
const target = chatbot.SlackChannelConfiguration.fromSlackChannelConfigurationArn(
this,
'SlackChannelConfiguration',
arteriaDevSlackConfigArn
);

pipeline.pipeline.notifyOn('PipelineSlackNotification', target, {
events: [
codepipeline.PipelineNotificationEvents.PIPELINE_EXECUTION_FAILED,
codepipeline.PipelineNotificationEvents.PIPELINE_EXECUTION_SUCCEEDED,
],
detailType: codestarnotifications.DetailType.BASIC,
notificationRuleName: 'orcabus_stateless_pipeline_notification',
});
}
}

Expand Down

0 comments on commit b0e5509

Please sign in to comment.