how to instantiate aws resources within sagemaker environment?

0

I am setting up a sagemaker processing job in sagemaker, as a part of sagemaker pipeline (see sample below)

in my script file , i instantiate a dynamo db client from boto3 library but before that i instantiate a session via boto3.Session(profile_name='myprofile') . within sagemaker , do we need to provide a profile name , or does boto3 creates a default profile , as it is already running within aws sagemaker environment? if yes, do i just import boto3 or do i need any other sagemaker libraries.

if no, how do i create a profile within aws sagemaker?

main.py

import boto3


session = boto3.Session(profile_name='profile')

dynamodb = session.client('dynamodb', ..)

my_processor = ScriptProcessor(
    command=['python3'],
    ...
)

my_step = ProcessingStep(
    "MyPreprocessStep",
    code=main.py,
    inputs=[...],
    arguments=["--flag"],
    ...
)
asked 22 days ago111 views
1 Answer
0

The session is created for you by default. But you don't need to initiate a session explicitly, just create the client and its done for you:

import boto3

client = boto3.client('dynamodb')
profile pictureAWS
EXPERT
answered 22 days ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions