{"id":20290668,"url":"https://github.com/notdodo/arner","last_synced_at":"2026-05-07T20:43:45.761Z","repository":{"id":56855279,"uuid":"524780341","full_name":"notdodo/arner","owner":"notdodo","description":"Correctly parse AWS ARN strings","archived":false,"fork":false,"pushed_at":"2023-02-22T13:47:01.000Z","size":48,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-14T08:52:53.023Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/notdodo.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-08-14T21:08:38.000Z","updated_at":"2022-08-25T09:37:13.000Z","dependencies_parsed_at":"2025-01-14T08:46:24.154Z","dependency_job_id":"c58de807-564d-4891-828e-cdddd43820c5","html_url":"https://github.com/notdodo/arner","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/notdodo%2Farner","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/notdodo%2Farner/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/notdodo%2Farner/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/notdodo%2Farner/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/notdodo","download_url":"https://codeload.github.com/notdodo/arner/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241787488,"owners_count":20020099,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-14T15:08:40.012Z","updated_at":"2026-05-07T20:43:40.740Z","avatar_url":"https://github.com/notdodo.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ARNer\n\n\u003ca href='https://github.com/jpoles1/gopherbadger' target='_blank'\u003e![gopherbadger-tag-do-not-edit](https://img.shields.io/badge/Go%20Coverage-100%25-brightgreen.svg?longCache=true\u0026style=flat)\u003c/a\u003e\n[![Go Reference](https://pkg.go.dev/badge/github.com/notdodo/arner.svg)](https://pkg.go.dev/github.com/notdodo/arner)\n\n\u003e Amazon Resource Names (ARNs) uniquely identify AWS resources. We require an ARN when you need to specify a resource unambiguously across all of AWS, such as in IAM policies, Amazon Relational Database Service (Amazon RDS) tags, and API calls.\n\n[Amazon Resource Names Documentation](https://docs.aws.amazon.com/general/latest/gr/aws-arns-and-namespaces.html)\n\nThe official AWS Golang SDK library has a simple ARN parsing function ([Parse](https://pkg.go.dev/github.com/aws/aws-sdk-go-v2@v1.16.11/aws/arn#Parse)) which is not actually accurate if you need to know the exact resource's name and/or path and/or resource type (i.e. role, group, table, cluster, etc.)\n\nThis library correctly parse AWS ARN strings and outputs a BetterARN struct.\n\n```golang\ntype BetterARN struct {\n\t// The partition that the resource is in. For standard AWS regions, the partition is \"aws\". If you have resources in\n\t// other partitions, the partition is \"aws-partitionname\". For example, the partition for resources in the China\n\t// (Beijing) region is \"aws-cn\".\n\tPartition string\n\n\t// The service namespace that identifies the AWS product (for example, Amazon S3, IAM, or Amazon RDS). For a list of\n\t// namespaces, see\n\t// http://docs.aws.amazon.com/general/latest/gr/aws-arns-and-namespaces.html#genref-aws-service-namespaces.\n\tService string\n\n\t// The region the resource resides in. Note that the ARNs for some resources do not require a region, so this\n\t// component might be omitted.\n\tRegion string\n\n\t// The ID of the AWS account that owns the resource, without the hyphens. For example, 123456789012. Note that the\n\t// ARNs for some resources don't require an account number, so this component might be omitted.\n\tAccountID string\n\n\t// The content of this part of the ARN varies by service. It often includes an indicator of the type of resource —\n\t// for example, an IAM user or Amazon RDS database - followed by a slash (/) or a colon (:), followed by the\n\t// resource name itself. Some services allows paths for resource names, as described in\n\t// http://docs.aws.amazon.com/general/latest/gr/aws-arns-and-namespaces.html#arns-paths.\n\tResourceType string\n\n\t// The actual resource name that the ARN is pointing to;\n\t// for example, a DynamoDB table arn:aws:dynamodb:::table/thistableprod real name is thistableprod.\n\tResource string\n\n\t// Paths can be use to logically separate resources like Organization Units for Users/Roles or specify subdirectory in S3 buckets.\n\tPath string\n}\n```\n\n## Example\n\n```golang\npackage main\n\nimport (\n\t\"fmt\"\n\t\"log\"\n\n\t\"github.com/notdodo/arner\"\n)\n\nfunc main() {\n\tarn := \"arn:aws:iam::111111111111:user/division_abc/subdivision_xyz/JaneDoe\"\n\n\tbetterARN, err := arner.ParseARN(arn)\n\tif err != nil {\n\t\tlog.Fatalln(err)\n\t}\n\n\tfmt.Println(betterARN)\n}\n```\n\nOutput will be:\n\n```json\n{\n  \"Partition\": \"aws\",\n  \"Service\": \"iam\",\n  \"Region\": \"\",\n  \"AccountID\": \"111111111111\",\n  \"ResourceType\": \"user\",\n  \"Resource\": \"JaneDoe\",\n  \"Path\": \"division_abc/subdivision_xyz\"\n}\n```\n\n## Why?\n\nBecause the default AWS SDK Golang library V2, for the previous example returns:\n\n```json\n{\n  \"Partition\": \"aws\",\n  \"Service\": \"iam\",\n  \"Region\": \"\",\n  \"AccountID\": \"111111111111\",\n  \"Resource\": \"user/division_abc/subdivision_xyz/JaneDoe\"\n}\n```\n\nIn my case I need the exact name of the resource, not the complete path plus the resource type plus other garbage.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnotdodo%2Farner","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnotdodo%2Farner","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnotdodo%2Farner/lists"}