I’m currently working on s project that doubles down on serverless computing and consumption-based services in general. When it comes to serverless, usually, the first two things that come to mind are AWS Lambda and serverless framework (they nicely capitalize on the similarity of the approach with the product). They nicely play together and we use both, so as other AWS platform services.

When it comes to DevOps, we decided to go with CodeBuild as it can nicely be provisioned as a part of your core infrastructure. It works great, has a build definition that can be versioned in your repository, and so on. However, when it comes to notifications it turns out that there are not many out-of-the-box integrations as let’s say in Azure DevOps and you will need a bit of coding/configuration to make it work.

Webhook Configuration in Microsoft Teams

This part of the configuration is pretty simple and you can find a pretty extensive guide on the incoming webhooks configuration in Microsoft documentation.

Configure CodeBuild notifications

While following CodeBuild rule setup guides from AWS one should be able

to set up notifications, the overall setup involves multiple components and even some coding.

Firstly, you need to create a notification rule in an existing CodeBuild project. I used the Full notification message type for this setup, to ensure that I have all the data elements that I might need.

Next, you should select the AWS SNS topic as a target for notifications (either create a new one or use the existing one). In my case, as the goal was to create notifications per environment, I used one topic per environment and configured deployments of different project elements to them.

The last portion is a processing of the messages in the topic. This can be archived by setting up a subscription to SNS topic. As for the integration with Teams I needed some processing to construct a specific message object, decide to use AWS Lambda for processing.

Create Lambda functions

I would suggest starting the creation of the function from the very basic one, which just logs incoming messages to CloudWatch. It will allow you to investigate the format of the message and come up with the required mapping of the data you want to send.

Once you have such functions it makes sense to trigger a few builds and check if messages are reaching out to your function. Or it is also possible to post messages manually to the topic from the SNS UI to validate acceptance.

The event received by the lambda will have 1 or more records describing the CodeBuild. Once you process the data and construct the data object that Teams require (active card format and a playground for it), you can use any Node.js HTTP client to send a post to the web-hook URL.

The gist below will speak better for code-level details.

As a result of this code, you get a pretty card in a configured channel (for the exception of the issues list, as it is a separate enhancement.)

As usual, follow me on Twitter @true_shoorik πŸ˜‰