Skip to content
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

TriggerAuthentication : AWS Secret Manager is not working with credentials accessKey and accessSecretKey #5941

Closed
Tejasvihuded opened this issue Jul 2, 2024 · 2 comments
Labels
bug Something isn't working stale All issues that are marked as stale due to inactivity

Comments

@Tejasvihuded
Copy link

Tejasvihuded commented Jul 2, 2024

Report

Getting "api error UnrecognizedClientException: The security token included in the request is invalid." when I try to use AWS Secret Manager TriggerAuthentication with credentials accessKey and accessSecretKey.

I am trying cross account, AWS secrets manager is in different account and keda operator is in different AWS account

Expected Behavior

TriggerAuthentication awsSecretManager should be able to create valid TriggerAuthentication object and should be able to pass required parameters to Scaledobject using valid accessKey and accessSecretKey

Actual Behavior

TriggerAuthentication awsSecretManager is not able to get secrets from AWS secret manager .Keda operator is throwing below error.

ERROR scale_handler error trying to read secret from Aws Secret Manager {"type": "ScaledObject", "namespace": "", "name": "keda-postgresql", "triggerAuthRef.Name": "sample-aws-sm-int", "secret.Name": "keda-int", "secret.Version": "", "secret.VersionStage": "", "error": "operation error Secrets Manager: GetSecretValue, https response error StatusCode: 400, RequestID: , api error UnrecognizedClientException: The security token included in the request is invalid."}

Steps to Reproduce the Problem

1.Create k8s secret. All data values are base64 encoded before creating k8s secret.

apiVersion: v1
kind: Secret
metadata:
  name: mysecret
type: Opaque
data:
  accessKey: <removed>
  accessSecretKey: <removed>

2.Create TriggerAuthentication

apiVersion: keda.sh/v1alpha1
kind: TriggerAuthentication
metadata:
  name: sample-aws-sm-int
spec:
  awsSecretManager:                                                      
    credentials:                                     
      accessKey:                                     
        valueFrom:                                   
          secretKeyRef:                              
            name: mysecret 
            key: accessKey                    
      accessSecretKey:                               
        valueFrom:                                   
          secretKeyRef:                              
            name: mysecret
            key: accessSecretKey                  
    region: us-east-2                                                 
    secrets:                                                              
    - parameter: userName
      name: keda-int
    - parameter: password
      name: keda-int  

3.Create ScaledObject

apiVersion: keda.sh/v1alpha1
kind: ScaledObject
metadata:
  name: keda-postgresql
spec:
  scaleTargetRef:
    name: app1
  triggers:
  - type: "postgresql"
    metadata:
      host: <removed>
      port: <removed>
      dbName: <removed>
      sslmode: disable
      query: <removed>
      targetQueryValue: "1" 
    authenticationRef:
      name: sample-aws-sm-int

Logs from KEDA operator

