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"],
    ...
)
gefragt vor einem Monat121 Aufrufe
1 Antwort
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
EXPERTE
beantwortet vor einem Monat

Du bist nicht angemeldet. Anmelden um eine Antwort zu veröffentlichen.

Eine gute Antwort beantwortet die Frage klar, gibt konstruktives Feedback und fördert die berufliche Weiterentwicklung des Fragenstellers.

Richtlinien für die Beantwortung von Fragen