File tree Expand file tree Collapse file tree 1 file changed +25
-0
lines changed
Expand file tree Collapse file tree 1 file changed +25
-0
lines changed Original file line number Diff line number Diff line change 1+ class AWS :
2+ def __init__ (self , region : str ) -> None :
3+ super ().__init__ ()
4+ self .region = region
5+
6+ def get_console_domain (self ):
7+ """
8+ See https://docs.aws.amazon.com/general/latest/gr/mgmt-console.html .
9+ See https://docs.amazonaws.cn/en_us/aws/latest/userguide/endpoints-arns.html .
10+ See https://github.com/boto/botocore/blob/develop/botocore/data/endpoints.json .
11+ """
12+ if self .region .startswith ("cn-" ):
13+ return f"{ self .region } .console.amazonaws.cn"
14+ if self .region .startswith ("us-gov-" ):
15+ return f"{ self .region } .console.amazonaws-us-gov.com"
16+ return f"{ self .region } .console.aws.amazon.com"
17+
18+ @staticmethod
19+ def is_arn (arn : str ):
20+ """
21+ See https://docs.aws.amazon.com/govcloud-us/latest/UserGuide/using-govcloud-arns.html .
22+ See https://docs.amazonaws.cn/en_us/aws/latest/userguide/ARNs.html .
23+ """
24+ import re
25+ return re .match (r'^arn:(aws|aws-cn|aws-us-gov):iam::([0-9]+):role/(\S+)$' , arn )
You can’t perform that action at this time.
0 commit comments