Skip to content

Instantly share code, notes, and snippets.

@cmaurer
Last active August 3, 2021 14:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cmaurer/36f9e98e7d8f6fecc1d8899b3b84e65c to your computer and use it in GitHub Desktop.
Save cmaurer/36f9e98e7d8f6fecc1d8899b3b84e65c to your computer and use it in GitHub Desktop.
A collection of regular expressions for AWS Ids

AWS ID Regex's

I needed one place where all of the regex's are located. I got tired of trying to track them down.

ARN - PCRE

^arn:(?P<partition>[^:\n]*):(?P<service>[^:\n]*):(?P<region>[^:\n]*):(?P<account_id>[^:\n]*):(?P<ignore>(?P<resource_type>[^:\/\n]*)[:\/])?(?P<resource>.*)$

lambda example

ARN - Javascript

^arn:(?<partition>[^:\n]*):(?<service>[^:\n]*):(?<region>[^:\n]*):(?<account_id>[^:\n]*):(?<ignore>(?<resource_type>[^:\/\n]*)[:\/])?(?<resource>.*)$

lambda example

s3 bucket example

s3 object example

VPC ID

vpc-[^\s]+

example

Subnet ID

subnet-[^\s]+

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment