Package: cdklabs.cdk-aws-sagemaker-role-manager
cdk-aws-sagemaker-role-managerUsageCreate Role from ML Activity with VPC and KMS conditionsimport{Stack}from'aws-cdk-lib';import{Activity}from'@cdklabs/cdk-aws-sagemaker-role-manager';conststack=newStack(app,'CdkRoleManagerDemo');constactivity=Activity.manageJobs(stack,'id1',{rolesToPass:[iam.Role.fromRoleName('Enter Name')],subnets:[ec2.Subnet.fromSubnetId('Enter Id')],securityGroups:[ec2.SecurityGroup.fromSecurityGroupId('Enter Id')],dataKeys:[kms.Key.fromKeyArn('Enter Key Arn')],volumeKeys:[kms.Key.fromKeyArn('Enter Key Arn')],});activity.createRole(stack,'role id','Enter Name');Create Role from ML Activity without VPC and KMS conditionsimport{Stack}from'aws-cdk-lib';import{Activity}from'@cdklabs/cdk-aws-sagemaker-role-manager';conststack=newStack(app,'CdkRoleManagerDemo');constactivity=Activity.manageJobs(this,'id1',{rolesToPass:[iam.Role.fromRoleName('Enter Name')],});activity.createRole(this,'role id','Enter Name','Enter Description');Create Role from Data Scientist ML Personaimport{Stack}from'aws-cdk-lib';import{Activity,Persona}from'@cdklabs/cdk-aws-sagemaker-role-manager';conststack=newStack(app,'CdkRoleManagerDemo');letpersona=newPersona(this,'persona id',{activities:[Activity.useStudioApps(),Activity.manageJobs(this,'id1',{rolesToPass:[iam.Role.fromRoleName('Enter Name')]}),Activity.manageModels(this,'id2',{rolesToPass:[iam.Role.fromRoleName('Enter Name')]}),Activity.manageExperiments(this,'id3',{}),Activity.searchExperiments(this,'id4',{}),Activity.accessBuckets(this,'id5',{buckets:[s3.S3Bucket.fromBucketName('Enter Name')]})],subnets:[ec2.Subnet.fromSubnetId('Enter Id')],securityGroups:[ec2.SecurityGroup.fromSecurityGroupId('Enter Id')],dataKeys:[kms.Key.fromKeyArn('Enter Key Arn')],volumeKeys:[kms.Key.fromKeyArn('Enter Key Arn')],});persona.createRole(this,'role id','Enter Name','Enter Description');Create Role from Data Scientist ML Persona without vpc and kms global conditionsimport{Stack}from'aws-cdk-lib';import{Activity,Persona}from'@cdklabs/cdk-aws-sagemaker-role-manager';conststack=newStack(app,'CdkRoleManagerDemo');//PleaseseebelowhowtocreatetheDataScientistMLPersonausingitsMLActivities.//Youcanupdatethefollowinglistwithchangesmatchingyourusecase.letpersona=newPersona(this,'persona id',{activities:[Activity.useStudioApps(),Activity.manageJobs(this,'id1',{rolesToPass:[iam.Role.fromRoleName('Enter Name')]}),Activity.manageModels(this,'id2',{rolesToPass:[iam.Role.fromRoleName('Enter Name')]}),Activity.manageExperiments(this,'id3',{}),Activity.searchExperiments(this,'id4',{}),Activity.accessBuckets(this,'id5',{buckets:[s3.S3Bucket.fromBucketName('Enter Name')]})],});//WecancreatearolewithDataScientistpersonapermissionsconstrole=persona.createRole(this,'role id','Enter Name','Enter Description');Create Role MLOps ML Personaimport{Stack}from'aws-cdk-lib';import{Activity,Persona}from'@cdklabs/cdk-aws-sagemaker-role-manager';conststack=newStack(app,'CdkRoleManagerDemo');letpersona=newPersona(this,'persona id',{activities:[Activity.useStudioApps(this,'id1',{}),Activity.manageModels(this,'id2',{rolesToPass:[iam.Role.fromRoleName('Enter Name')]}),Activity.manageEndpoints(this,'id3',{rolesToPass:[iam.Role.fromRoleName('Enter Name')]}),Activity.managePipelines(this,'id4',{rolesToPass:[iam.Role.fromRoleName('Enter Name')]}),Activity.searchExperiments(this,'id5',{})],subnets:[ec2.Subnet.fromSubnetId('Enter Id')],securityGroups:[ec2.SecurityGroup.fromSecurityGroupId('Enter Id')],dataKeys:[kms.Key.fromKeyArn('Enter Key Arn')],volumeKeys:[kms.Key.fromKeyArn('Enter Key Arn')],});constrole=persona.createRole(this,'role id','Enter Name','Enter Description');Create Role from MLOps ML Persona without vpc and kms global conditionsimport{Stack}from'aws-cdk-lib';import{Activity,Persona}from'@cdklabs/cdk-aws-sagemaker-role-manager';conststack=newStack(app,'CdkRoleManagerDemo');letpersona=newPersona(this,'persona id',{activities:[Activity.useStudioApps(this,'id1',{}),Activity.manageModels(this,'id2',{rolesToPass:[iam.Role.fromRoleName('Enter Name')]}),Activity.manageEndpoints(this,'id3',{rolesToPass:[iam.Role.fromRoleName('Enter Name')]}),Activity.managePipelines(this,'id4',{rolesToPass:[iam.Role.fromRoleName('Enter Name')]}),Activity.searchExperiments(this,'id5',{})],});constrole=persona.createRole(this,'role id','Enter Name','Enter Description');Available ML ActivitiesML Activity NameML Activity InterfaceML Activity DescriptionML Activity Required ParametersAccess Required AWS ServicesActivity.accessAwsServices()Permissions to access S3, ECR, Cloudwatch and EC2. Required for execution roles for jobs and endpoints.ecrRepositories, s3BucketsRun Studio ApplicationsActivity.runStudioApps()Permissions to operate within a Studio environment. Required for domain and user-profile execution roles.rolesToPassManage ML JobsActivity.manageJobs()Permissions to manage SageMaker jobs across their lifecycles.rolesToPassManage ModelsActivity.manageModels()Permissions to manage SageMaker models and Model Registry.rolesToPassManage EndpointsActivity.manageEndpoints()Permissions to manage SageMaker Endpoint deployments and updates.No required parametersManage PipelinesActivity.managePipelines()Permissions to manage SageMaker Pipelines and pipeline executions.rolesToPassManage ExperimentsActivity.manageExperiments()Permissions to manage experiments and trials.No required parametersSearch and visualize experimentsActivity.visualizeExperiments()Permissions to audit, query lineage and visualize experiments.No required parametersManage Model MonitoringActivity.monitorModels()Permissions to manage monitoring schedules for SageMaker Model Monitor.rolesToPassS3 Full AccessActivity.accessS3AllResources()Permissions to perform all S3 operationsNo required parametersS3 Bucket AccessActivity.accessS3Buckets()Permissions to perform operations on specified buckets.s3BucketsQuery Athena WorkgroupsActivity.queryAthenaGroups()Permissions to execute and manage Amazon Athena queries.athenaWorkgroupNamesManage Glue TablesActivity.manageGlueTables()Permissions to create and manage Glue tables for SageMaker Feature Store and Data Wrangler.s3Buckets, glueDatabaseNamesSecuritySeeCONTRIBUTINGfor more information.LicenseThis project is licensed under the Apache-2.0 License.