cloudcomponents / cdk-constructs

A collection of higher-level reusable cdk constructs
MIT License
623 stars 101 forks source link

bug(cdk-codepipeline-slack): New ENV handling is breaking the Slack notifier #123

Closed netroy closed 2 years ago

netroy commented 2 years ago

I see that you folks switched to get-env-or-die for reading env variables. Since this change, the env fallbacks defined in the code breaks the lambda function completely ('' is false-y in JS).

Previously only one of SLACK_CHANNEL and SLACK_CHANNEL_ID was needed. So, this change breaks the notifier for anyone who was passing in only one of these two env variables.

I've temporarily fixed this by manually patching the lambda code

const bot = new SlackBot({
  token: getEnv('SLACK_BOT_TOKEN'),
  channelName: process.env.SLACK_CHANNEL,
  channelId: null,
  channelTypes: getEnv('SLACK_CHANNEL_TYPES'),
  name: getEnv('SLACK_BOT_NAME', 'Pipeline Bot'),
  icon: getEnv('SLACK_BOT_ICON', ':robot_face:'),
});