Setup in your AWS account

Setting up permissions in your AWS account to link credentials to NetBook

Here is a guide on how to connect your credentials to NetBook.

We wish to simplify the process so that you would need minimal intervention from your IT teams.

We need you to create policy for NetBook to use.

Creating IAM policy for NetBook

Resources that NetBook uses in your account

  1. EC2 Instances

    1. This is to spin up instances for your workspaces and experiments

  2. EKS ( Amazon Kubernetes clusters)

    1. This is to enable Kubernetes setup for workspaces and enabling distributed GPU trainings

  3. EC2 Network-Stack

    1. Managing access to clusters and nodes and securing the instances from public access

  4. Cost and Usage

    1. To get cost estimate. (Note: Please enable Hourly data on Cost Explorer setting page ).

Please check in your AWS console if you have access to these resources. If you do, you can directly skip to generating Access key , secret, and adding them to the NetBook portal.

Most organizations don't give users access to create policies. In this case, there are some steps the IT team or IAM admin needs to set up in your AWS account for you to connect your credentials with NetBook.

How to add policies to AWS through the AWS console

  • Navigate to policies on the left side panel. You will find existing policies here

  • Click on create policy on the right. You will find two options for visual editor and JSON.

  • Select JSON and copy the policy JSON and give it a name

Policy JSON

