Skip to content

Commit a09c8a5

Browse files
authored
Merge pull request #25 from SumoLogic/hpal_kms_fixes
kms fixes to include function name in context
2 parents bf30b4b + 67702bd commit a09c8a5

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

lambda-extensions/config/version.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import (
88

99
// ExtensionName same as binary name or file name where main exists
1010
var ExtensionName = filepath.Base(os.Args[0])
11-
var layerVersion = "8"
11+
var layerVersion = "9"
1212

1313
// SumoLogicExtensionLayerVersionSuffix denotes the layer version published in AWS
1414
var SumoLogicExtensionLayerVersionSuffix string = fmt.Sprintf("%s-prod:%s", ExtensionName, layerVersion)

lambda-extensions/sumoclient/sumoclient.go

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import (
1010
"net/http"
1111
"strings"
1212
"time"
13-
13+
"os"
1414
"github.com/SumoLogic/sumologic-lambda-extensions/lambda-extensions/utils"
1515

1616
"github.com/SumoLogic/sumologic-lambda-extensions/lambda-extensions/config"
@@ -73,6 +73,7 @@ func (s *sumoLogicClient) makeRequest(ctx context.Context, buf *bytes.Buffer) (*
7373
endpoint, err := s.getHttpEndpoint()
7474
if err != nil {
7575
err = fmt.Errorf("Failed to get SUMO HTTP Endpoint error: %v", err)
76+
return nil, err
7677
}
7778

7879
request, err := http.NewRequestWithContext(ctx, "POST", endpoint, buf)
@@ -94,6 +95,7 @@ func (s *sumoLogicClient) makeRequest(ctx context.Context, buf *bytes.Buffer) (*
9495

9596
// Use cached KMS decrypted endpoint, refresh the cached endpoint, or return unencrypted endpoint
9697
func (s *sumoLogicClient) getHttpEndpoint() (string, error) {
98+
9799
if s.config.KMSKeyId == "" {
98100
return s.config.SumoHTTPEndpoint, nil
99101
}
@@ -114,11 +116,13 @@ func (s *sumoLogicClient) getHttpEndpoint() (string, error) {
114116
blob, err := b64.StdEncoding.DecodeString(s.config.SumoHTTPEndpoint)
115117
if err != nil {
116118
fmt.Errorf("Error converting string to blob, error: %v", err)
119+
return "", err
117120
}
118121

119122
input := &kms.DecryptInput{
120-
CiphertextBlob: blob,
121-
KeyId: aws.String(s.config.KMSKeyId),
123+
CiphertextBlob: blob,
124+
KeyId: aws.String(s.config.KMSKeyId),
125+
EncryptionContext: map[string]string{"LambdaFunctionName": os.Getenv("AWS_LAMBDA_FUNCTION_NAME")},
122126
}
123127

124128
result, err := DecodeData(context.TODO(), client, input)

0 commit comments

Comments
 (0)