crossplane-contrib / provider-upjet-aws

Official AWS Provider for Crossplane by Upbound.
https://marketplace.upbound.io/providers/upbound/provider-aws
Apache License 2.0
137 stars 113 forks source link

[Bug]: DynamoDB Table attribute Invalid value: "boolean" #1261

Open zargor opened 2 months ago

zargor commented 2 months ago

Is there an existing issue for this?

Affected Resource(s)

dynamodb.aws.upbound.io/v1beta1 - Table

https://marketplace.upbound.io/providers/upbound/provider-aws-dynamodb/v1.3.1/resources/dynamodb.aws.upbound.io/Table/v1beta1

Resource MRs required to reproduce the bug

apiVersion: dynamodb.aws.upbound.io/v1beta1
kind: Table
metadata:
  annotations:
    meta.upbound.io/example-id: dynamodb/v1beta1/table
  name: example
spec:
  forProvider:
    attribute:
      - name: UserId
        type: S
      - name: GameTitle
        type: S
      - name: TopScore
        type: N
    billingMode: PROVISIONED
    globalSecondaryIndex:
      - hashKey: GameTitle
        name: GameTitleIndex
        nonKeyAttributes:
          - UserId
        projectionType: INCLUDE
        rangeKey: TopScore
        readCapacity: 10
        writeCapacity: 10
    hashKey: UserId
    rangeKey: GameTitle
    readCapacity: 20
    region: us-west-1
    tags:
      Environment: production
      Name: dynamodb-table-1
    writeCapacity: 20

Steps to Reproduce

Apply the MR manifest. The result would be:

The Table "example" is invalid: spec.forProvider.attribute[2].type: Invalid value: "boolean": spec.forProvider.attribute[2].type in body must be of type string: "boolean"

However, when 'N'is provided instead N it is working.

Now, in case DynamoDB Table is part of a composition (based on KCL function, not P&T), then no matter how value "N" (number) is provided, quoted or not, the process ends up with error.

What happened?

From a composition, expected is to have DynamoDB Table provisioned. It turns out that if one has an attribute of type number (N), the resource will never get provisioned due to an error.

Relevant Error Output Snippet

cannot compose resources: cannot apply composed resource "example": failed to create typed patch object (/example; dynamodb.aws.upbound.io/v1beta1, Kind=Table): .spec.forProvider.attribute[2].type: expected string, got &value.valueUnstructured{Value:false}


### Crossplane Version

v1.14.5

### Provider Version

v1.3.1

### Kubernetes Version

v1.27.11

### Kubernetes Distribution

EKS

### Additional Info

This does not happen with P&T composition, but with KCL function based composition.
Peefy commented 2 months ago

Hello @zargor Thank you for your feedback. I have fixed it in function-kcl v0.5.4 with the PR: https://github.com/crossplane-contrib/function-kcl/pull/79

zargor commented 2 months ago

Awesome! It works.

turkenf commented 1 month ago

Hi @zargor, thank you for the issue, I think it works as expected on the provider side, do you still think this is a valid issue?