{
    "Version": "2012-10-17",
    "Statement": [
        { 
            "Sid": "AllowEKSDeleteCluster",
            "Effect": "Allow",
            "Action": [
                "eks:DeleteCluster",
                "eks:DeregisterCluster"
            ],
            "Resource": "*",
            "Condition": {
                "ForAnyValue:StringEquals": {
                    "aws:ResourceTag/scope": "nb-prod",
                    "aws:PrincipalTag/scope": "nb-prod"
                }
            }
        },
        { 
            "Sid": "AllowEKSDeleteNodegroup",
            "Effect": "Allow",
            "Action": "eks:DeleteNodegroup",
            "Resource": [
                "arn:aws:eks:*:<acc-id>:nodegroup/*/*/*",
                "arn:aws:eks:*:<acc-id>:cluster/*"
            ],
            "Condition": {
                "ForAnyValue:StringEquals": {
                    "aws:ResourceTag/scope": "nb-prod",
                    "aws:PrincipalTag/scope": "nb-prod"
                }
            }
        },
        {
            "Sid": "AllowEKSCreateNodegroup",
            "Effect": "Allow",
            "Action": "eks:CreateNodegroup",
            "Resource": "arn:aws:eks:*:<acc-id>:cluster/*",
            "Condition": {
                "ForAnyValue:StringEquals": {
                    "aws:TagKeys": "scope",
                    "aws:RequestTag/scope": "nb-prod"
                }
            }
        },
        {
            "Sid": "AllowEKSCreateCluster",
            "Effect": "Allow",
            "Action": "eks:CreateCluster",
            "Resource": "*",
            "Condition": {
                "ForAnyValue:StringEquals": {
                    "aws:TagKeys": "scope",
                    "aws:RequestTag/scope": "nb-prod"
                }
            }
        },
        {
            "Sid": "AllowListCluster",
            "Effect": "Allow",
            "Action": "eks:ListClusters",
            "Resource": "*",
            "Condition": {
                "ForAnyValue:StringEquals": {
                    "aws:PrincipalTag/scope": "nb-prod"
                }
            }
        },
        {
            "Sid": "AllowDescribeCluster",
            "Effect": "Allow",
            "Action": [
                "eks:DescribeNodegroup",
                "eks:ListNodegroups",
                "eks:DescribeCluster"
            ],
            "Resource": "*",
            "Condition": {
                "ForAnyValue:StringEquals": {
                    "aws:ResourceTag/scope": "nb-prod"
                }
            }
        },
        {
            "Sid": "AllowEKSTagResource",
            "Effect": "Allow",
            "Action": "eks:TagResource",
            "Resource": [
                "arn:aws:eks:*:<acc-id>:identityproviderconfig/*/*/*/*",
                "arn:aws:eks:*:<acc-id>:fargateprofile/*/*/*",
                "arn:aws:eks:*:<acc-id>:nodegroup/*/*/*",
                "arn:aws:eks:*:<acc-id>:addon/*/*/*",
                "arn:aws:eks:*:<acc-id>:cluster/*"
            ]
        },
        {
            "Sid": "AllowEKSAssumeRole",
            "Effect": "Allow",
            "Action": [
                "iam:GetRole",
                "iam:PassRole",
                "iam:ListAttachedRolePolicies",
                "iam:AttachRolePolicy"
            ],
            "Resource": [
                "arn:aws:iam::<acc-id>:role/aws-service-role/eks-nodegroup.amazonaws.com/AWSServiceRoleForAmazonEKSNodegroup",
                "arn:aws:iam::<acc-id>:role/aws-service-role/eks.amazonaws.com/AWSServiceRoleForAmazonEKS",
                "arn:aws:iam::<acc-id>:role/netbook-AWS-ServiceRoleForEKS-BADBEEF",
                "arn:aws:iam::<acc-id>:role/netbook-AWS-NodeGroupInstanceRole-CAFE"
            ]
        },
        {
            "Sid": "AllowEC2CreateVolume",
            "Effect": "Allow",
            "Action": [
                "ec2:CreateVolume"
            ],
            "Resource": "arn:aws:ec2:*:<acc-id>:volume/*",
            "Condition": {
                "ForAnyValue:StringEquals": {
                    "aws:TagKeys": "scope",
                    "aws:RequestTag/scope": "nb-prod"
                }
            }
        },
        {
            "Sid": "AllowEC2DeleteVolumeAndSnapshots",
            "Effect": "Allow",
            "Action": [
                "ec2:DeleteVolume",
                "ec2:DeleteSnapshot"
            ],
            "Resource": [
                "arn:aws:ec2:*:<acc-id>:instance/*",
                "arn:aws:ec2:*:<acc-id>:volume/*",
                "arn:aws:ec2:*::snapshot/*"
            ],
            "Condition": {
                "ForAnyValue:StringEquals": {
                    "aws:ResourceTag/scope": "nb-prod"
                }
            }
        },
        {
            "Sid": "AllowEC2CreateSnapshot",
            "Effect": "Allow",
            "Action": [
                "ec2:CreateSnapshots",
                "ec2:CreateSnapshot"
            ],
            "Resource": [
                "arn:aws:ec2:*:<acc-id>:instance/*",
                "arn:aws:ec2:*:<acc-id>:volume/*",
                "arn:aws:ec2:*::snapshot/*"
            ]
        },
        {
            "Sid": "AllowEC2DescribeActions",
            "Effect": "Allow",
            "Action": [
                "ec2:DescribeInternetGateways",
                "ec2:DescribeInstances",
                "ec2:DescribeVolumeStatus",
                "ec2:DescribeInstanceTypeOfferings",
                "ec2:DescribeSnapshotAttribute",
                "ec2:DescribeVolumes",
                "ec2:DescribeInstanceTypes",
                "ec2:DescribeInstanceEventWindows",
                "ec2:DescribeInstanceEventNotificationAttributes",
                "ec2:DescribeSnapshots",
                "ec2:DescribeVolumeAttribute",
                "ec2:DescribeInstanceStatus",
                "ec2:DescribeNetworkInterfaces",
                "ec2:DescribeTags",
                "ec2:DescribeVpcPeeringConnections",
                "ec2:DescribeDhcpOptions",
                "ec2:DescribeAccountAttributes",
                "ec2:DescribeNatGateways",
                "ec2:DescribeAvailabilityZones",
                "ec2:DescribeVpcEndpoints",
                "ec2:DescribeNetworkAcls",
                "ec2:DescribeVpnGateways",
                "ec2:DescribeSecurityGroups",
                "ec2:GetSubnetCidrReservations",
                "ec2:DescribeSubnets",
                "ec2:DescribeRouteTables",
                "ec2:DescribeEgressOnlyInternetGateways"
            ],
            "Resource": "*"
        },
        {
            "Sid": "AllowEC2AssociateDisassociateSubnet",
            "Effect": "Allow",
            "Action": [
                "ec2:AssociateSubnetCidrBlock",
                "ec2:DisassociateSubnetCidrBlock"
            ],
            "Resource": "arn:aws:ec2:*:<acc-id>:subnet/*"
        },
        {
            "Sid": "AllowEC2DescribeVPCs",
            "Effect": "Allow",
            "Action": "ec2:DescribeVpcs",
            "Resource": "*",
            "Condition": {
                "ForAnyValue:StringEquals": {
                    "aws:PrincipalTag/scope": "nb-prod"
                }
            }
        },
        {
            "Sid": "AllowEC2CreateTagsRouteRoutetableSubnet",
            "Effect": "Allow",
            "Action": [
                "ec2:CreateRouteTable",
                "ec2:CreateRoute",
                "ec2:CreateSubnet",
                "ec2:CreateTags"
            ],
            "Resource": "*",
            "Condition": {
                "ForAnyValue:StringEquals": {
                    "aws:PrincipalTag/scope": "nb-prod"
                }
            }
        },
        { 
            "Sid": "AllowEC2AttachAndDetachInternetGateway",
            "Effect": "Allow",
            "Action": [
                "ec2:AttachInternetGateway",
                "ec2:DetachInternetGateway",
                "ec2:AssociateRouteTable",
                "ec2:ModifySubnetAttribute"
            ],
            "Resource": [
                "arn:aws:ec2:*:<acc-id>:vpc/*",
                "arn:aws:ec2:*:<acc-id>:prefix-list/*",
                "arn:aws:ec2:*:<acc-id>:internet-gateway/*",
                "arn:aws:ec2:*:<acc-id>:subnet/*",
                "arn:aws:ec2:*:<acc-id>:vpn-gateway/*",
                "arn:aws:ec2:*:<acc-id>:route-table/*"
            ],
            "Condition": {
                "ForAnyValue:StringEquals": {
                    "aws:PrincipalTag/scope": "nb-prod"
                }
            }
        },
        { 
            "Sid": "AllowEC2DeleteNetworkStack",
            "Effect": "Allow",
            "Action": [
                "ec2:DeleteSubnet",
                "ec2:DeleteRoute",
                "ec2:DeleteRouteTable",
                "ec2:DeleteInternetGateway",
                "ec2:DeleteVpc"
            ],
            "Resource": [
                "arn:aws:ec2:*:<acc-id>:vpc/*",
                "arn:aws:ec2:*:<acc-id>:prefix-list/*",
                "arn:aws:ec2:*:<acc-id>:internet-gateway/*",
                "arn:aws:ec2:*:<acc-id>:subnet/*",
                "arn:aws:ec2:*:<acc-id>:vpn-gateway/*",
                "arn:aws:ec2:*:<acc-id>:route-table/*"
            ],
            "Condition": {
                "ForAnyValue:StringEquals": {
                    "aws:ResourceTag/scope": "nb-prod"
                }
            }
        },
        {
            "Sid": "AllowCreateVPCAnaInternetGateway",
            "Effect": "Allow",
            "Action": [
                "ec2:CreateInternetGateway",
                "ec2:CreateVpc"
            ],
            "Resource": "*",
            "Condition": {
                "ForAnyValue:StringEquals": {
                    "aws:RequestTag/scope": "nb-prod",
                    "aws:TagKeys": "scope"
                }
            }
        },
        {
            "Sid": "AllowGetCostAndUsage",
            "Effect": "Allow",
            "Action": "ce:GetCostAndUsage",
            "Resource": "*"
        }
        
    ]
}

