If I use aws configure to configure the details, do I still need to pass the region explicitly?
I am using Boto3 resource to send push notification to iOS devices.
It is working fine but issue is that I am not able to show badge count on the iOS App and also not able to pass any value for sound effect for new notifications.
My code below:
sns = boto3.resource( 'sns', region_name='AWS_REGION_NAME', aws_access_key_id='AWS_ACCESS_KEY', aws_secret_access_key='AWS_SECRET_ACCESS_KEY' ) user_endpoint_arn = 'DEVICE_ENDPOINT_ARN' platform_endpoint = sns.PlatformEndpoint(endpoint_arn) platform_endpoint.publish(Message='notification message')
What should be added here to have sound effect for new notifications and also for badge count (count for unread notifications) on the installed APP icon?
A related option, when in ec2, assuming you want to connect to whatever region the ec2 instance is running in (thus the region isn't hard coded):
import json import boto3 import urllib2 durl = "http://169.254.169.254/latest/dynamic/instance-identity/document" document = json.loads(urllib2.urlopen(durl).read()) client = boto3.client('cloudwatch', region_name=document['region'])
Thank you Russell. didn't know lambda could be executed in all regions by configuring regions. gonna help me reduce the time to spend on making lambda function in every region!!
Hi, when I use:
>>> import boto3 >>> rds = boto3.setup_default_session(region_name='us-west-2') >>> rds = boto3.client('rds')
It raises:
NoCredentialsError botocore.exceptions.NoCredentialsError: Unable to locate credentials
What should I do?
Hi, this error message means boto3
didn't find API credentials. To fix this you need to either setup:
-
A profile in your aws config file (typically located in
~/.aws/config
) -
Environment vars:
AWS_ACCESS_KEY_ID
andAWS_SECRET_ACCESS_KEY
Check out my quickstart for the botoform project here for more details.
Hi all Cool and helpful article. Now I'm trying to dive a little deeper The task is how to use region_name as list of defined regions. For example, find all instances across AWS with specific tag.
You might be able to steal some code from a tool I wrote called atmosphere.
It loops over all AWS profiles, over all regions for each profile, and does some look ups.