(ctx context.Context, clients *awsclients.Clients, cfg *config.CLIConfig, bucketName string)
| 221 | } |
| 222 | |
| 223 | func getS3Status(ctx context.Context, clients *awsclients.Clients, cfg *config.CLIConfig, bucketName string) (*S3Status, error) { |
| 224 | status := &S3Status{ |
| 225 | BucketName: bucketName, |
| 226 | } |
| 227 | |
| 228 | // List objects to get count and size |
| 229 | input := &s3.ListObjectsV2Input{ |
| 230 | Bucket: aws.String(bucketName), |
| 231 | } |
| 232 | |
| 233 | result, err := clients.S3.ListObjectsV2WithContext(ctx, input) |
| 234 | if err != nil { |
| 235 | return nil, fmt.Errorf("failed to list S3 objects: %w", err) |
| 236 | } |
| 237 | |
| 238 | status.ObjectCount = len(result.Contents) |
| 239 | var totalSize int64 |
| 240 | var lastModified *time.Time |
| 241 | |
| 242 | for _, obj := range result.Contents { |
| 243 | totalSize += *obj.Size |
| 244 | if lastModified == nil || obj.LastModified.After(*lastModified) { |
| 245 | lastModified = obj.LastModified |
| 246 | } |
| 247 | } |
| 248 | |
| 249 | status.TotalSize = totalSize |
| 250 | if lastModified != nil { |
| 251 | status.LastActivity = lastModified.Format("2006-01-02 15:04:05") |
| 252 | } |
| 253 | |
| 254 | // Check bucket notifications |
| 255 | triggerDeployer := deploy.NewTriggerDeployer(clients, cfg) |
| 256 | notificationConfig, err := triggerDeployer.GetBucketNotifications(ctx, bucketName) |
| 257 | if err == nil { |
| 258 | status.NotificationsOK = len(notificationConfig.LambdaFunctionConfigurations) > 0 |
| 259 | } |
| 260 | |
| 261 | return status, nil |
| 262 | } |
| 263 | |
| 264 | func getRecentLogs(ctx context.Context, clients *awsclients.Clients, functionName string) ([]LogEntry, error) { |
| 265 | logGroupName := fmt.Sprintf("/aws/lambda/%s", functionName) |
no test coverage detected