Simple automation scripts for deploying DocumentDB operator on AWS EKS.
- AWS CLI configured:
aws configure - Required tools:
aws,eksctl,kubectl,helm,jq - Optional for operator installation: GitHub account and token for authenticated GHCR pulls
The DocumentDB operator chart is published to GHCR as a public OCI artifact and can usually be pulled anonymously. If your environment requires authenticated GHCR access, set credentials before running the script:
-
Create GitHub Personal Access Token:
- Go to https://github.com/settings/tokens
- Click "Generate new token (classic)"
- Select scope:
read:packages - Copy the generated token
-
Set Environment Variables:
export GITHUB_USERNAME="your-github-username" export GITHUB_TOKEN="ghp_xxxxxxxxxxxxxxxxxxxx"
# Create EKS cluster with DocumentDB (includes public IP LoadBalancer)
./scripts/create-cluster.sh --deploy-instance
# Delete cluster when done (avoid charges)
./scripts/delete-cluster.sh
# OR keep cluster and delete DocumentDB components
./scripts/delete-cluster.sh --instance-and-operatorThe DocumentDB service is automatically configured with these annotations for public IP access:
serviceAnnotations:
service.beta.kubernetes.io/aws-load-balancer-type: "nlb"
service.beta.kubernetes.io/aws-load-balancer-scheme: "internet-facing"
service.beta.kubernetes.io/aws-load-balancer-cross-zone-load-balancing-enabled: "true"
service.beta.kubernetes.io/aws-load-balancer-nlb-target-type: "ip"Note: These annotations are automatically applied by the DocumentDB operator when environment: eks is specified in the DocumentDB resource. Manual patching is no longer required.
Note: It takes 2-5 minutes for AWS to provision the Network Load Balancer and assign a public IP.
# Basic usage (cluster only)
./scripts/create-cluster.sh
# With operator using environment variables
export GITHUB_USERNAME="your-username"
export GITHUB_TOKEN="your-token"
./scripts/create-cluster.sh --install-operator
# With operator using command-line parameters
./scripts/create-cluster.sh --install-operator \
--github-username "your-username" \
--github-token "your-token"
# Custom configuration
./scripts/create-cluster.sh --cluster-name my-cluster --region us-east-1
# See all options
./scripts/create-cluster.sh --helpAvailable options:
--cluster-name NAME- EKS cluster name (default: documentdb-cluster)--region REGION- AWS region (default: us-west-2)--skip-operator- Skip operator installation (default)--install-operator- Install operator (requires GitHub authentication)--deploy-instance- Deploy operator + instance (requires GitHub authentication)--node-type TYPE- EC2 instance type (default:m7g.large, Graviton/ARM)--eks-version VER- Kubernetes/EKS version (default:1.35)--spot- Use Spot-backed managed nodes (dev/test only — see warning below)--tags TAGS- Cost allocation tags as comma-separatedkey=valuepairs (default:project=documentdb-playground,environment=dev,managed-by=eksctl)
When using --spot, AWS can terminate instances at any time with only 2 minutes notice.
This will interrupt your database and require recovery. Only use Spot for dev/test
workloads where brief downtime is acceptable. Spot is disabled by default.
Tags are passed to AWS for cost allocation tracking in Cost Explorer:
# Default tags
./scripts/create-cluster.sh
# Tags: project=documentdb-playground,environment=dev,managed-by=eksctl
# Custom tags via flag
./scripts/create-cluster.sh --tags "project=myproj,team=platform,costcenter=1234"
# Or via environment variable
export CLUSTER_TAGS="project=myproj,team=platform"
./scripts/create-cluster.sh# Delete everything (default)
./scripts/delete-cluster.sh
# Delete only DocumentDB instances (keep operator and cluster)
./scripts/delete-cluster.sh --instance-only
# Delete instances and operator (keep cluster)
./scripts/delete-cluster.sh --instance-and-operator
# Custom configuration
./scripts/delete-cluster.sh --cluster-name my-cluster --region us-east-1
# See all options
./scripts/delete-cluster.sh --helpAvailable options:
--cluster-name NAME- EKS cluster name (default: documentdb-cluster)--region REGION- AWS region (default: us-west-2)--instance-only- Delete only DocumentDB instances--instance-and-operator- Delete instances and operator (keep cluster)
Common scenarios:
- Default: Delete everything (instances + operator + cluster)
- Cost optimization: Use
--instance-and-operatorto preserve expensive EKS setup - Testing instances: Use
--instance-onlyto test deployments without recreating operator - Operator upgrades: Use
--instance-and-operatorto reinstall operator without losing cluster
create-cluster.sh builds:
- EKS cluster with managed nodes (default:
m7g.largeGraviton/ARM, 3 nodes) - EBS CSI driver for storage
- AWS Load Balancer Controller
- cert-manager for TLS
- Optimized storage classes
Estimated cost: ~$140-230/month (always run delete-cluster.sh when done!) — use --spot for ~70% savings on dev/test.