Multiple clients
Sam knows that she will often have to work with more than one service at once. She wants to practice creating two separate clients for two different services in boto3.
When she is building her workflows, she will make multiple Amazon Web Services interact with each other, with a script executed on her computer.
Her AWS key id and AWS secret have been stored in AWS_KEY_ID and AWS_SECRET respectively.
You will help Sam initialize a boto3 client for S3, and another client for SNS.
She will use the S3 client to list the buckets in S3. She will use the SNS client to list topics she can publish to (you will learn about SNS topics in Chapter 3).
Este ejercicio forma parte del curso
Introduction to AWS Boto in Python
Instrucciones del ejercicio
- Generate the
boto3clients for interacting with S3 and SNS. - Specify
'us-east-1'for the region_name for both clients. - Use
AWS_KEY_IDandAWS_SECRETto set up the credentials. - List and print the SNS topics.
Ejercicio interactivo práctico
Prueba este ejercicio y completa el código de muestra.
# Generate the boto3 client for interacting with S3 and SNS
s3 = boto3.____('____', region_name=____,
aws_access_key_id=____,
____=____)
sns = boto3.____('____', region_name=____,
aws_access_key_id=____,
____=____)
# List S3 buckets and SNS topics
buckets = s3.list_buckets()
topics = sns.list_topics()
# Print out the list of SNS topics
print(topics)