View a markdown version of this page

Set up service roles for AWS Clean Rooms ML - AWS Clean Rooms

Set up service roles for AWS Clean Rooms ML

The roles needed to perform lookalike modeling differ from those needed to use a custom model. The following sections describe the roles needed to perform each task.

Set up service roles for lookalike modeling

Create a service role to read training data

AWS Clean Rooms uses a service role to read training data. You can create this role using the console if you have the necessary IAM permissions. If you don't have CreateRole permissions, ask your administrator to create the service role.

To create a service role to train a dataset
  1. Sign in to the IAM console (https://console.aws.amazon.com/iam/) with your administrator account.

  2. Under Access management, choose Policies.

  3. Choose Create policy.

  4. In the Policy editor, select the JSON tab, and then copy and paste the following policy.

    Note

    The following example policy supports the permissions needed to read AWS Glue metadata and its corresponding Amazon S3 data. However, you might need to modify this policy depending on how you've set up your S3 data. This policy doesn't include a KMS key to decrypt data.

    Your AWS Glue resources and underlying Amazon S3 resources must be in the same AWS Region as the AWS Clean Rooms collaboration.

    JSON
    { "Version":"2012-10-17", "Statement": [ { "Effect": "Allow", "Action": [ "glue:GetDatabase", "glue:GetDatabases", "glue:GetTable", "glue:GetTables", "glue:GetPartitions", "glue:GetPartition", "glue:BatchGetPartition", "glue:GetUserDefinedFunctions" ], "Resource": [ "arn:aws:glue:us-east-1:111122223333:database/databases", "arn:aws:glue:us-east-1:111122223333:table/databases/tables", "arn:aws:glue:us-east-1:111122223333:catalog", "arn:aws:glue:us-east-1:111122223333:database/default" ] }, { "Effect": "Allow", "Action": [ "glue:CreateDatabase" ], "Resource": [ "arn:aws:glue:us-east-1:111122223333:database/default" ] }, { "Effect": "Allow", "Action": [ "s3:ListBucket", "s3:GetBucketLocation" ], "Resource": [ "arn:aws:s3:::bucket" ], "Condition": { "StringEquals": { "s3:ResourceAccount": [ "111122223333" ] } } }, { "Effect": "Allow", "Action": [ "s3:GetObject" ], "Resource": [ "arn:aws:s3:::bucketFolders/*" ], "Condition": { "StringEquals": { "s3:ResourceAccount": [ "111122223333" ] } } } ] }

    If you need to use a KMS key to decrypt data, add this AWS KMS statement to the previous template:

    { "Effect": "Allow", "Action": [ "kms:Decrypt", ], "Resource": [ "arn:aws:kms:region:accountId:key/keyId" ], "Condition": { "ArnLike": { "kms:EncryptionContext:aws:s3:arn": "arn:aws:s3:::bucketFolders*" } } } ] }
  5. Replace each placeholder with your own information:

    • region – The name of the AWS Region. For example, us-east-1.

    • accountId – The AWS account ID in which the S3 bucket is located.

    • database/databases, table/databases/tables, catalog, and database/default – The location of the training data that AWS Clean Rooms needs to access.

    • bucket – The Amazon Resource Name (ARN) of the S3 bucket. The Amazon Resource Name (ARN) can be found on the Properties tab of the bucket in Amazon S3.

    • bucketFolders – The name of specific folders in the S3 bucket that AWS Clean Rooms needs to access.

  6. Choose Next.

  7. For Review and create, enter a Policy name and Description, and review the Summary.

  8. Choose Create policy.

    You have created a policy for AWS Clean Rooms.

  9. Under Access management, choose Roles.

    With Roles, you can create short-term credentials, which is recommended for increased security. You can also choose Users to create long-term credentials.

  10. Choose Create role.

  11. In the Create role wizard, for Trusted entity type, choose Custom trust policy.

  12. Copy and paste the following custom trust policy into the JSON editor.

    JSON
    { "Version":"2012-10-17", "Statement": [ { "Sid": "AllowAssumeRole", "Effect": "Allow", "Principal": { "Service": "cleanrooms-ml.amazonaws.com" }, "Action": "sts:AssumeRole", "Condition": { "StringEqualsIfExists": { "aws:SourceAccount": ["111122223333"] }, "ArnLikeIfExists": { "aws:SourceArn": "arn:aws:cleanrooms-ml:us-east-1:111122223333:training-dataset/*" } } } ] }

    The SourceAccount is always your AWS account. The SourceArn can be limited to a specific training dataset, but only after that dataset is created. Because you don't yet know the training dataset ARN, the wildcard is specified here.

    accountId is the ID of AWS account that contains the training data.

  13. Choose Next and under Add permissions, enter the name of the policy you just created. (You might need to reload the page.)

  14. Select the check box next to the name of the policy you created, and then choose Next.

  15. For Name, review, and create, enter the Role name and Description.

    Note

    The Role name must match the pattern in the passRole permissions granted to the member who can query and receive results and member roles.

    1. Review Select trusted entities, and edit if necessary.

    2. Review the permissions in Add permissions, and edit if necessary.

    3. Review the Tags, and add tags if necessary.

    4. Choose Create role.

