Code Ocean VPC Administration Guide
v2.13
v2.13
  • Code Ocean VPC Administration Guide
  • Overview
    • System Overview
    • System Capacity and Sizing
  • Installation Guide
    • Prerequisites
    • CloudFormation Deployment
    • Deployment Parameters
    • Deployment IAM role
    • Subdomain Delegation
    • Create an Admin Account
    • Upgrade Code Ocean
    • Remove Code Ocean
  • Management Guide
    • User Management
      • Admin Signup
      • Adding/Removing an Administrator
      • Inviting New Users
      • Generating a Reset Password Link
      • Extend User Ownership
      • Deactivate User
    • Set up a User Banner Message
    • Enable Git Integration
    • Starter Environments
      • Deploy Base Image
      • Image Actions
      • Deploying Private Docker Base Images
    • Authentication
    • SCIM Provisioning using Azure Active Directory
    • SCIM Provisioning using Okta
    • Configure Worker Parameters
    • ACM Certificate Renewal
    • Deleting Released Capsules
    • Assumable Roles
  • Troubleshooting Guide
    • Collecting Logs with the Support Bundle
    • Searching Logs in AWS CloudWatch
    • Alarms
Powered by GitBook
On this page
  • Overview
  • Configuration
  • Part 1 - AWS
  • Part 2 - Identity Provider
  • Conclusion

Was this helpful?

  1. Management Guide

Assumable Roles

Learn how to configure AWS Assumable roles in CodeOcean

PreviousDeleting Released CapsulesNextTroubleshooting Guide

Last updated 1 year ago

Was this helpful?

Overview

IAM roles in AWS enable administrators to control user and group access to AWS resources, such as external datasets stored in Amazon S3 buckets without the need to share sensitive secrets, such as access keys or passwords.

By leveraging assumable roles, administrators can define fine-grained access permissions, enforce security best practices, and maintain control over data access. This approach enhances security, reduces the risk of unauthorized access, and promotes a least privilege access model for accessing S3 data within Code Ocean.

Configuration

Part 1 - AWS

IAM

  • Create a new IAM role of type "Custom Trust Policy" - .

{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Effect": "Allow",
            "Principal": {
                "AWS": "arn:aws:iam::<aws_account_id>:root",
                "Service": "ecs-tasks.amazonaws.com"
            },
            "Action": "sts:AssumeRole",
            "Condition": {}
        }
    ]
}
  • Create and attach an ECS AssumeRole policy:

{
    "Version": "2012-10-17",
    "Statement": [
        {
          "Action": [
            "iam:PassRole"
          ],
          "Effect": "Allow",
          "Resource": "*",
          "Condition": {
            "StringLike": {
              "iam:PassedToService": [
                "ecs-tasks.amazonaws.com"
              ]
            }
          }
        }
    ]
}
{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Effect": "Allow",
            "Action": [
                "s3:GetObject",
                "s3:ListBucket",
                "s3:PutObject",
                "s3:DeleteObject"
            ],
            "Resource": [
                "arn:aws:s3:::<bucket_name>",
                "arn:aws:s3:::<bucket_name>/*"
            ]
        }
    ]
}
{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Effect": "Allow",
            "Action": [
                "s3:GetObject",
                "s3:ListBucket",
            ],
            "Resource": [
                "arn:aws:s3:::<bucket_name>",
                "arn:aws:s3:::<bucket_name>/*"
            ]
        }
    ]
}
  • Attach Code Ocean's batch job policy [CodeOcean-Stack-Name]-BatchJobPolicy-*******. Code Ocean's batch job policy is used to grant the necessary permissions to run pipelines in Code Ocean

CloudFormation

  • Go to Code Ocean deployment stack under "CloudFormation" console, Click on "Update".

  • Use current template for the update of the stack, Click "Next".

  • In the "IAM Configuration" Parameter section -> "Assumable IAM roles" parameter, enter the IAM role ARN that you want to let CodeOcean the ability to assume. If you want to insert more then one role, use commas to delimit between them.

You can pre configure the roles during stack update even if the roles do not yet exist.

Part 2 - Identity Provider

  • Add Custom attributes to your User/Group profile:

    • Role (string).

    • SessionDuration (int - seconds).

  • Assign an IAM role to a User/Group by filling the Role and SessionDuration attributes in their profile.

  • Add the Role, SessionDuration and Primary email attributes to the SAML attribute mapping:

Example - Google Workspace:

  1. Open the Admin console.

  2. Go to "Directory" -> Users and press on "More Options" -> "Configure custom attributes".

  3. Add the attributes:

  4. Go to a User profile -> "User Information" -> Add the Role and SessionDuration attributes under the AWS tab:

  5. Go to your CodeOcean custom SAML app under "Web and Mobile Apps" -> Edit the "SAML Attribute Mapping" section:

Conclusion

By following the outlined steps, you can enhance the security and control of accessing AWS resources within Code Ocean. IAM roles provide administrators with fine-grained access permissions, allowing users to interact with external datasets stored in Amazon S3 buckets without compromising sensitive credentials. Leveraging assumable roles, you can enforce security best practices and maintain control over data access.

Create and attach A policy that grants access to S3 (Read/Write) -

Create a custom SAML app for CodeOcean and configure CodeOCean's authentication method to SAML SSO -

Role ->

SessionDuration ->

Primary email ->

AWS guide
AWS guide
https://aws.amazon.com/SAML/Attributes/Role
https://aws.amazon.com/SAML/Attributes/SessionDuration
https://aws.amazon.com/SAML/Attributes/RoleSessionName
How To