Skip to content

Commit

Permalink
Remove logger.
Browse files Browse the repository at this point in the history
  • Loading branch information
constanca-m committed Oct 12, 2023
1 parent e322104 commit 5ee94b1
Showing 1 changed file with 1 addition and 9 deletions.
10 changes: 1 addition & 9 deletions libbeat/processors/add_cloud_metadata/provider_aws_ec2.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ import (
"github.com/aws/aws-sdk-go-v2/service/ec2"
"github.com/aws/aws-sdk-go-v2/service/ec2/types"

"github.com/elastic/elastic-agent-libs/logp"
"github.com/elastic/elastic-agent-libs/mapstr"

conf "github.com/elastic/elastic-agent-libs/config"
Expand Down Expand Up @@ -75,20 +74,16 @@ func fetchRawProviderMetadata(
client http.Client,
result *result,
) {
logger := logp.NewLogger("add_cloud_metadata")

// LoadDefaultConfig loads the EC2 role credentials
awsConfig, err := awscfg.LoadDefaultConfig(context.TODO(), awscfg.WithHTTPClient(&client))
if err != nil {
logger.Warnf("error loading AWS default configuration: %s.", err)
result.err = fmt.Errorf("failed loading AWS default configuration: %w", err)
return
}
awsClient := NewIMDSClient(awsConfig)

instanceIdentity, err := awsClient.GetInstanceIdentityDocument(context.TODO(), &imds.GetInstanceIdentityDocumentInput{})
if err != nil {
logger.Warnf("error fetching EC2 Identity Document: %s.", err)
result.err = fmt.Errorf("failed fetching EC2 Identity Document: %w", err)
return
}
Expand All @@ -97,10 +92,7 @@ func fetchRawProviderMetadata(
awsRegion := instanceIdentity.InstanceIdentityDocument.Region
awsConfig.Region = awsRegion

clusterName, err := fetchEC2ClusterNameTag(awsConfig, instanceIdentity.InstanceIdentityDocument.InstanceID)
if err != nil {
logger.Warnf("error fetching cluster name metadata: %s.", err)
}
clusterName, _ := fetchEC2ClusterNameTag(awsConfig, instanceIdentity.InstanceIdentityDocument.InstanceID)

accountID := instanceIdentity.InstanceIdentityDocument.AccountID

Expand Down

0 comments on commit 5ee94b1

Please sign in to comment.