{"id":13714127,"url":"https://github.com/gigawattio/awsarn","last_synced_at":"2025-12-30T06:13:00.717Z","repository":{"id":57487899,"uuid":"99282420","full_name":"gigawattio/awsarn","owner":"gigawattio","description":"AWS ARN Parser package for Go","archived":false,"fork":false,"pushed_at":"2018-03-17T19:02:44.000Z","size":7,"stargazers_count":12,"open_issues_count":1,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-08-03T23:29:47.447Z","etag":null,"topics":["aws","go","golang"],"latest_commit_sha":null,"homepage":"https://gigawatt.io/","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/gigawattio.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}},"created_at":"2017-08-03T23:13:09.000Z","updated_at":"2023-01-17T15:03:27.000Z","dependencies_parsed_at":"2022-08-29T13:31:02.583Z","dependency_job_id":null,"html_url":"https://github.com/gigawattio/awsarn","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gigawattio%2Fawsarn","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gigawattio%2Fawsarn/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gigawattio%2Fawsarn/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gigawattio%2Fawsarn/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/gigawattio","download_url":"https://codeload.github.com/gigawattio/awsarn/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":224551163,"owners_count":17330089,"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":["aws","go","golang"],"created_at":"2024-08-02T23:01:52.846Z","updated_at":"2025-12-30T06:13:00.691Z","avatar_url":"https://github.com/gigawattio.png","language":"Go","funding_links":[],"categories":["Repositories"],"sub_categories":[],"readme":"# awsarn\n\n[![Documentation](https://godoc.org/github.com/gigawattio/awsarn?status.svg)](https://godoc.org/github.com/gigawattio/awsarn)\n[![Build Status](https://travis-ci.org/gigawattio/awsarn.svg?branch=master)](https://travis-ci.org/gigawattio/awsarn)\n[![Report Card](https://goreportcard.com/badge/github.com/gigawattio/awsarn)](https://goreportcard.com/report/github.com/gigawattio/awsarn)\n\n### About\n\n[awsarn](https://github.com/gigawattio/awsarn) is an ARN parser.\n\nMore specifically, this is a Go (golang) library for validating, parsing, and comparing AWS ARN resource identifier strings.\n\nThis package also provides the capability of determining if one ARN is a superset of another.  This is useful for safely eliminating redundant ARNs from a set.\n\nCreated by [Jay Taylor](https://jaytaylor.com/) and used by [Gigawatt](https://gigawatt.io/).\n\n#### ARN Vocabulary\n\nThe AWS documentation uses [two subtly different sets of vocabulary](#further-reading) when discussing the internal workings of ARNs:\n\nVariant #1\n\n```\narn:partition:service:region:account-id:resource\narn:partition:service:region:account-id:resourcetype/resource\narn:partition:service:region:account-id:resourcetype:resource\n```\n\nVariant #2\n\n```\narn:partition:service:region:namespace:relative-id\n```\n\nThis package uses the vocabulary of variant #1, that is:\n\n* arn\n* partition\n* service\n* region\n* account-id\n* resource, resourcetype/resource, resourcetype:resource\n\n#### Wildcards\n\nThe documentation is ambiguous about which components of an ARN allow wildcards like `*` and `?`.  This package uses the loosest possible interpretation, which means wildcards are allowed in any and all parts of ARNs.\n\n### Requirements\n\n* Go version 1.1 or newer\n\n### Example usage\n\nParse an AWS ARN for an RDS database:\n\n[examples/rds.go](examples/rds.go)\n\n```go\npackage main\n\nimport (\n\t\"fmt\"\n\n\t\"github.com/gigawattio/awsarn\"\n)\n\nconst arn = \"arn:aws:rds:region:account-id:db:db-instance-name\"\n\nfunc main() {\n\tcomponents, err := awsarn.Parse(arn)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\tfmt.Printf(\"%# v\\n\", *components)\n    eq := components.String() == arn\n    fmt.Printf(\"Reconstruction: %v, equal=%v\\n\", components.String(), eq)\n}\n```\n\nOutput:\n\n```shell\nawsarn.Components{\n    ARN: \"arn\",\n    Partition: \"aws\",\n    Service: \"rds\",\n    Region: \"region\",\n    AccountID: \"account-id\",\n    ResourceType: \"db\",\n    Resource: \"db-instance-name\"\n    ResourceDelimiter: \":\"\n}\nReconstruction: arn:aws:rds:region:account-id:db:db-instance-name, equal=true\n```\n\nAlso may be worth checking out the [unit-tests](awsarn_test.go), too!\n\n### Running the test suite\n\n    go test -v ./...\n    echo $?\n\nif `echo $?` produces a 0, that's a clean exit status and means the tests succeeded.  Anything else indicates one or more failed tests.\n\n### Terminology\n\n* ARN: Amazon Resource Name; used for identifying, specifying, and referencing resources\n* AWS: Amazon Web Services; Cloud provider\n\n### Components of an ARN\n\nPiece by piece:\n\narn:partition:service:region:account-id:resourcetype/resource\n\n**arn**\n\n\u003e This should always be the string \"arn\", indicating the start of an ARN.\n\n**partition**\n\n\u003e The partition that the resource is in. For standard AWS regions, the\n\u003e partition is aws. If you have resources in other partitions, the partition\n\u003e is aws-partitionname. For example, the partition for resources in the China\n\u003e (Beijing) region is aws-cn.\n\n**service**\n\n\u003eThe service namespace that identifies the AWS product (for example, Amazon\n\u003eS3, IAM, or Amazon RDS). For a list of namespaces, see AWS Service Namespaces.\n\n**region**\n\n\u003e The region the resource resides in. Note that the ARNs for some resources do\n\u003e not require a region, so this component might be omitted.\n\n**account**\n\n\u003e The ID of the AWS account that owns the resource, without the hyphens. For\n\u003e example, 123456789012. Note that the ARNs for some resources don't require\n\u003e an account number, so this component might be omitted.\n\n**resource, resourcetype:resource, or resourcetype/resource**\n\n\u003e The content of this part of the ARN varies by service. It often includes an\n\u003e indicator of the type of resource—for example, an IAM user or Amazon RDS\n\u003e database —followed by a slash (/) or a colon (:), followed by the resource\n\u003e name itself. Some services allows paths for resource names, as described in\n\u003e Paths in ARNs.\n\n### Further reading\n\n* [Amazon AWS ARN documentation](http://docs.aws.amazon.com/general/latest/gr/aws-arns-and-namespaces.html)\n* [Amazon AWS S3 ARN format](http://docs.aws.amazon.com/AmazonS3/latest/dev/s3-arn-format.html)\n\n### License\n\nPermissive MIT license, see the [LICENSE](LICENSE) file for more information.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgigawattio%2Fawsarn","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgigawattio%2Fawsarn","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgigawattio%2Fawsarn/lists"}