You have created the service role for AWS Clean Rooms.

Create a service role to write a lookalike segment

AWS Clean Rooms uses a service role to write lookalike segments to a bucket. You can create this role using the console if you have the necessary IAM permissions. If you don't have CreateRole permissions, ask your administrator to create the service role.

To create a service role to write a lookalike segment
  1. Sign in to the IAM console (https://console.aws.amazon.com/iam/) with your administrator account.

  2. Under Access management, choose Policies.

  3. Choose Create policy.

  4. In the Policy editor, select the JSON tab, and then copy and paste the following policy.

    Note

    The following example policy supports the permissions needed to read AWS Glue metadata and its corresponding Amazon S3 data. However, you might need to modify this policy depending on how you've set up your Amazon S3 data. This policy doesn't include a KMS key to decrypt data.

    Your AWS Glue resources and underlying Amazon S3 resources must be in the same AWS Region as the AWS Clean Rooms collaboration.

    JSON
    { "Version":"2012-10-17", "Statement": [ { "Effect": "Allow", "Action": [ "s3:ListBucket", "s3:GetBucketLocation" ], "Resource": [ "arn:aws:s3:::buckets" ], "Condition":{ "StringEquals":{ "s3:ResourceAccount":[ "accountId" ] } } }, { "Effect": "Allow", "Action": [ "s3:PutObject" ], "Resource": [ "arn:aws:s3:::bucketFolders/*" ], "Condition":{ "StringEquals":{ "s3:ResourceAccount":[ "accountId" ] } } } ] }

    If you need to use a KMS key to encrypt data, add this AWS KMS statement to the template:

    { "Effect": "Allow", "Action": [ "kms:Encrypt", "kms:GenerateDataKey*", "kms:ReEncrypt*", ], "Resource": [ "arn:aws:kms:region:accountId:key/keyId" ], "Condition": { "ArnLike": { "kms:EncryptionContext:aws:s3:arn": "arn:aws:s3:::bucketFolders*" } } } ] }
  5. Replace each placeholder with your own information:

    • buckets – The Amazon Resource Name (ARN) of the S3 bucket. The Amazon Resource Name (ARN) can be found on the Properties tab of the bucket in Amazon S3.

    • accountId – The AWS account ID in which the S3 bucket is located.

    • bucketFolders – The name of specific folders in the S3 bucket that AWS Clean Rooms needs to access.

    • region – The name of the AWS Region. For example, us-east-1.

    • keyId – The KMS key needed to encrypt your data.

  6. Choose Next.

  7. For Review and create, enter a Policy name and Description, and review the Summary.

  8. Choose Create policy.

    You have created a policy for AWS Clean Rooms.

  9. Under Access management, choose Roles.

    With Roles, you can create short-term credentials, which is recommended for increased security. You can also choose Users to create long-term credentials.

  10. Choose Create role.

  11. In the Create role wizard, for Trusted entity type, choose Custom trust policy.

  12. Copy and paste the following custom trust policy into the JSON editor.

    JSON
    { "Version":"2012-10-17", "Statement": [ { "Sid": "AllowAssumeRole", "Effect": "Allow", "Principal": { "Service": "cleanrooms-ml.amazonaws.com" }, "Action": "sts:AssumeRole", "Condition": { "StringEqualsIfExists": { "aws:SourceAccount": ["111122223333"] }, "ArnLikeIfExists": { "aws:SourceArn": "arn:aws:cleanrooms-ml:us-east-1:111122223333:configured-audience-model/*" } } } ] }

    The SourceAccount is always your AWS account. The SourceArn can be limited to a specific training dataset, but only after that dataset is created. Because you don't yet know the training dataset ARN, the wildcard is specified here.

  13. Choose Next.

  14. Select the check box next to the name of the policy you created, and then choose Next.

  15. For Name, review, and create, enter the Role name and Description.

    Note

    The Role name must match the pattern in the passRole permissions granted to the member who can query and receive results and member roles.

    1. Review Select trusted entities, and edit if necessary.

    2. Review the permissions in Add permissions, and edit if necessary.

    3. Review the Tags, and add tags if necessary.

    4. Choose Create role.

