-
Notifications
You must be signed in to change notification settings - Fork 3.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
sagemaker: can not launch studio app for a SSO user that is created with CDK #23627
Comments
I get the same error using the python cdk |
Hi After you CDK deploy, you need to I will reach out to the relevant team internally for this, but this is how it works now. My CDK code: import * as cdk from 'aws-cdk-lib';
import { Construct } from 'constructs';
import { aws_sagemaker as sagemaker,
aws_ec2 as ec2,
aws_iam as iam } from 'aws-cdk-lib';
import { IamResource } from 'aws-cdk-lib/aws-appsync';
export class SagemakerTsStack extends cdk.Stack {
constructor(scope: Construct, id: string, props?: cdk.StackProps) {
super(scope, id, props);
const vpc = ec2.Vpc.fromLookup(this, 'Vpc', { isDefault: true });
const executionRole = new iam.Role(this, 'ExecutionRole', {
managedPolicies: [
iam.ManagedPolicy.fromAwsManagedPolicyName('AmazonSageMakerFullAccess'),
iam.ManagedPolicy.fromAwsManagedPolicyName('AmazonSageMakerCanvasFullAccess'),
],
assumedBy: new iam.ServicePrincipal('sagemaker.amazonaws.com'),
});
const domain = new sagemaker.CfnDomain(this, 'Domain', {
authMode: 'SSO',
subnetIds: vpc.selectSubnets({
subnetType: ec2.SubnetType.PUBLIC,
}).subnetIds,
defaultUserSettings: {
executionRole: executionRole.roleArn,
},
vpcId: vpc.vpcId,
domainName: 'mydomain',
});
const userProfile = new sagemaker.CfnUserProfile(this, 'UserProfile', {
domainId: domain.ref,
userProfileName: 'pahudProfile',
singleSignOnUserIdentifier: 'UserName',
singleSignOnUserValue: 'pahud',
});
const jupyter = new sagemaker.CfnApp(this, 'Jupiter', {
appName: 'default',
appType: 'JupyterServer',
domainId: domain.ref,
userProfileName: userProfile.userProfileName,
});
jupyter.node.addDependency(userProfile);
}
} Let me know if it works with you. |
The whole idea is to not go to the console! |
Agree. This is definitely not an acceptable user experience. We have reported this internally to the relevant team. I will update here when I have any news. This is related to SageMaker with SSO and nothing CDK can do at this moment. |
@pahud I can confirm this issue is still happening. Any updates on this? I appreciate it falls under the responsibility of a different team, but just wondering when this will get solved. |
@pahud, we're seeing the same issue when using terraform, AWS CLI and
We can also see However, both This looks like Sagemaker / SSO still internally use some old API Endpoints which are no longer available to external clients (including your own AWS CLI and boto3). And - what's even worse - the new What's even worse, is that:
|
Can confirm that this is still happening. We would like to create a SageMaker domain and assign SSO users to the domain via IaC, but can not get it working without tinkering around in the console. Any updates from the relevant team? |
@mkielar I know this open issue is an |
@l3ku this looks like a possible lead for Terraform folks? hashicorp/terraform-provider-aws#28958 |
@jmeisele, I don't think there's anything to do for Terraform or CDK to call that API. The API is deprecated, you cannot find any implementation of it in boto3 or any other AWS SDK, so the only way that comes to mind would be to look up some very old version of some SDK (before the There's a lot of ifs here, and even more places where things may fail because - officially, at least - the endpoint doesn't exist. I think we just have to wait for AWS / SSO Team to implement missing pieces in the new |
@mkielar received word from my AWS colleague, this is on the roadmap late 2023, Q1 2024 |
Can we get a link to this being noted in a roadmap so that it can be tracked? This seems like such a major miss. |
I am facing similar issue. |
Unfortunately we don't have any workaround from CDK's perspective. Are we still having the issue now? |
I was able to fix this. |
@mkielar @hossein-jazayeri @pahud keep an eye out for for the next terraform-provider-aws release. One of the output attributes is going to be the single sign on ARN for the Sagemaker domain. This can be combined with new resource hashicorp/terraform-provider-aws#34673 |
@jmeisele, could you elaborate how the new resource "aws_sagemaker_domain" "example" {
domain_name = "example"
auth_mode = "SSO"
...
}
resource "aws_sagemaker_user_profile" "example" {
domain_id = aws_sagemaker_domain.example.id
user_profile_name = "user-example"
single_sign_on_user_identifier = "UserName"
single_sign_on_user_value = "user@example.com"
} How do I use resource "aws_ssoadmin_application_assignment" "example" {
application_arn = aws_sagemaker_domain.example.single_sign_on_application_arn
principal_id = aws_identitystore_user.example.user_id
principal_type = "USER"
} Or is there anything else to create? |
I can confirm this deploys in CDK But it won't add your user from AWS Identity Center as a userprofile to the created export class SagemakerTsStack extends cdk.Stack {
constructor(scope: Construct, id: string, props?: cdk.StackProps) {
super(scope, id, props);
const vpc = ec2.Vpc.fromLookup(this, 'Vpc', { isDefault: true });
// create a dummy executionRole
// probably need to scope down its permissions
const executionRole = new iam.Role(this, 'ExecutionRole', {
managedPolicies: [
iam.ManagedPolicy.fromAwsManagedPolicyName('AmazonSageMakerFullAccess'),
iam.ManagedPolicy.fromAwsManagedPolicyName('AmazonSageMakerCanvasFullAccess'),
],
assumedBy: new iam.ServicePrincipal('sagemaker.amazonaws.com'),
});
const domain = new sagemaker.CfnDomain(this, 'Domain', {
authMode: 'SSO',
subnetIds: vpc.selectSubnets({
subnetType: ec2.SubnetType.PUBLIC,
}).subnetIds,
defaultUserSettings: {
executionRole: executionRole.roleArn,
},
vpcId: vpc.vpcId,
domainName: `${Stack.of(this).stackName}Domain`,
});
const userProfile = new sagemaker.CfnUserProfile(this, 'UserProfile', {
domainId: domain.ref,
userProfileName: `${Stack.of(this).stackName}profile`,
singleSignOnUserIdentifier: 'UserName',
singleSignOnUserValue: 'user@example.com', // your iam identity center login name
});
const jupyter = new sagemaker.CfnApp(this, 'Jupiter', {
appName: 'default',
appType: 'JupyterServer',
domainId: domain.ref,
userProfileName: userProfile.userProfileName,
});
jupyter.node.addDependency(userProfile);
}
} part of "Domain": {
"Type": "AWS::SageMaker::Domain",
"Properties": {
"AuthMode": "SSO",
"DefaultUserSettings": {
"ExecutionRole": {
"Fn::GetAtt": [
"ExecutionRole605A040B",
"Arn"
]
}
},
"DomainName": "dummy-stack3Domain",
"SubnetIds": [
"subnet-0564da5939b9f37e8",
"subnet-0a2ae97b17b9f6820",
"subnet-0f1bbb27b1f58cca7"
],
"VpcId": "vpc-1f5b7e78"
},
"Metadata": {
"aws:cdk:path": "dummy-stack3/Domain"
}
},
"UserProfile": {
"Type": "AWS::SageMaker::UserProfile",
"Properties": {
"DomainId": {
"Ref": "Domain"
},
"SingleSignOnUserIdentifier": "UserName",
"SingleSignOnUserValue": "user@example.com",
"UserProfileName": "dummy-stack3profile"
},
"Metadata": {
"aws:cdk:path": "dummy-stack3/UserProfile"
}
}, If you login with your identity from AWS Identity Center you get
I think cloudformation at this moment does not allow you to assign an existing user from AWS IAM Identity Center to the domain. I'll reach out internally to cloudformation and sagemaker team for clarifying. |
internal tracking: V848394195 |
Confirmed that you need to create export class SagemakerTsStack extends cdk.Stack {
constructor(scope: Construct, id: string, props?: cdk.StackProps) {
super(scope, id, props);
const vpc = ec2.Vpc.fromLookup(this, 'Vpc', { isDefault: true });
// create a dummy executionRole
// probably need to scope down its permissions
const executionRole = new iam.Role(this, 'ExecutionRole', {
managedPolicies: [
iam.ManagedPolicy.fromAwsManagedPolicyName('AmazonSageMakerFullAccess'),
iam.ManagedPolicy.fromAwsManagedPolicyName('AmazonSageMakerCanvasFullAccess'),
],
assumedBy: new iam.ServicePrincipal('sagemaker.amazonaws.com'),
});
const domain = new sagemaker.CfnDomain(this, 'Domain', {
authMode: 'SSO',
subnetIds: vpc.selectSubnets({
subnetType: ec2.SubnetType.PUBLIC,
}).subnetIds,
defaultUserSettings: {
executionRole: executionRole.roleArn,
},
vpcId: vpc.vpcId,
domainName: `${Stack.of(this).stackName}Domain`,
});
const userProfile = new sagemaker.CfnUserProfile(this, 'UserProfile', {
domainId: domain.ref,
userProfileName: `${Stack.of(this).stackName}profile`,
singleSignOnUserIdentifier: 'UserName',
singleSignOnUserValue: 'pahud@example.com', // your iam identity center login name
});
// create an assignment
new sso.CfnApplicationAssignment(this, 'MyCfnApplicationAssignment', {
applicationArn: domain.attrSingleSignOnApplicationArn,
principalId: 'e4c88428-7051-70b0-413c-8a32638d2326',
principalType: 'USER',
});
}
}
You need to find out this ID in the IAM Identity Center console under Let me know if it works for you. |
This issue has not received a response in a while. If you want to keep this issue open, please leave a comment below and auto-close will be canceled. |
I'm facing the same issue. |
Describe the bug
I'd like to create sagemaker user and app in a stack along the sagemaker domain using the SSO users in the account. While the stack is deployed without any error, the attempts to open the studio app from the console, yield the following error:
Expected Behavior
The studio app should create jupyter server without any issues.
Current Behavior
The user and app are created with the stack successfully, but upon accessing the jupyter server via user's profile in the console, it fails with the above mentioned error.
Reproduction Steps
Here's the stack:
Configurations look like this:
Possible Solution
No response
Additional Information/Context
sagemaker:CreateApp
.CDK CLI Version
2.59.0
Framework Version
No response
Node.js Version
v18.0.0
OS
Linux
Language
Python
Language Version
Python (3.10.8)
Other information
No response
The text was updated successfully, but these errors were encountered: