crossplane-contrib / provider-jet-aws

AWS Provider for Crossplane that is built with Terrajet.
https://crossplane.io
Apache License 2.0
37 stars 30 forks source link

Strange error when creating a 'connection' resource in AWS EventBridge API destinations #215

Open milonjames opened 2 years ago

milonjames commented 2 years ago

What happened?

We are trying to create a connection resource referring to the CRD here however we are getting a strange error. The error message says Failed to create the connection(s). Parameter OAuthHttpParameters is not valid. Reason: Parameter BodyParameters is not valid. Reason: Missing required field(s): 'Value'. status code: 400, request id: 8a2b0f3c-4156-4bf3-9fe5-ba9239370a57: : File name: main.tf.json

There is not an option to specify the Value field, so we thought this would be automatically generated from the ValueSecretRef object. And we created a k8s secret to store the value fields and referenced the same in the ValueSecretRef, however still its complaining. So we are kind of perplexed here about what could be wrong.

How can we reproduce it?

apiVersion: events.aws.jet.crossplane.io/v1alpha1
kind: Connection
metadata:
  name: sf-api-connection
spec:
  forProvider:
    region: eu-west-1
    name: sf-api-connection
    authorizationType: OAUTH_CLIENT_CREDENTIALS
    authParameters:
      - oauth:
        - authorizationEndpoint: 'https://xxxx.salesforce.com/services/oauth2/token'
          httpMethod: POST
          oauthHttpParameters:
          - body:
            - isValueSecret: True
              key: grant_type
              valueSecretRef:
                key: SF_API_OAUTH_GRANT_TYPE
                name: sf-api-oauth
                namespace: custom
            - isValueSecret: True
              key: username
              valueSecretRef:
                key: SF_API_OAUTH_USERNAME
                name: sf-api-oauth
                namespace: custom
            - isValueSecret: True
              key: password
              valueSecretRef:
                key: SF_API_OAUTH_PASSWORD
                name: sf-api-oauth
                namespace: custom
          clientParameters:
            - clientId: 'xxxxxxxxxxxxxxxx'
              clientSecretSecretRef:
                key: SF_API_CLIENT_SECRET
                name: sf-api-client-secret
                namespace: custom

What environment did it happen in?

Crossplane version: 1.6.2

haarchri commented 2 years ago

Can you add the full kubectl describe for this resource ?

milonjames commented 2 years ago

Here it is

Name:         sf-api-connection
Namespace:
Labels:       argocd.argoproj.io/instance=<redacted>
Annotations:  crossplane.io/external-create-failed: 2022-07-13T08:20:14Z
              crossplane.io/external-create-pending: 2022-07-13T08:19:49Z
API Version:  events.aws.jet.crossplane.io/v1alpha1
Kind:         Connection
Metadata:
  Creation Timestamp:  2022-07-06T08:38:27Z
  Finalizers:
    finalizer.managedresource.crossplane.io
  Generation:  1
  Managed Fields:
    API Version:  events.aws.jet.crossplane.io/v1alpha1
    Fields Type:  FieldsV1
    fieldsV1:
      f:metadata:
        f:annotations:
          .:
          f:kubectl.kubernetes.io/last-applied-configuration:
        f:labels:
          .:
          f:argocd.argoproj.io/instance:
      f:spec:
        .:
        f:deletionPolicy:
        f:forProvider:
          .:
          f:authParameters:
          f:authorizationType:
          f:name:
          f:region:
        f:providerConfigRef:
          .:
          f:name:
    Manager:      argocd-application-controller
    Operation:    Update
    Time:         2022-07-06T08:38:27Z
    API Version:  events.aws.jet.crossplane.io/v1alpha1
    Fields Type:  FieldsV1
    fieldsV1:
      f:metadata:
        f:annotations:
          f:crossplane.io/external-create-failed:
          f:crossplane.io/external-create-pending:
        f:finalizers:
          .:
          v:"finalizer.managedresource.crossplane.io":
    Manager:      crossplane-provider
    Operation:    Update
    Time:         2022-07-06T08:39:21Z
    API Version:  events.aws.jet.crossplane.io/v1alpha1
    Fields Type:  FieldsV1
    fieldsV1:
      f:status:
        .:
        f:atProvider:
        f:conditions:
    Manager:         crossplane-provider
    Operation:       Update
    Subresource:     status
    Time:            2022-07-06T08:39:22Z
  Resource Version:  74601442
  UID:               35971493-2a4e-49c8-97bf-f020291c9fa1
Spec:
  Deletion Policy:  Delete
  For Provider:
    Auth Parameters:
      Oauth:
        Authorization Endpoint:  <redacted>
        Client Parameters:
          Client Id:  <redacted>
          Client Secret Secret Ref:
            Key:        SF_API_CLIENT_SECRET
            Name:       <redacted>
            Namespace:  <redacted>
        Http Method:    POST
        Oauth Http Parameters:
          Body:
            Is Value Secret:  true
            Key:              grant_type
            Value Secret Ref:
              Key:            SF_API_OAUTH_GRANT_TYPE
              Name:           <redacted>
              Namespace:      <redacted>
            Is Value Secret:  true
            Key:              username
            Value Secret Ref:
              Key:            SF_API_OAUTH_USERNAME
              Name:           <redacted>
              Namespace:      <redacted>
            Is Value Secret:  true
            Key:              <redacted>
            Value Secret Ref:
              Key:        SF_API_OAUTH_PASSWORD
              Name:       <redacted>
              Namespace:  <redacted>
    Authorization Type:   OAUTH_CLIENT_CREDENTIALS
    Name:                 sf-api-connection
    Region:               <redacted>
  Provider Config Ref:
    Name:  aws-jet-provider
Status:
  At Provider:
  Conditions:
    Last Transition Time:  2022-07-06T08:39:22Z
    Reason:                Creating
    Status:                False
    Type:                  Ready
    Last Transition Time:  2022-07-13T08:20:14Z
    Message:               create failed: cannot apply: apply failed: error creating CloudWatch Events connection (sf-api-connection): ValidationException: Failed to create the connection(s). Parameter OAuthHttpParameters is not valid. Reason: Parameter BodyParameters is not valid. Reason: Missing required field(s): 'Value'.
                           status code: 400, request id: 46b02c1d-56c1-4ca3-9bf3-3ec57212b965: : File name: main.tf.json
    Reason:                ReconcileError
    Status:                False
    Type:                  Synced
Events:
  Type     Reason                        Age                      From                                                            Message
  ----     ------                        ----                     ----                                                            -------
  Warning  CannotCreateExternalResource  60s (x11782 over 6d23h)  managed/events.aws.jet.crossplane.io/v1alpha1, kind=connection  (combined from similar events): cannot apply: apply failed: error creating CloudWatch Events connection (sf-api-connection): ValidationException: Failed to create the connection(s). Parameter OAuthHttpParameters is not valid. Reason: Parameter BodyParameters is not valid. Reason: Missing required field(s): 'Value'.
           status code: 400, request id: 3ab60edb-ca80-4b02-ba73-ad3eee597060: : File name: main.tf.json
milonjames commented 2 years ago

@haarchri Did you get some time to look into this ?