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 Respuesta
0
Respuesta aceptada

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
respondido hace 9 meses

No has iniciado sesión. Iniciar sesión para publicar una respuesta.

Una buena respuesta responde claramente a la pregunta, proporciona comentarios constructivos y fomenta el crecimiento profesional en la persona que hace la pregunta.

Pautas para responder preguntas