amazon-archives / aws-service-operator

AWS Service Operator allows you to create AWS resources using kubectl.
Apache License 2.0
733 stars 103 forks source link

Dynamodb resource does not support N,B Attribute types #181

Open dathan opened 5 years ago

dathan commented 5 years ago

N as a value is a special character in YAML, it means false. So quoting N is the only way to pass the value for instance.

// HELM DIFF OUTPUT

+ kind: DynamoDB
+ metadata:
+   name: sample-tablename
+ spec:
+   hashAttribute:
+     name: AuthorizationCode
+     type: "S"
+   rangeAttribute:
+     name: CreatedAt
+     type: "N"
+   readCapacityUnits: 10
+   writeCapacityUnits: 10

The dynamodb table gets created but sets CreatedAt to "S"

Looking at the cloudformation template, I see that the value N is allowed out of the 3 values S,N,B

but

regardless of what is passed out of the 3 valid values, "S" is the outcome I don't know if this is the culprit but it looks like the attributetype value should be a ref.

https://github.com/awslabs/aws-service-operator/blob/master/cloudformation/dynamodb.yaml#L72

dathan commented 5 years ago

Also, the underlying Cloudformation yaml is being served from s3 defined in https://github.com/awslabs/aws-service-operator/blob/master/pkg/helpers/helpers.go#L104

For the mirror of the issue above this cloudformation yaml is being served by the operator.

https://s3-us-west-2.amazonaws.com/cloudkit-templates/dynamodb.yaml

this file contains the bug from what I gather.

dathan commented 5 years ago

I did a write up here: Showing how to debug the aws-service-operator, as well as the fix which is odd that the aws-service-operator already has the default namespace cloudformation template, but due to code-reuse an extra api call is made to fetch it from an s3 bucket.