-
-
Save KyMidd/646ef35f4b326ed25dd3dcbadb44377f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def parse_arn(arn): | |
| # http://docs.aws.amazon.com/general/latest/gr/aws-arns-and-namespaces.html | |
| elements = arn.split(':', 6) | |
| result = { | |
| 'arn': elements[0], | |
| 'partition': elements[1], | |
| 'service': elements[2], | |
| 'region': elements[3], | |
| 'account': elements[4], | |
| 'resource': elements[5], | |
| 'resource_name': elements[6] | |
| } | |
| if '/' in result['resource']: | |
| result['resource_type'], result['resource'] = result['resource'].split('/',1) | |
| elif ':' in result['resource']: | |
| result['resource_type'], result['resource'] = result['resource'].split(':',1) | |
| return result |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment