Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

codepipeline notication #130

Merged
merged 3 commits into from
Mar 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading