hide preview

What's next? verify your email address for reply notifications!

unverified 9y, 94d ago [edited]

Thanks!

hide preview

What's next? verify your email address for reply notifications!

unverified 9y, 59d ago [edited]

Thanks a lot buddy for this basic yet important lesson.

Python 3 picks up the IAM role and other stuff on its own, however I faced challenges with Python 2.

hide preview

What's next? verify your email address for reply notifications!

unverified 9y, 46d ago [edited]

Great Information ! This is what I was looking for !! Thank you !

hide preview

What's next? verify your email address for reply notifications!

TXO6AksL 9y, 40d ago [edited]

Awesome !! Exactly the info that was needed !

hide preview

What's next? verify your email address for reply notifications!

unverified 9y, 12d ago [edited]

If I use aws configure to configure the details, do I still need to pass the region explicitly?

remark link
hide preview

What's next? verify your email address for reply notifications!

russell 9y, 12d ago

You can set a default region in the aws config (.aws/config) for your profile.

Then instead of passing a region, you can pass a profile name.

Here is a class I wrote to manage boto connections:

In it you can see how I get the default region from the profile.

hide preview

What's next? verify your email address for reply notifications!

unverified 8y, 362d ago [edited]

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?

remark link
hide preview

What's next? verify your email address for reply notifications!

russell 8y, 362d ago

Sorry I don't use this part of the API so I can't help. Hopefully somebody else can chime in.

Otherwise, I would ask AWS support or the Boto3 github issue tracker.

hide preview

What's next? verify your email address for reply notifications!

unverified 8y, 326d ago [edited]

Thanks, It helped me to set my 'ses' region to eu-west-1 since aws has no ses in ap-southeast

remark link
hide preview

What's next? verify your email address for reply notifications!

russell 8y, 326d ago

Your welcome! Great use case.

hide preview

What's next? verify your email address for reply notifications!

unverified 8y, 262d ago [edited]

Thank u so much!

remark link
hide preview

What's next? verify your email address for reply notifications!

russell 8y, 262d ago

You are welcome!

hide preview

What's next? verify your email address for reply notifications!

unverified 8y, 244d ago [edited]

totally helped me out today! I looked at boto docs first and couldn't figure it out

remark link
hide preview

What's next? verify your email address for reply notifications!

russell 8y, 244d ago

You are very welcome!

hide preview

What's next? verify your email address for reply notifications!

unverified 8y, 235d ago [edited]

Thanks dude! Was wondering why the AWS_REGION env variable wasn't being honored and couldn't use a boto config.

remark link
hide preview

What's next? verify your email address for reply notifications!

russell 8y, 235d ago

Cool, yeah, I stopped using ENV vars and either use flags or I use the ~/.aws/config with profiles.

hide preview

What's next? verify your email address for reply notifications!

unverified 8y, 223d ago [edited]

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'])
hide preview

What's next? verify your email address for reply notifications!

unverified 8y, 201d ago [edited]

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!!

remark link
hide preview

What's next? verify your email address for reply notifications!

russell 8y, 201d ago

Yeah, makes perfect sense if you want to maintain the same lambda script in multiple regions, iterate over all regions and upload latest.

hide preview

What's next? verify your email address for reply notifications!

unverified 8y, 167d ago

How to pass aws_access_key_id,aws_secret_access_key,region in client I am working on elb please help

hide preview

What's next? verify your email address for reply notifications!

unverified 8y, 131d ago

I had to search the whole internet to find such a simple answer that how can i pass the aws credential on boto3 resource. Saved my day man!!!

hide preview

What's next? verify your email address for reply notifications!

unverified 7y, 340d ago [edited]

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?

remark link
hide preview

What's next? verify your email address for reply notifications!

russell 7y, 340d ago [edited]

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 and AWS_SECRET_ACCESS_KEY

Check out my quickstart for the botoform project here for more details.

hide preview

What's next? verify your email address for reply notifications!

unverified 7y, 337d ago

Thank you so much. It helps me.

hide preview

What's next? verify your email address for reply notifications!

jmbW8tGZ 7y, 322d ago [edited]

Thanks for this post. I did not know that Lambda function in US region can access resource in Asia region like this...

session = Session(aws_access_key_id='xxx', aws_secret_access_key='x+xx/xx')
ec2 = session.resource('ec2', region_name='ap-south-1')
hide preview

What's next? verify your email address for reply notifications!

unverified 7y, 244d ago

Thank you :)

hide preview

What's next? verify your email address for reply notifications!

unverified 7y, 191d ago

Thanks, this was great!

hide preview

What's next? verify your email address for reply notifications!

unverified 7y, 102d ago

Thank you for sharing. Nicely presented. This Saved me.

hide preview

What's next? verify your email address for reply notifications!

unverified 6y, 310d ago

Thanks Russell.

hide preview

What's next? verify your email address for reply notifications!

unverified 6y, 159d ago

Very helpful!! :D

hide preview

What's next? verify your email address for reply notifications!

unverified 6y, 64d ago

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.

remark link
hide preview

What's next? verify your email address for reply notifications!

russell 6y, 64d ago [edited]

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.

hide preview

What's next? verify your email address for reply notifications!

unverified 6y, 54d ago

Thanks, it helped.

hide preview

What's next? verify your email address for reply notifications!

Bw9c3zPj 6y, 48d ago

Hi, I would like to pass region input as variable interactively. Like how python get it as raw_input() So, how do I do that in boto3

remark link
hide preview

What's next? verify your email address for reply notifications!

russell 6y, 48d ago

I prefer to use flags than interactive prompts. That said, this totally works:

>>> import boto3
>>> region_name = raw_input("region: ")
region: us-west-2
>>> rds = boto3.client('rds', region_name=region_name)
remark link parent
hide preview

What's next? verify your email address for reply notifications!

Bw9c3zPj 6y, 47d ago

Thanks Russell..!!

hide preview

What's next? verify your email address for reply notifications!

unverified 6y, 21d ago

Hey Buddy, you made my 1 week work resolved. Thanks. AWS document keeps you busy reading, till you die or finish their document.

remark link
hide preview

What's next? verify your email address for reply notifications!

russell 6y, 21d ago

Welcome.

hide preview

What's next? verify your email address for reply notifications!

unverified 6y, 14d ago

Thanks!

remark link
hide preview

What's next? verify your email address for reply notifications!

russell 6y, 14d ago

Welcome!

hide preview

What's next? verify your email address for reply notifications!

unverified 5y, 255d ago

thanks!

hide preview

What's next? verify your email address for reply notifications!

aduYzOf7 5y, 171d ago

Very nice thanks!! can anyone chime in how to do this on a one liner instead of 2 lines? boto3.setup_default_session(profile_name='account1') boto3.setup_default_session(region_name='eu-west-2')

hide preview

What's next? verify your email address for reply notifications!

unverified 5y, 58d ago

hi...i am trying to access a lambda function which is in eu-west-1 using api gateway.the api gateway , i dont know how created in us-east-1...how should i solve this?I cannot able to create api in the same region as lambda fn

hide preview

What's next? verify your email address for reply notifications!

mSwornyB 4y, 218d ago

This is great, just what I was looking for, do you know of a way to find which specific instances of services/resources are using which using roles?

I'm trying to write a little program that will audit our role usage based on the instances of EC2 and other services using the roles.

hide preview

What's next? verify your email address for reply notifications!

unverified 4y, 197d ago

Thanks!!!!

hide preview

What's next? verify your email address for reply notifications!