Using an AWS Access Key and Secret Key
You can access AWS resources in Modelbit by storing your AWS Access Key ID and AWS Secret Access Key as Modelbit Secrets.
Create a key pair and store them as Modelbit secrets.
Begin by creating a keypair for Modelbit. Then, go to Settings in Modelbit and click the Integrations tab. Add both your AWS Access Key ID and AWS Secret Access Key here as secrets.
Example reading data from AWS S3
Using the boto3
package and clients from within a deployment is the same as anywhere else.
import boto3, os
import modelbit as mb
os.environ["AWS_ACCESS_KEY_ID"] = mb.get_secret("AWS_ACCESS_KEY_ID")
os.environ["AWS_SECRET_ACCESS_KEY"] = mb.get_secret("AWS_SECRET_ACCESS_KEY")
def predict_with_s3_data():
client = boto3.client("s3")
obj = client.get_object(Bucket='<YOUR BUCKET>', Key='path/to/your/file')
return f"The S3 file contents are: {obj['Body'].read().decode()}"}