Skip to content

Commit

Permalink
Properly catch error response from AWS Logs integration (#1095)
Browse files Browse the repository at this point in the history
  • Loading branch information
zippolyte authored Jun 3, 2021
1 parent 565b918 commit 524e3d9
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion datadog/resource_datadog_integration_aws_lambda_arn.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,16 @@ func resourceDatadogIntegrationAwsLambdaArnCreate(ctx context.Context, d *schema
authV1 := providerConf.AuthV1

attachLambdaArnRequest := buildDatadogIntegrationAwsLambdaArnStruct(d)
_, _, err := datadogClientV1.AWSLogsIntegrationApi.CreateAWSLambdaARN(authV1, *attachLambdaArnRequest)
response, httpresp, err := datadogClientV1.AWSLogsIntegrationApi.CreateAWSLambdaARN(authV1, *attachLambdaArnRequest)
if err != nil {
return utils.TranslateClientErrorDiag(err, "error attaching Lambda ARN to AWS integration account")
}

res := response.(map[string]interface{})
if status, ok := res["status"]; ok && status == "error" {
return diag.FromErr(fmt.Errorf("error attaching Lambda ARN to AWS integration account: %s", httpresp.Body))
}

d.SetId(fmt.Sprintf("%s %s", attachLambdaArnRequest.GetAccountId(), attachLambdaArnRequest.GetLambdaArn()))

return resourceDatadogIntegrationAwsLambdaArnRead(ctx, d, meta)
Expand Down

0 comments on commit 524e3d9

Please sign in to comment.