We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 9a849cf commit 3c9ff8aCopy full SHA for 3c9ff8a
get_accountid.py
@@ -0,0 +1,15 @@
1
+import boto3
2
+import sys
3
+
4
+# Script gets the AWS profile name as input param and
5
+# prints the corresponding account-id associated with the profile
6
+session = boto3.Session(profile_name=sys.argv[1])
7
+credentials = session.get_credentials()
8
9
+# credentials = credentials.get_frozen_credentials()
10
+ACCESS_KEY = credentials.access_key
11
+SECRET_KEY = credentials.secret_key
12
13
+client = boto3.client("sts", aws_access_key_id=ACCESS_KEY, aws_secret_access_key=SECRET_KEY)
14
+account_id = client.get_caller_identity()["Account"]
15
+print(account_id)
0 commit comments