[PYTHON] Get AWS account ID with boto3

import boto3

iam = boto3.client('iam')
user = iam.get_user()

aws_account_id =  user['User']['Arn'].split(':')[4]


Recommended Posts

Get AWS account ID with boto3
Get thread ID with python
How to get parent id with sqlalchemy
[AWS] Link Lambda and S3 with boto3
Get a list of IAM users with Boto3
Manage AWS nicely with the Python library Boto
Put AWS data in Google Spreadsheet with boto + gspread
Tested with boto3 + mock
Region specification with boto
Get started with MicroPython
Get Tweets with Tweepy
[Piyopiyokai # 1] Let's play with Lambda: Get a Twitter account
S3 uploader with boto
Get date with python
AWS CDK with Python
Get started with Mezzanine
How to get the information of organizations, Cost Explorer of another AWS account with Lambda (python)
Get the id of a GPU with low memory usage
Display only the resources created when acquiring AWS resources with Boto3
Get country code with python
Get table dynamically with sqlalchemy
Get started with Django! ~ Tutorial ⑤ ~
Set connection timeout with boto3
Get Twitter timeline with python
Get FortiGate Application Control ID
Get Youtube data with python
S3 operation with python boto3
Get information with zabbix api
Get started with Django! ~ Tutorial ④ ~
Change retry settings with boto3
Get started with Django! ~ Tutorial ⑥ ~
Linux fastest learning with AWS
AWS Lambda with PyTorch [Lambda import]
Get started with Python! ~ ② Grammar ~
Get image features with OpenCV
Get stock price with Python
Get home directory with python
Get keyboard events with python
(Python) Get AWS billing amount
Get Alembic information with Python
Use AWS interpreter with Pycharm
Get another tab with pyppeteer
Get ranking with Rakuten API
How to get the ID of Type2Tag NXP NTAG213 with nfcpy