Deep link for Codebuild failed project

0

Hi,

I want to see in my lambda a link to a build project. My syntax:

import json
import requests

def lambda_handler(event, context):
    build_status = event['detail']['build-status']
    project_name = event['detail']['project-name']
    build_id = event['detail']['build-id']
    region = event['region']
    deep_link = event['detail']['logs']['deep-link']

    message = f"AWS CodeBuild project '{project_name}' has {build_status} use this link {deep_link}"

I have this error:


[ERROR] KeyError: 'logs'
Traceback (most recent call last):
  File "/var/task/lambda_function.py", line 9, in lambda_handler
    deep_link = event['detail']['logs']['deep-link']
[ERROR] KeyError: 'logs' Traceback (most recent call last):   File "/var/task/lambda_function.py", line 9, in lambda_handler     deep_link = event['detail']['logs']['deep-link']

Based on documentation path for a deep link is correct.

1 Answer
0
Accepted Answer

Hi myronix88,

I created a quick function to check the event sent to a Lambda and it looks like that the 'logs' key is under the 'additional-information' key.

Changing your code to:

deep_link = event['detail']['additional-information'['logs']['deep-link']

should get the link. If you can point me at the documentation and will raise an issue with it.

profile pictureAWS
answered 8 months ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions