Boto sts


Python3 - Boto3

import boto3
some_binary_data = b'Here we have some data'
more_binary_data = b'Here we have some more data'
bucket_name = "ring-dm-integration-stark"

def lambda_handler(a, b):
  boto_sts=boto3.client('sts')
  response = boto_sts.assume_role(
    RoleArn="arn:aws:iam::XXXXXX:role/role",
    RoleSessionName='role'
  )["Credentials"]
  client = boto3.client('s3',
   region_name='us-east-1',
   aws_access_key_id=response["AccessKeyId"],
   aws_secret_access_key=response["SecretAccessKey"],
   aws_session_token=response["SessionToken"]
  )
  client.put_object(Body=more_binary_data, Bucket=bucket_name, Key='my/key/including/anotherfilename.txt')

Go

https://github.com/cn007b/my/blob/97fa665c2a9151c2b0b47ab1edab59d60ffe67e6/ed/l/go/examples/aws/src/app/sts/a.go#L11