SageMaker notebook has no VPC subnet specified

Specify a subnet and security groups when a notebook needs access through the organization’s VPC.

Description

Set SubnetId so the SageMaker notebook can reach private resources in your VPC. SecurityGroupIds alone does not attach the notebook to a subnet.

Potential impact

Without that VPC connection, internal data sources may be unreachable and network isolation requirements may go unmet.

Remediation

Choose a subnet and security groups from the same VPC and verify the route to your data source. To send notebook traffic only through the VPC, set DirectInternetAccess to Disabled.

Examples

The first example cannot deploy because DirectInternetAccess: Disabled requires a subnet. The second supplies PrivateSubnet1. Changing an existing notebook’s subnet replaces it. Back up its files and give the replacement a distinct name.

Before

yaml
Resources:
  NotebookInstance:
    Type: AWS::SageMaker::NotebookInstance
    Properties:
      NotebookInstanceName: !Ref NotebookInstanceName
      InstanceType: !Ref NotebookInstanceType
      RoleArn: !GetAtt ExecutionRole.Arn
      SecurityGroupIds:
        - !GetAtt VpcSecurityGroup.GroupId
      DirectInternetAccess: Disabled

After

yaml
Resources:
  NotebookInstance:
    Type: AWS::SageMaker::NotebookInstance
    Properties:
      NotebookInstanceName: !Ref NotebookInstanceName
      InstanceType: !Ref NotebookInstanceType
      RoleArn: !GetAtt ExecutionRole.Arn
      SecurityGroupIds:
        - !GetAtt VpcSecurityGroup.GroupId
      SubnetId: !Ref PrivateSubnet1
      DirectInternetAccess: Disabled

References