Provision a DynamoDB table
We can now define a real DynamoDB table as a Kubernetes resource. Take a look at the manifest:
apiVersion: dynamodb.services.k8s.aws/v1alpha1
kind: Table
metadata:
name: items
namespace: carts
spec:
tableName: ${EKS_CLUSTER_AUTO_NAME}-carts-fastpath
billingMode: PAY_PER_REQUEST
keySchema:
- attributeName: id
keyType: HASH
attributeDefinitions:
- attributeName: id
attributeType: "S"
- attributeName: customerId
attributeType: "S"
globalSecondaryIndexes:
- indexName: idx_global_customerId
keySchema:
- attributeName: customerId
keyType: HASH
- attributeName: id
keyType: RANGE
projection:
projectionType: "ALL"
Uses the ACK DynamoDB controller's Table custom resource.
Names the table after the cluster (${EKS_CLUSTER_AUTO_NAME}-carts-fastpath) so parallel workshop runs don't collide.
Uses on-demand pricing.
Defines the partition key schema, matching what the carts service expects.
Adds a global secondary index on customerId so the service can query carts by customer.
The YAML closely mirrors the DynamoDB CreateTable API. Anything you can express through the API is expressible here.
Apply the manifest:
table.dynamodb.services.k8s.aws/items created
The capability's DynamoDB controller picks up the new Table resource and provisions the corresponding AWS resource. Wait for the ACK.ResourceSynced condition, which is how every ACK resource signals it has reconciled successfully:
table.dynamodb.services.k8s.aws/items condition met
Inspect the resource status:
ACTIVE
Finally, confirm the table exists in AWS:
ACTIVE
We've created a real DynamoDB table without ever leaving the Kubernetes API. The capability handled both the controller infrastructure and the IAM permissions needed to call the DynamoDB API.