• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

elastic / cloudbeat / 17606600399

10 Sep 2025 07:32AM UTC coverage: 76.0% (-0.06%) from 76.062%
17606600399

Pull #3561

github

amirbenun
Revert "cloud_connectors_federated_identity"

This reverts commit df92f7759.
Pull Request #3561: Azure cloud connector credentials

15 of 38 new or added lines in 2 files covered. (39.47%)

200 existing lines in 32 files now uncovered.

9560 of 12579 relevant lines covered (76.0%)

16.59 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

88.0
/internal/inventory/awsfetcher/fetcher_lambda.go
1
// Licensed to Elasticsearch B.V. under one or more contributor
2
// license agreements. See the NOTICE file distributed with
3
// this work for additional information regarding copyright
4
// ownership. Elasticsearch B.V. licenses this file to you under
5
// the Apache License, Version 2.0 (the "License"); you may
6
// not use this file except in compliance with the License.
7
// You may obtain a copy of the License at
8
//
9
//     http://www.apache.org/licenses/LICENSE-2.0
10
//
11
// Unless required by applicable law or agreed to in writing,
12
// software distributed under the License is distributed on an
13
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14
// KIND, either express or implied.  See the License for the
15
// specific language governing permissions and limitations
16
// under the License.
17

18
package awsfetcher
19

20
import (
21
        "context"
22

23
        "github.com/elastic/cloudbeat/internal/dataprovider/providers/cloud"
24
        "github.com/elastic/cloudbeat/internal/infra/clog"
25
        "github.com/elastic/cloudbeat/internal/inventory"
26
        "github.com/elastic/cloudbeat/internal/resources/providers/awslib"
27
)
28

29
type lambdaFetcher struct {
30
        logger      *clog.Logger
31
        provider    lambdaProvider
32
        AccountId   string
33
        AccountName string
34
}
35

36
type (
37
        lambdaDescribeFunc func(context.Context) ([]awslib.AwsResource, error)
38
        lambdaProvider     interface {
39
                ListAliases(context.Context, string, string) ([]awslib.AwsResource, error)
40
                ListEventSourceMappings(context.Context) ([]awslib.AwsResource, error)
41
                ListFunctions(context.Context) ([]awslib.AwsResource, error)
42
                ListLayers(context.Context) ([]awslib.AwsResource, error)
43
        }
44
)
45

46
func newLambdaFetcher(logger *clog.Logger, identity *cloud.Identity, provider lambdaProvider) inventory.AssetFetcher {
47
        return &lambdaFetcher{
48
                logger:      logger,
1✔
49
                provider:    provider,
1✔
50
                AccountId:   identity.Account,
1✔
51
                AccountName: identity.AccountAlias,
1✔
52
        }
1✔
53
}
1✔
54

1✔
55
func (s *lambdaFetcher) Fetch(ctx context.Context, assetChannel chan<- inventory.AssetEvent) {
1✔
56
        resourcesToFetch := []struct {
1✔
57
                name           string
58
                function       lambdaDescribeFunc
1✔
59
                classification inventory.AssetClassification
1✔
60
        }{
1✔
61
                {"Lambda Event Source Mappings", s.provider.ListEventSourceMappings, inventory.AssetClassificationAwsLambdaEventSourceMapping},
1✔
62
                {"Lambda Functions", s.provider.ListFunctions, inventory.AssetClassificationAwsLambdaFunction},
1✔
63
                {"Lambda Layers", s.provider.ListLayers, inventory.AssetClassificationAwsLambdaLayer},
1✔
64
        }
1✔
65
        for _, r := range resourcesToFetch {
1✔
66
                s.fetch(ctx, r.name, r.function, r.classification, assetChannel)
1✔
67
        }
1✔
68
}
4✔
69

3✔
70
func (s *lambdaFetcher) fetch(ctx context.Context, resourceName string, function lambdaDescribeFunc, classification inventory.AssetClassification, assetChannel chan<- inventory.AssetEvent) {
3✔
71
        s.logger.Infof("Fetching %s", resourceName)
72
        defer s.logger.Infof("Fetching %s - Finished", resourceName)
73

3✔
74
        awsResources, err := function(ctx)
3✔
75
        if err != nil {
3✔
76
                s.logger.Errorf("Could not fetch %s: %v", resourceName, err)
3✔
77
                return
3✔
78
        }
3✔
UNCOV
79

×
UNCOV
80
        for _, item := range awsResources {
×
UNCOV
81
                id := item.GetResourceArn()
×
UNCOV
82
                if id == "" { // e.g. LambdaEventSourceMappings
×
83
                        id = item.GetResourceName()
84
                }
4✔
85
                assetChannel <- inventory.NewAssetEvent(
1✔
86
                        classification,
1✔
UNCOV
87
                        id,
×
UNCOV
88
                        item.GetResourceName(),
×
89
                        inventory.WithRawAsset(item),
1✔
90
                        inventory.WithCloud(inventory.Cloud{
1✔
91
                                Provider:    inventory.AwsCloudProvider,
1✔
92
                                Region:      item.GetRegion(),
1✔
93
                                AccountID:   s.AccountId,
1✔
94
                                AccountName: s.AccountName,
1✔
95
                                ServiceName: "AWS Lambda",
1✔
96
                        }),
1✔
97
                )
1✔
98
        }
1✔
99
}
1✔
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc