How to access an IP whitelist secured API from within a Sagemaker notebook?

Viewed 50

I have deployed a Flask application and its containers in an AWS EKS managed Kubernetes cluster, and the cluster's security group is IP whitelist secured.

I created the cluster using eksctl, created an RDS instance for it, and deployed the application using it's helm chart.

I am trying to access the APIs of the flask application from within a AWS Sagemaker Notebook instance, but because of the IP whitelist, I am unable to connect. The connection times-out instead.

Can anyone tell me how I can add the Notebook instance to my whitelist?

1 Answers

Since the API is IP whitelist secured, you will need to add the public IP of your Sagemaker instance to the whitelist in order to connect to the API from the notebook.

  1. Open a Sagemaker notebook instance, and run the following command in a cell.

    !curl ifconfig.me

    This will return an IP address such as 13.232.97.17.

  2. Go to your cluster's security group from EC2 console page. It will have a name such as eks-cluster-sg-cluserName-uniqueID.

  3. Edit the security group's inbound rules, and add a new entry for the sagemaker notebook instance.

       Type          Protocol
       Custom TCP    TCP    <port_number>    Custom    13.232.97.17/32
    

    and add an appropriate description.

Now, you should be able to access the API via the notebook.

Related