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"],
    ...
)
posta un mese fa121 visualizzazioni
1 Risposta
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
ESPERTO
con risposta un mese fa

Accesso non effettuato. Accedi per postare una risposta.

Una buona risposta soddisfa chiaramente la domanda, fornisce un feedback costruttivo e incoraggia la crescita professionale del richiedente.

Linee guida per rispondere alle domande