Skip to content

kms fixes to include function name in context #25

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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