Closed pelgrim closed 5 months ago
Deletion request to the Lambda Custom Resource named 'GrafanaDataSourceFunction':
[INFO] 2024-01-23T16:58:42.399Z babaa255-5dcf-4d55-a6a3-51cb4f9b2451 Failed attempting to delete datasource COAST-2023-09-19: Failed calling grafana api to retrieve datasources
The delete lambda identifies the datasource by name, and it pulls the ID of the datasource. However, the grafana call to the api endpoint is done by UID
datasource_id = None
for datasource in datasources:
if datasource['name'] == self.datasource_name:
datasource_id = datasource['id']
break
return self.grafana_api('DELETE',f'datasources/uid/{datasource_id}')
Requests was not imported into the code for this to succeed:
response = requests.get(grafana_url, headers={'Authorization': f"Bearer {key}",'Content-Type': 'application/json'})
When deleting the CFN stack, the Lambda that manages the datasource resource raised: