MCPcopy Create free account
hub / github.com/dan-v/lambda-nat-proxy / deleteCloudWatchLogs

Function deleteCloudWatchLogs

cmd/lambda-nat-proxy/cmd_destroy.go:250–269  ·  view source on GitHub ↗
(ctx context.Context, clients *awsclients.Clients, functionName string)

Source from the content-addressed store, hash-verified

248}
249
250func deleteCloudWatchLogs(ctx context.Context, clients *awsclients.Clients, functionName string) error {
251 logGroupName := fmt.Sprintf("/aws/lambda/%s", functionName)
252
253 input := &cloudwatchlogs.DeleteLogGroupInput{
254 LogGroupName: aws.String(logGroupName),
255 }
256
257 _, err := clients.CloudWatchLogs.DeleteLogGroupWithContext(ctx, input)
258 if err != nil {
259 if awsErr, ok := err.(awserr.Error); ok {
260 if awsErr.Code() == cloudwatchlogs.ErrCodeResourceNotFoundException {
261 log.Printf("CloudWatch log group %s does not exist", logGroupName)
262 return nil
263 }
264 }
265 return fmt.Errorf("failed to delete CloudWatch log group: %w", err)
266 }
267
268 return nil
269}
270
271func init() {
272 // Add destroy-specific flags

Callers 1

runDestroyFunction · 0.85

Calls 1

Tested by

no test coverage detected