(ctx context.Context, clients *awsclients.Clients, functionName string)
| 248 | } |
| 249 | |
| 250 | func 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 | |
| 271 | func init() { |
| 272 | // Add destroy-specific flags |
no test coverage detected