2024-07-02T09:26:52Z INFO Creating a new HPA {"controller": "scaledobject", "controllerGroup": "keda.sh", "controllerKind": "ScaledObject", "ScaledObject": {"name":"keda-postgresql","namespace":""}, "namespace": "", "name": "keda-postgresql", "reconcileID": "", "HPA.Namespace": "", "HPA.Name": ""}
2024-07-02T09:26:52Z ERROR scale_handler Error getting credentials {"type": "ScaledObject", "namespace": "", "name": "keda-postgresql", "error": "operation error Secrets Manager: GetSecretValue, https response error StatusCode: 400, RequestID: , api error UnrecognizedClientException: The security token included in the request is invalid."}
github.com/kedacore/keda/v2/pkg/scaling/resolver.(*AwsSecretManagerHandler).Read
/workspace/pkg/scaling/resolver/aws_secretmanager_handler.go:60
github.com/kedacore/keda/v2/pkg/scaling/resolver.resolveAuthRef
/workspace/pkg/scaling/resolver/scale_resolvers.go:344
github.com/kedacore/keda/v2/pkg/scaling/resolver.ResolveAuthRefAndPodIdentity
/workspace/pkg/scaling/resolver/scale_resolvers.go:183
github.com/kedacore/keda/v2/pkg/scaling.(*scaleHandler).buildScalers.func1
/workspace/pkg/scaling/scalers_builder.go:72
github.com/kedacore/keda/v2/pkg/scaling.(*scaleHandler).buildScalers
/workspace/pkg/scaling/scalers_builder.go:96
github.com/kedacore/keda/v2/pkg/scaling.(*scaleHandler).performGetScalersCache
/workspace/pkg/scaling/scale_handler.go:357
github.com/kedacore/keda/v2/pkg/scaling.(*scaleHandler).GetScalersCache
/workspace/pkg/scaling/scale_handler.go:282
github.com/kedacore/keda/v2/controllers/keda.(*ScaledObjectReconciler).getScaledObjectMetricSpecs
/workspace/controllers/keda/hpa.go:217
github.com/kedacore/keda/v2/controllers/keda.(*ScaledObjectReconciler).newHPAForScaledObject
/workspace/controllers/keda/hpa.go:72
github.com/kedacore/keda/v2/controllers/keda.(*ScaledObjectReconciler).createAndDeployNewHPA
/workspace/controllers/keda/hpa.go:45
github.com/kedacore/keda/v2/controllers/keda.(*ScaledObjectReconciler).ensureHPAForScaledObjectExists
/workspace/controllers/keda/scaledobject_controller.go:441
github.com/kedacore/keda/v2/controllers/keda.(*ScaledObjectReconciler).reconcileScaledObject
/workspace/controllers/keda/scaledobject_controller.go:280
github.com/kedacore/keda/v2/controllers/keda.(*ScaledObjectReconciler).Reconcile
/workspace/controllers/keda/scaledobject_controller.go:191
sigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller).Reconcile
/workspace/vendor/sigs.k8s.io/controller-runtime/pkg/internal/controller/controller.go:119
sigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller).reconcileHandler
/workspace/vendor/sigs.k8s.io/controller-runtime/pkg/internal/controller/controller.go:316
sigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller).processNextWorkItem
/workspace/vendor/sigs.k8s.io/controller-runtime/pkg/internal/controller/controller.go:266
sigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller).Start.func2.2
/workspace/vendor/sigs.k8s.io/controller-runtime/pkg/internal/controller/controller.go:227
2024-07-02T09:26:52Z ERROR scale_handler error trying to read secret from Aws Secret Manager {"type": "ScaledObject", "namespace": "", "name": "keda-postgresql", "triggerAuthRef.Name": "sample-aws-sm-int", "secret.Name": "keda-int", "secret.Version": "", "secret.VersionStage": "", "error": "operation error Secrets Manager: GetSecretValue, https response error StatusCode: 400, RequestID: , api error UnrecognizedClientException: The security token included in the request is invalid."}
github.com/kedacore/keda/v2/pkg/scaling/resolver.resolveAuthRef
/workspace/pkg/scaling/resolver/scale_resolvers.go:346
github.com/kedacore/keda/v2/pkg/scaling/resolver.ResolveAuthRefAndPodIdentity
/workspace/pkg/scaling/resolver/scale_resolvers.go:183
github.com/kedacore/keda/v2/pkg/scaling.(*scaleHandler).buildScalers.func1
/workspace/pkg/scaling/scalers_builder.go:72
github.com/kedacore/keda/v2/pkg/scaling.(*scaleHandler).buildScalers
/workspace/pkg/scaling/scalers_builder.go:96
github.com/kedacore/keda/v2/pkg/scaling.(*scaleHandler).performGetScalersCache
/workspace/pkg/scaling/scale_handler.go:357
github.com/kedacore/keda/v2/pkg/scaling.(*scaleHandler).GetScalersCache
/workspace/pkg/scaling/scale_handler.go:282
github.com/kedacore/keda/v2/controllers/keda.(*ScaledObjectReconciler).getScaledObjectMetricSpecs
/workspace/controllers/keda/hpa.go:217
github.com/kedacore/keda/v2/controllers/keda.(*ScaledObjectReconciler).newHPAForScaledObject
/workspace/controllers/keda/hpa.go:72
github.com/kedacore/keda/v2/controllers/keda.(*ScaledObjectReconciler).createAndDeployNewHPA
/workspace/controllers/keda/hpa.go:45
github.com/kedacore/keda/v2/controllers/keda.(*ScaledObjectReconciler).ensureHPAForScaledObjectExists
/workspace/controllers/keda/scaledobject_controller.go:441
github.com/kedacore/keda/v2/controllers/keda.(*ScaledObjectReconciler).reconcileScaledObject
/workspace/controllers/keda/scaledobject_controller.go:280
github.com/kedacore/keda/v2/controllers/keda.(*ScaledObjectReconciler).Reconcile
/workspace/controllers/keda/scaledobject_controller.go:191
sigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller).Reconcile
/workspace/vendor/sigs.k8s.io/controller-runtime/pkg/internal/controller/controller.go:119
sigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller).reconcileHandler
/workspace/vendor/sigs.k8s.io/controller-runtime/pkg/internal/controller/controller.go:316
sigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller).processNextWorkItem
/workspace/vendor/sigs.k8s.io/controller-runtime/pkg/internal/controller/controller.go:266
sigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller).Start.func2.2
/workspace/vendor/sigs.k8s.io/controller-runtime/pkg/internal/controller/controller.go:227
2024-07-02T09:26:52Z ERROR scale_handler Error getting credentials {"type": "ScaledObject", "namespace": "", "name": "keda-postgresql", "error": "operation error Secrets Manager: GetSecretValue, https response error StatusCode: 400, RequestID: , api error UnrecognizedClientException: The security token included in the request is invalid."}
github.com/kedacore/keda/v2/pkg/scaling/resolver.(*AwsSecretManagerHandler).Read
/workspace/pkg/scaling/resolver/aws_secretmanager_handler.go:60
github.com/kedacore/keda/v2/pkg/scaling/resolver.resolveAuthRef
/workspace/pkg/scaling/resolver/scale_resolvers.go:344
github.com/kedacore/keda/v2/pkg/scaling/resolver.ResolveAuthRefAndPodIdentity
/workspace/pkg/scaling/resolver/scale_resolvers.go:183
github.com/kedacore/keda/v2/pkg/scaling.(*scaleHandler).buildScalers.func1
/workspace/pkg/scaling/scalers_builder.go:72
github.com/kedacore/keda/v2/pkg/scaling.(*scaleHandler).buildScalers
/workspace/pkg/scaling/scalers_builder.go:96
github.com/kedacore/keda/v2/pkg/scaling.(*scaleHandler).performGetScalersCache
/workspace/pkg/scaling/scale_handler.go:357
github.com/kedacore/keda/v2/pkg/scaling.(*scaleHandler).GetScalersCache
/workspace/pkg/scaling/scale_handler.go:282
github.com/kedacore/keda/v2/controllers/keda.(*ScaledObjectReconciler).getScaledObjectMetricSpecs
/workspace/controllers/keda/hpa.go:217
github.com/kedacore/keda/v2/controllers/keda.(*ScaledObjectReconciler).newHPAForScaledObject
/workspace/controllers/keda/hpa.go:72
github.com/kedacore/keda/v2/controllers/keda.(*ScaledObjectReconciler).createAndDeployNewHPA
/workspace/controllers/keda/hpa.go:45
github.com/kedacore/keda/v2/controllers/keda.(*ScaledObjectReconciler).ensureHPAForScaledObjectExists
/workspace/controllers/keda/scaledobject_controller.go:441
github.com/kedacore/keda/v2/controllers/keda.(*ScaledObjectReconciler).reconcileScaledObject
/workspace/controllers/keda/scaledobject_controller.go:280
github.com/kedacore/keda/v2/controllers/keda.(*ScaledObjectReconciler).Reconcile
/workspace/controllers/keda/scaledobject_controller.go:191
sigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller).Reconcile
/workspace/vendor/sigs.k8s.io/controller-runtime/pkg/internal/controller/controller.go:119
sigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller).reconcileHandler
/workspace/vendor/sigs.k8s.io/controller-runtime/pkg/internal/controller/controller.go:316
sigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller).processNextWorkItem
/workspace/vendor/sigs.k8s.io/controller-runtime/pkg/internal/controller/controller.go:266
sigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller).Start.func2.2
/workspace/vendor/sigs.k8s.io/controller-runtime/pkg/internal/controller/controller.go:227

KEDA Version

2.13.0

Kubernetes Version

1.28

Platform

Amazon Web Services

Scaler Details

postgresql

Anything else?

No response

@Tejasvihuded Tejasvihuded added the bug Something isn't working label Jul 2, 2024
Copy link

stale bot commented Aug 31, 2024

This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 7 days if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale All issues that are marked as stale due to inactivity label Aug 31, 2024
Copy link

stale bot commented Sep 7, 2024

This issue has been automatically closed due to inactivity.

@stale stale bot closed this as completed Sep 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working stale All issues that are marked as stale due to inactivity
Projects
None yet
Development

No branches or pull requests

1 participant