Let's operate AWS of another account with Lambda boto3
Posted in aws, blog on November 4, 2020 by Henk Verlinde ‐ 1 min read

Introduction
Describes how to easily operate other AWS environments with Lambda boto3
Get referrer access key ID and secret access key
Follow the steps below
- Go to AWS service [IAM]
- User Press
- [AdministratorAccess] Select the user to which the policy is attached
- Press the Credentials tab
- Create access key
- Make a note of the Access Key ID and Secret Access Key
create dynamoDB with referrer
create table. Name it [sample_tbl].
Create a Lambda function in the referenced account
code below
import boto3
def get_external_dynamodb():
client = boto3.client('dynamodb',
aws_access_key_id=[access key id],
aws_secret_access_key=[secret access key] ,
region_name=[region code]
)
return client
def lambda_handler(event, context):
external_dynamodb = get_external_dynamodb()
external_table = external_dynamodb.scan(TableName = "sample_tbl")
return external_table
that’s all