Skip to content

Commit

Permalink
kms fixes to include function name in context
Browse files Browse the repository at this point in the history
  • Loading branch information
himanshu219 committed Jun 17, 2024
1 parent bf30b4b commit 67702bd
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
2 changes: 1 addition & 1 deletion lambda-extensions/config/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (

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

// SumoLogicExtensionLayerVersionSuffix denotes the layer version published in AWS
var SumoLogicExtensionLayerVersionSuffix string = fmt.Sprintf("%s-prod:%s", ExtensionName, layerVersion)
10 changes: 7 additions & 3 deletions lambda-extensions/sumoclient/sumoclient.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
"net/http"
"strings"
"time"

"os"
"github.com/SumoLogic/sumologic-lambda-extensions/lambda-extensions/utils"

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

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

// Use cached KMS decrypted endpoint, refresh the cached endpoint, or return unencrypted endpoint
func (s *sumoLogicClient) getHttpEndpoint() (string, error) {

if s.config.KMSKeyId == "" {
return s.config.SumoHTTPEndpoint, nil
}
Expand All @@ -114,11 +116,13 @@ func (s *sumoLogicClient) getHttpEndpoint() (string, error) {
blob, err := b64.StdEncoding.DecodeString(s.config.SumoHTTPEndpoint)
if err != nil {
fmt.Errorf("Error converting string to blob, error: %v", err)
return "", err
}

input := &kms.DecryptInput{
CiphertextBlob: blob,
KeyId: aws.String(s.config.KMSKeyId),
CiphertextBlob: blob,
KeyId: aws.String(s.config.KMSKeyId),
EncryptionContext: map[string]string{"LambdaFunctionName": os.Getenv("AWS_LAMBDA_FUNCTION_NAME")},
}

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

0 comments on commit 67702bd

Please sign in to comment.