Please notice:

            "Condition": { // For creating resource
                "ForAnyValue:StringEquals": {
                    "aws:RequestTag/scope": "nb-prod",
                    "aws:TagKeys": "scope"
                }
            },
            "Condition": { // For deleting resource
                "ForAnyValue:StringEquals": {
                    "aws:ResourceTag/scope": "nb-prod"
                }
            }

Note: NetBook creates every resource with a tag nb-prod to make sure we don't access any other resources of your account other than the ones NetBook created. We make sure that NetBook gets limited access to your cloud.

Note : Please replace <acc_id> with your Account ID.

Additional Roles

For creating Role "arn:aws:iam::<acc_id>:role/AWSServiceRoleForAmazonEKS":

  • Go to IAM -> Roles -> Create Roles

  • Select EKS in Use cases for other AWS services: then select EKS

  • Then Proceed with Default permissions and name this role as AWSServiceRoleForAmazonEKS

For creating Role "arn:aws:iam::<acc_id>:role/AWSServiceRoleForAmazonEKSNodegroup":

  • Go to IAM -> Roles -> Create Roles

  • Select EKS in Use cases for other AWS services: then select EKS Nodegroup

  • Then proceed with Default permissions and proceed with the default name, as this won’t be editable “AWSServiceRoleForAmazonEKSNodegroup

For creating role "arn:aws:iam::<acc_id>:role/netbook-AWS-NodeGroupInstanceRole-CAFE"

  • Go to IAM -> Roles -> Create Roles

  • Select Custom trust policy and paste the following JSON:

{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Effect": "Allow",
            "Principal": {
                "Service": "ec2.amazonaws.com"
            },
            "Action": "sts:AssumeRole"
        }
    ]
}

For creating role "arn:aws:iam::<acc_id>:role/netbook-AWS-ServiceRoleForEKS-BADBEEF"

  • Go to IAM -> Roles -> Create Roles

  • Select Custom trust policy and paste the following JSON:

{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Effect": "Allow",
            "Principal": {
                "Service": "eks.amazonaws.com"
            },
            "Action": "sts:AssumeRole"
        }
    ]
}

Adding policies to the User

  • You will find a list of all available policies including AWS default policies. Search for the policies that you created earlier and assign them to the user

  • Next add tag with Key : scope and Value : nb-prod

Generating User Access key Id and Access key secret to provide NetBook

  • Select the Security credentials tab in the user information

  • You can download the Access Key and Secret as a CSV from the platform.

  • NOTE: You will find a warning not to share your access keys and secrets to public platforms. NetBook handles the access key security through a secured vault.

Now you are done with creating the needed keys for the NetBook platform. These are the steps you need your IT team's help to setup Credentials. Now let us move to how to connect them to NetBook's platform

Last updated