Skip to content

Commit

Permalink
https://github.com/kedacore/keda/issues/2214
Browse files Browse the repository at this point in the history
Signed-off-by: Siva Guruvareddiar <sivagurunath@gmail.com>
  • Loading branch information
sguruvar committed Jan 17, 2024
1 parent f73c7aa commit bcafe6f
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 0 deletions.
27 changes: 27 additions & 0 deletions pkg/scalers/aws/aws_sigv4.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,28 @@
/*
Copyright 2024 The KEDA Authors
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

/*
This file contains all the logic for caching aws.Config across all the (AWS)
triggers. The first time when an aws.Config is requested, it's cached based on
the authentication info (roleArn, Key&Secret, keda itself) and it's returned
every time when an aws.Config is requested for the same authentication info.
This is required because if we don't cache and share them, each scaler
generates and refresh it's own token although all the tokens grants the same
permissions
*/
package aws

import (
Expand All @@ -23,6 +48,7 @@ var (
ErrAwsAMPNoAwsRegion = errors.New("no awsRegion given")
)

// add the roundTrip logic so that the request is SigV4 signed
func (rt *roundTripper) RoundTrip(req *http.Request) (*http.Response, error) {
cred, err := rt.client.Options().Credentials.Retrieve(req.Context())
if err != nil {
Expand All @@ -44,6 +70,7 @@ func (rt *roundTripper) RoundTrip(req *http.Request) (*http.Response, error) {
return transport.RoundTrip(req)
}

// parse the data to get the AWS sepcific auth info and metadata
func parseAwsAMPMetadata(config *scalersconfig.ScalerConfig) (*awsConfigMetadata, error) {
meta := awsConfigMetadata{}

Expand Down
25 changes: 25 additions & 0 deletions pkg/scalers/aws/aws_sigv4_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,28 @@
/*
Copyright 2024 The KEDA Authors
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

/*
This file contains all the logic for caching aws.Config across all the (AWS)
triggers. The first time when an aws.Config is requested, it's cached based on
the authentication info (roleArn, Key&Secret, keda itself) and it's returned
every time when an aws.Config is requested for the same authentication info.
This is required because if we don't cache and share them, each scaler
generates and refresh it's own token although all the tokens grants the same
permissions
*/
package aws

import (
Expand Down

0 comments on commit bcafe6f

Please sign in to comment.