Migrate the carts service
The DynamoDB table exists, but the carts Deployment is still pointed at the in-cluster carts-dynamodb Pod. Two changes flip it onto the AWS table:
- ConfigMap — replace
RETAIL_CART_PERSISTENCE_DYNAMODB_ENDPOINTand remove the_CREATE_TABLEflag (the table already exists). - EKS Pod Identity — bind the
cartsServiceAccount to a pre-provisioned IAM role so the Pod can call DynamoDB. The role and its policy are created duringprepare-environment; we just need to associate it with the ServiceAccount.
Inspect the kustomization that patches the ConfigMap:
- Kustomize Patch
- ConfigMap/carts
- Diff
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- ../../../../../base-application/carts
configMapGenerator:
- name: carts
namespace: carts
env: config.properties
behavior: replace
options:
disableNameSuffixHash: true
apiVersion: v1
data:
RETAIL_CART_PERSISTENCE_DYNAMODB_TABLE_NAME: ${EKS_CLUSTER_AUTO_NAME}-carts-fastpath
RETAIL_CART_PERSISTENCE_PROVIDER: dynamodb
kind: ConfigMap
metadata:
name: carts
namespace: carts
apiVersion: v1
data:
- AWS_ACCESS_KEY_ID: key
- AWS_SECRET_ACCESS_KEY: secret
- RETAIL_CART_PERSISTENCE_DYNAMODB_CREATE_TABLE: "true"
- RETAIL_CART_PERSISTENCE_DYNAMODB_ENDPOINT: http://carts-dynamodb:8000
- RETAIL_CART_PERSISTENCE_DYNAMODB_TABLE_NAME: Items
+ RETAIL_CART_PERSISTENCE_DYNAMODB_TABLE_NAME: ${EKS_CLUSTER_AUTO_NAME}-carts-fastpath
RETAIL_CART_PERSISTENCE_PROVIDER: dynamodb
kind: ConfigMap
metadata:
name: carts
The base-application's local carts-dynamodb Pod and Service stay in place. We're only flipping the application's pointer at the database — cleanup will restore the original ConfigMap so other labs work normally.
Apply the kustomization:
Bind the carts ServiceAccount to the IAM role via EKS Pod Identity. The role ${EKS_CLUSTER_AUTO_NAME}-carts-dynamo was created by prepare-environment and already has access to both the -carts and -carts-fastpath tables:
Restart the carts Pod so it picks up the new ConfigMap and the Pod Identity binding:
deployment.apps/carts restarted
deployment "carts" successfully rolled out
Confirm the Pod sees the new table name and has Pod Identity credentials available:
RETAIL_CART_PERSISTENCE_DYNAMODB_TABLE_NAME=...-carts-fastpath
AWS_CONTAINER_CREDENTIALS_FULL_URI=http://...
The AWS_CONTAINER_CREDENTIALS_FULL_URI env var being present confirms Pod Identity is wiring the IAM role into the Pod. Every DynamoDB call the carts service makes will use the role's credentials, scoped to only the tables we provisioned.
That's Lab 1 done. The retail app is now backed by a real, AWS-managed DynamoDB table, provisioned and reconciled entirely from the Kubernetes API by an EKS capability.
Next, we'll deliver the catalog service via GitOps using the Argo CD capability.