Run interactive IDEs on Amazon EKS with SageMaker AI to power up your AI workflows
The Amazon SageMaker AI Spaces add-on for Amazon EKS runs managed JupyterLab and Code Editor environments on the cluster your ML team already operates. This post shows how to install and configure the add-on, connect from the browser and from VS Code over SSH-over-SSM, and move your team to OpenID Connect sign-in with Amazon Cognito.
To power up AI workflows on Amazon Elastic Kubernetes Service (Amazon EKS), data scientists need interactive IDEs like JupyterLab and Code Editor. Yet running those IDEs usually means leaving the cluster that hosts their pipelines, moving to a standalone JupyterHub deployment or a local laptop. That switch leaves them without the GPU nodes, shared storage, and AWS Identity and Access Management (IAM) roles their pipelines depend on. The Amazon SageMaker AI Spaces add-on for Amazon EKS closes that gap. It runs managed JupyterLab and Code Editor environments on the cluster that you already operate. Standing up a standalone JupyterHub environment with GPU access, storage, and authentication typically takes a platform team 3–5 days. With the add-on, a data scientist launches a fully configured Space in about 5 minutes.
In this post, you install the SageMaker AI Spaces add-on on an Amazon EKS cluster. You set up the supporting add-ons and IAM roles, deploy the AWS Load Balancer Controller, request a TLS certificate, and create an AWS Key Management System (AWS KMS) encryption key. You then create your first Space and reach it through a presigned URL in the browser and from VS Code over SSH-over-SSM. Finally, you review how to move your team to OpenID Connect (OIDC) sign-in with Amazon Cognito.
Solution overview
The solution runs on a single EKS cluster in three layers:
Network and access. Amazon Route 53 resolves a wildcard domain to an internet-facing Application Load Balancer (ALB) with TLS from AWS Certificate Manager (ACM). For VS Code, AWS Systems Manager tunnels directly to the Space pod.
Cluster routing. The AWS Load Balancer Controller provisions the ALB. Traefik routes by hostname. Auth middleware validates tokens using AWS Key Management Service (AWS KMS) for JSON Web Token (JWT) encryption.
Compute and storage. Space pods run on private-subnet workers. The Amazon Elastic Block Store (Amazon EBS) CSI driver provides persistent volumes, and Amazon Elastic File System (Amazon EFS) or Amazon FSx handle shared or high-throughput storage. EKS Pod Identity grants pods scoped IAM roles.
Consolidating interactive and training workloads on one cluster keeps GPU nodes busy between jobs. This can lift GPU utilization by up to 30 percent compared with a dedicated notebook fleet. It also avoids the cost of an always-on GPU environment, which can run into thousands of dollars a month.
Figure 1: Solution architecture
Prerequisites
To follow along, you need an AWS account with the AWS Command Line Interface (AWS CLI) 2.x or later configured for your target AWS Region, plus kubectl 1.30 or later and Helm v3. You also need a Route 53 public hosted zone for a domain you own, referenced as throughout this post, and IAM permissions to create roles, policies, EKS add-ons, access entries, Pod Identity associations, ACM certificates, and KMS keys. The Spaces add-on must be version 0.1.4 or later, because earlier versions supported Amazon SageMaker HyperPod only.
Figure 2: Route 53 hosted zone with validation records
Set these variables once. The rest of the post reuses them.
export CLUSTER_NAME= export REGION= export ACCOUNT_ID=$(aws sts get-caller-identity --query Account --output text)
Every IAM role in this post is assumed by a Kubernetes service account through EKS Pod Identity, so they all share one trust policy. Save it once and reuse it:
cat > pod-identity-trust.json 38m v1.34.6-eks-bbe087e ip-10-0-2-96.ec2.internal Ready 38m v1.34.6-eks-bbe087e
Confirm the system pods are healthy across the add-on namespaces with kubectl get pods -A. Every pod in kube-system, cert-manager, and external-dns should be Running before you continue.
External DNS needs Route 53 permissions to manage records. Create the role, attach a least-privilege policy, and bind it through Pod Identity:
aws iam create-role --role-name ExternalDNSRole \ --assume-role-policy-document file://pod-identity-trust.json
aws iam put-role-policy --role-name ExternalDNSRole \ --policy-name ExternalDNSRoute53Policy \ --policy-document '{ "Version":"2012-10-17", "Statement":[ {"Effect":"Allow","Action":["route53:ChangeResourceRecordSets"], "Resource":"arn:aws:route53:::hostedzone/*"}, {"Effect":"Allow","Action":["route53:ListHostedZones","route53:ListResourceRecordSets","route53:ListTagsForResource"], "Resource":"*"} ]}'
aws eks create-pod-identity-association \ --cluster-name $CLUSTER_NAME --region $REGION \ --namespace external-dns --service-account external-dns \ --role-arn arn:aws:iam::${ACCOUNT_ID}:role/ExternalDNSRole
kubectl rollout restart deployment -n external-dns external-dns
Security note: Scope each Pod Identity role to minimum actions and resources. Prefer explicit resource ARNs over wildcards, and confirm only the intended service account can assume the role.
Install the AWS Load Balancer Controller
The AWS Load Balancer Controller provisions the ALB that fronts your Spaces UI. Install it with Helm.
Define the controller’s IAM policy, role, and Pod Identity association:
curl -sS -o /tmp/lbc-iam-policy.json \ https://raw.githubusercontent.com/kubernetes-sigs/aws-load-balancer-controller/main/docs/install/iam_policy.json
aws iam create-policy --policy-name AWSLoadBalancerControllerIAMPolicy \ --policy-document file:///tmp/lbc-iam-policy.json
aws iam create-role --role-name AWSLoadBalancerControllerRole \ --assume-role-policy-document file://pod-identity-trust.json
aws iam attach-role-policy --role-name AWSLoadBalancerControllerRole \ --policy-arn arn:aws:iam::${ACCOUNT_ID}:policy/AWSLoadBalancerControllerIAMPolicy
aws eks create-pod-identity-association \ --cluster-name $CLUSTER_NAME --region $REGION \ --namespace kube-system --service-account aws-load-balancer-controller \ --role-arn arn:aws:iam::${ACCOUNT_ID}:role/AWSLoadBalancerControllerRole
Install the Helm chart. Pass vpcId and region explicitly. On chart v3.2+, the controller fails if it auto-detects the VPC through EC2 metadata, which EKS blocks for pods.
helm repo add eks https://aws.github.io/eks-charts helm repo update eks
helm install aws-load-balancer-controller eks/aws-load-balancer-controller \ -n kube-system \ --set clusterName=$CLUSTER_NAME \ --set serviceAccount.create=true \ --set serviceAccount.name=aws-load-balancer-controller \ --set region=$REGION \ --set vpcId=$VPC_ID
kubectl rollout status deployment -n kube-system aws-load-balancer-controller --timeout=180s
Both controller replicas come up:
NAME READY UP-TO-DATE AVAILABLE AGE aws-load-balancer-controller 2/2 2 2 174m
Create the certificate, key, and SSM configuration
The Spaces add-on needs a TLS certificate, a KMS key for JWT encryption, and SSM service settings for remote access.
Request an ACM certificate covering your domain and a wildcard, using DNS validation, then read back the CNAME records ACM expects:
CERT_ARN=$(aws acm request-certificate \ --domain-name "" \ --subject-alternative-names "*." \ --validation-method DNS \ --region $REGION \ --query CertificateArn --output text)
Read the CNAME records ACM expects, then add them to your Route 53
hosted zone. The console's 'Create records in Route 53' button
does this for you.
aws acm describe-certificate --certificate-arn "$CERT_ARN" \ --region $REGION \ --query 'Certificate.DomainValidationOptions[].ResourceRecord'
Wait for the certificate status to reach Issued, then copy the ARN.
Figure 3: Certificate issued for the domain
Security note: DNS validation verifies domain ownership and triggers ACM automatic renewal. Keep the validation CNAMEs in Route 53. Removing them breaks renewal.
Create a KMS encryption key. The auth middleware calls kms:GenerateDataKey per JWT, so the key must be symmetric ENCRYPT_DECRYPT, which is the CLI default:
KMS_KEY_ARN=$(aws kms create-key --region $REGION \ --description "SageMaker Spaces JWT encryption" \ --query 'KeyMetadata.Arn' --output text)
aws kms create-alias --region $REGION \ --alias-name alias/sagemaker-spaces-jwt \ --target-key-id "$KMS_KEY_ARN"
Turn on the SSM advanced-instances tier. Session Manager tunnels to hybrid managed instances, which is what VS Code remote uses, require this tier (about $0.00695/hr per Space pod):
aws ssm update-service-setting --region $REGION \ --setting-id arn:aws:ssm:$REGION:${ACCOUNT_ID}:servicesetting/ssm/managed-instance/activation-tier \ --setting-value advanced
Install the Spaces add-on
You create IAM roles for the Spaces controller and auth middleware, then install the add-on.
Start with the SSM managed-instance role that each Space pod uses in the SSM fleet:
aws iam create-role --role-name SageMakerSpacesSSMManagedNodeRole \ --assume-role-policy-document '{ "Version":"2012-10-17", "Statement":[{"Effect":"Allow","Principal":{"Service":"ssm.amazonaws.com"},"Action":"sts:AssumeRole"}] }'
aws iam attach-role-policy --role-name SageMakerSpacesSSMManagedNodeRole \ --policy-arn arn:aws:iam::aws:policy/AmazonSSMManagedInstanceCore
Next, create the Spaces controller role. It needs SSM, PassRole, and KMS permissions. Save the following policy as spaces-controller-policy.json, replacing , , and with your own values:
{ "Version": "2012-10-17", "Statement": [ { "Sid": "SSMAccountLevel", "Effect": "Allow", "Action": [ "ssm:CreateActivation", "ssm:DeleteActivation", "ssm:DescribeActivations", "ssm:DescribeInstanceInformation", "ssm:DeregisterManagedInstance", "ssm:ListTagsForResource", "ssm:AddTagsToResource", "ssm:ListDocuments", "ssm:DescribeSessions" ], "Resource": "*" }, { "Sid": "SSMDocumentMgmt", "Effect": "Allow", "Action": [ "ssm:CreateDocument", "ssm:DescribeDocument", "ssm:GetDocument", "ssm:UpdateDocument", "ssm:UpdateDocumentDefaultVersion", "ssm:DeleteDocument" ], "Resource": "arn:aws:ssm:::document/SageMaker-Space*" }, { "Sid": "SSMSessionMgmt", "Effect": "Allow", "Action": [ "ssm:StartSession", "ssm:TerminateSession", "ssm:ResumeSession", "ssm:GetConnectionStatus" ], "Resource": [ "arn:aws:ssm:::document/SageMaker-Space*", "arn:aws:ssm:::managed-instance/*", "arn:aws:ssm:::document/AWS-StartSSHSession" ] }, { "Sid": "PassSSMManagedNodeRole", "Effect": "Allow", "Action": "iam:PassRole", "Resource": "arn:aws:iam:::role/SageMakerSpacesSSMManagedNodeRole", "Condition": { "StringEquals": { "iam:PassedToService": "ssm.amazonaws.com" } } }, { "Sid": "KMSForJWT", "Effect": "Allow", "Action": [ "kms:GenerateDataKey", "kms:Decrypt", "kms:Encrypt", "kms:DescribeKey" ], "Resource": "" } ] }
Create the role and attach the policy:
aws iam create-role --role-name SageMakerSpacesControllerRole \ --assume-role-policy-document file://pod-identity-trust.json
aws iam put-role-policy --role-name SageMakerSpacesControllerRole \ --policy-name SageMakerSpacesControllerPolicy \ --policy-document file://spaces-controller-policy.json
Bind controller and auth middleware service accounts to this role through Pod Identity:
for SA in jupyter-k8s-controller-manager jupyter-k8s-authmiddleware; do aws eks create-pod-identity-association \ --cluster-name $CLUSTER_NAME --region $REGION \ --namespace jupyter-k8s-system --service-account $SA \ --role-arn arn:aws:iam::${ACCOUNT_ID}:role/SageMakerSpacesControllerRole done
Security note: For tighter separation of duties, split this into two roles: one with SSM actions for the controller, and one with KMS encrypt and decrypt for the auth middleware.
Define addon-config.yaml with your domain, certificate ARN, key ARN, and managed-node role name:
jupyter-k8s:
'enable' (not 'enabled') is correct here, per the official AWS docs:
https://docs.aws.amazon.com/sagemaker/latest/dg/operator-install.html
The jupyter-k8s and jupyter-k8s-aws-hyperpod subcharts use different
schemas, so clusterWebUI below correctly uses 'enabled'. Not a typo.
workspacePodWatching: enable: true jupyter-k8s-aws-hyperpod: clusterWebUI: enabled: true domain: "" awsCertificateArn: "" traefik: shouldInstall: true auth: kmsKeyId: "" remoteAccess: enabled: true ssmManagedNodeRole: SageMakerSpacesSSMManagedNodeRole
Install the add-on:
aws eks create-addon \ --cluster-name $CLUSTER_NAME --region $REGION \ --addon-name amazon-sagemaker-spaces \ --configuration-values file://addon-config.yaml \ --resolve-conflicts OVERWRITE
Poll until the add-on reaches ACTIVE (about three minutes):
aws eks describe-addon \ --cluster-name $CLUSTER_NAME --region $REGION \ --addon-name amazon-sagemaker-spaces \ --query 'addon.{status:status,version:addonVersion,issues:health.issues}'
The add-on reports ACTIVE with an empty issues list:
{ "status": "ACTIVE", "version": "v0.1.4-eksbuild.1", "issues": [] }
Confirm all Spaces pods are Running:
kubectl get pods -n jupyter-k8s-system
The controller, two auth middleware replicas, and two Traefik routers should all be Running:
NAME READY STATUS RESTARTS AGE jupyter-k8s-controller-manager-65fcd4d67f-* 1/1 Running 0 3h13m workspace-auth-middleware-c7f7fbb6d-* 1/1 Running 0 3h13m workspace-auth-middleware-c7f7fbb6d-* 1/1 Running 0 3h13m workspace-traefik-router-755d494fbf-* 1/1 Running 0 3h13m workspace-traefik-router-755d494fbf-* 1/1 Running 0 3h13m
Grant user access and create a Space
With the add-on healthy, you grant a user access to the cluster and create the first JupyterLab Space. Access relies on an EKS access entry scoped to a single namespace, so users can’t reach resources outside it.
Grant access through an EKS access entry. In the EKS console, navigate to your cluster’s Access tab and choose Create access entry. Choose your IAM user or role, then add AmazonSagemakerHyperpodSpacePolicy for the default namespace.
Figure 4: Access entry for namespace
Security note: Prefer namespace-scoped access over cluster-wide policies so users can’t modify resources outside their namespace.
List the pre-installed Workspace templates and access strategies:
kubectl get workspacetemplate -A kubectl get workspaceaccessstrategies -A
You see sagemaker-jupyter-template, sagemaker-code-editor-template, and hyperpod-access-strategy in jupyter-k8s-system. Reference these in your Workspace rather than repeating configuration inline.
Define workspace.yaml for a JupyterLab Space:
apiVersion: workspace.jupyter.org/v1alpha1 kind: Workspace metadata: name: my-space namespace: default spec: templateRef: name: sagemaker-jupyter-template namespace: jupyter-k8s-system appType: jupyterlab accessType: OwnerOnly accessStrategy: name: hyperpod-access-strategy namespace: jupyter-k8s-system image: public.ecr.aws/sagemaker/sagemaker-distribution:latest-cpu
accessType: OwnerOnly restricts browser access to the IAM principal that created the Space. Use Public for any namespace-authorized user.
Apply and wait for the Space to become Available:
kubectl apply -f workspace.yaml kubectl get workspace -n default -w
workspace.workspace.jupyter.org/my-space created
First-time startup takes about five minutes. The cluster pulls the 4 GB SageMaker Distribution image and registers the pod with SSM.
Figure 5: Space running
Connect in the browser
The Spaces controller issues a short-lived, presigned URL that carries the user’s encrypted token. You generate one, then navigate to it in your browser.
Generate a short-lived presigned URL:
kubectl create -f - -o yaml ./bearer-auth?token=eyJhbGciOiJIUzM4NCIsImVkayI6...
Security note: Presigned URLs carry the user’s KMS-encrypted JWT with a 5-minute expiry enforced by the exp claim. This value isn’t configurable in the current add-on version. Don’t log or share presigned URLs over unencrypted channels. For durable access, use VS Code remote.
Figure 6: JupyterLab on the custom domain
Connect from VS Code
For a local IDE experience, VS Code connects to the Space pod through an SSM tunnel, with no browser, domain, or ALB required.
Install VS Code, the AWS Toolkit extension, and the Session Manager plugin locally.
Generate a VS Code connection URL by creating the same WorkspaceConnection resource as before, with workspaceConnectionType: vscode-remote instead of web-ui. This time the response carries a vscode:// deep link instead of an HTTPS URL:
status: workspaceConnectionType: vscode-remote workspaceConnectionUrl: vscode://amazonwebservices.aws-toolkit-vscode/connect/workspace?sessionId=eks-Sagemaker--jupyter-k8s-...&sessionToken=...&streamUrl=wss://ssmmessages..amazonaws.com/v1/data-channel/...&workspaceName=my-space&namespace=default&eksClusterArn=arn:aws:eks:::cluster/
Paste the vscode:// URL into your browser. The browser prompts you to open the link in VS Code.
Figure 7: Browser opens VS Code
Accept the prompt. AWS Toolkit establishes an SSH-over-SSM tunnel to the Space, and VS Code attaches to the remote filesystem.
Figure 8: VS Code with remote kernel
For private-subnet configurations and SDK alternatives, see Remote access to SageMaker AI Spaces.
Sign in with corporate credentials using OIDC
Access so far relies on IAM users and roles. To let your team sign in with corporate credentials instead, register an OIDC provider with the cluster and bind Kubernetes role-based access control (RBAC) to identity provider groups. Kubernetes then authorizes people by group membership, with no IAM principal per user.
The open source jupyter-deploy project ships an aws-eks-oidc template that sets this up for you. Dex runs in the cluster as the OIDC provider, Amazon EKS trusts it as an identity provider, and a web console gives your team self-service workspace management. The template provisions its own VPC and cluster, so run it alongside the cluster from this post.
Figure 9: Self-managed OIDC with Amazon Cognito
The template ships a Dex connector for GitHub. Amazon Cognito works through the generic oidc connector in Dex instead, and needs two claim mappings that GitHub never requires. Amazon EKS reads the username from the preferred_username claim, which Cognito doesn’t issue, so map it from email. Cognito also publishes group membership as cognito:groups rather than groups. Miss the username mapping and requests reach the API server with no resolvable user, and the console reports an expired session rather than an authorization error. The template binds its RBAC role to a group named :, so create a Cognito group with that exact name and add your users to it.
Your team then signs in at the Cognito managed login page. With a single connector configured, Dex skips the provider chooser.
Figure 10: Cognito managed login
The console lists and creates workspaces under that identity.
Figure 11: Self-service workspace management
Opening one launches JupyterLab, authorized as the Cognito user.
Figure 12: JupyterLab for the Cognito user
Cleanup
To avoid ongoing charges, delete resources in reverse order.
Delete the Space and the add-on:
kubectl delete workspace my-space -n default
aws eks delete-addon --cluster-name $CLUSTER_NAME --region $REGION \ --addon-name amazon-sagemaker-spaces
Uninstall the Load Balancer Controller and remaining add-ons:
helm uninstall aws-load-balancer-controller -n kube-system
for a in aws-ebs-csi-driver external-dns cert-manager eks-pod-identity-agent kube-proxy; do aws eks delete-addon --cluster-name $CLUSTER_NAME --region $REGION --addon-name $a done
Delete the IAM roles, policies, and Pod Identity associations you created (ExternalDNSRole, AWSLoadBalancerControllerRole, AWSLoadBalancerControllerIAMPolicy, SageMakerSpacesControllerRole, SageMakerSpacesSSMManagedNodeRole).
Delete the certificate, schedule the KMS key for deletion (7-day minimum), and remove the Route 53 records.
Revert the SSM advanced-instances tier to stop per-instance charges across the account:
aws ssm update-service-setting --region $REGION \ --setting-id arn:aws:ssm:$REGION:${ACCOUNT_ID}:servicesetting/ssm/managed-instance/activation-tier \ --setting-value standard
Delete the node group and EKS cluster, and delete the VPC if you created it for this walkthrough.
Note: Skipping these steps continues to incur charges for the EKS cluster, node group, EBS volumes, ALB, and each registered hybrid instance on advanced tier.
Conclusion
In this post, you installed the SageMaker AI Spaces add-on on an Amazon EKS cluster and configured browser and VS Code access. You also saw how to move your team to OIDC sign-in with Amazon Cognito. By consolidating interactive IDEs onto the cluster you already run, you manage one environment instead of two and cut time-to-first-notebook from days to minutes.
To go further, attach AWS WAF, federate additional providers, split controller and auth middleware IAM roles, or set namespace-level resource quotas.
For related approaches, see:
Power up your ML workflows with interactive IDEs on SageMaker HyperPod.
Accelerate foundation model training and inference with Amazon SageMaker HyperPod and Amazon SageMaker Studio.
About the authors