You have created the service role for AWS Clean Rooms.

Create a service role to read seed data

AWS Clean Rooms uses a service role to read seed data. You can create this role using the console if you have the necessary IAM permissions. If you don't have CreateRole permissions, ask your administrator to create the service role.

To create a service role to read seed data that is stored in an S3 bucket.
  1. Sign in to the IAM console (https://console.aws.amazon.com/iam/) with your administrator account.

  2. Under Access management, choose Policies.

  3. Choose Create policy.

  4. In the Policy editor, select the JSON tab, and then copy and paste one of the following policies.

    Note

    The following example policy supports the permissions needed to read AWS Glue metadata and its corresponding Amazon S3 data. However, you might need to modify this policy depending on how you've set up your Amazon S3 data. This policy doesn't include a KMS key to decrypt data.

    Your AWS Glue resources and underlying Amazon S3 resources must be in the same AWS Region as the AWS Clean Rooms collaboration.

    JSON
    { "Version":"2012-10-17", "Statement": [ { "Effect": "Allow", "Action": [ "s3:ListBucket" ], "Resource": [ "arn:aws:s3:::buckets" ], "Condition": { "StringEquals": { "s3:ResourceAccount": [ "accountId" ] } } }, { "Effect": "Allow", "Action": [ "s3:GetObject" ], "Resource": [ "arn:aws:s3:::bucketFolders/*" ], "Condition": { "StringEquals": { "s3:ResourceAccount": [ "accountId" ] } } } ] }
    Note

    The following example policy supports the permissions needed to read the results of an SQL query and use that as the input data. However, you might need to modify this policy depending on how your query is structured. This policy doesn't include a KMS key to decrypt data.

    JSON
    { "Version":"2012-10-17", "Statement": [ { "Sid": "AllowCleanRoomsStartQuery", "Effect": "Allow", "Action": [ "cleanrooms:GetCollaborationAnalysisTemplate", "cleanrooms:GetSchema", "cleanrooms:StartProtectedQuery" ], "Resource": "*" }, { "Sid": "AllowCleanRoomsGetAndUpdateQuery", "Effect": "Allow", "Action": [ "cleanrooms:GetProtectedQuery", "cleanrooms:UpdateProtectedQuery" ], "Resource": [ "arn:aws:cleanrooms:us-east-1:111122223333:membership/queryRunnerMembershipId" ] } ] }

    If you need to use a KMS key to decrypt data, add this AWS KMS statement to the template:

    { "Effect": "Allow", "Action": [ "kms:Decrypt", "kms:DescribeKey" ], "Resource": [ "arn:aws:kms:region:accountId:key/keyId" ], "Condition": { "ArnLike": { "kms:EncryptionContext:aws:s3:arn": "arn:aws:s3:::bucketFolders*" } } } ] }
  5. Replace each placeholder with your own information:

    • buckets – The Amazon Resource Name (ARN) of the S3 bucket. The Amazon Resource Name (ARN) can be found on the Properties tab of the bucket in Amazon S3.

    • accountId – The AWS account ID in which the S3 bucket is located.

    • bucketFolders – The name of specific folders in the S3 bucket that AWS Clean Rooms needs to access.

    • region – The name of the AWS Region. For example, us-east-1.

    • queryRunnerAccountId – The AWS account ID of the account that will run queries.

    • queryRunnerMembershipId – The Membership ID of the member who can query. The Membership ID can be found on the Details tab of the collaboration. This ensures that AWS Clean Rooms is assuming the role only when this member runs the analysis in this collaboration.

    • keyId – The KMS key needed to encrypt your data.

  6. Choose Next.

  7. For Review and create, enter a Policy name and Description, and review the Summary.

  8. Choose Create policy.

    You have created a policy for AWS Clean Rooms.

  9. Under Access management, choose Roles.