Skip to content

Instantly share code, notes, and snippets.

@matwerber1
Last active October 13, 2023 04:16
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 matwerber1/798073832a22a5441f3ef2fec7d35759 to your computer and use it in GitHub Desktop.
Save matwerber1/798073832a22a5441f3ef2fec7d35759 to your computer and use it in GitHub Desktop.
Javascript regex patterns for AWS

AWS Resource Regex Patterns

AWS Backup

These were extracted from the open source AWS CLI code on GitHub for AWS Backup:

ruleName: /^[a-zA-Z0-9\-_\.]{1,50}$/,
selectionName: /^[a-zA-Z0-9\\-\\_\\.]{1,50}$/,
vaultName: /^[a-zA-Z0-9\\-\\_\\.]{1,50}$/,
frameworkDescription: /.*\\S.*/,
frameworkName: /[a-zA-Z][_a-zA-Z0-9]*/,
reportPlanDescription: /.*\\S.*/, 
reportPlanName: /[a-zA-Z][_a-zA-Z0-9]*/,
organizationId: /^o-[a-z0-9]{10,32}$/,
OrganizationalUnitId: /^ou-[0-9a-z]{4,32}-[a-z0-9]{8,32}$/,
policyDescription: /[\\s\\S]*/,
policyName: /[\\s\\S]*/ ,
tagKey: /^([\\p{L}\\p{Z}\\p{N}_.:/=+\\-@]*)$/,
tagValue: /^([\\p{L}\\p{Z}\\p{N}_.:/=+\\-@]*)$/

AWS Lambda

Lambda Function, Lambda Layer, and Lambda Event Source Mapping:

^(arn:(?:aws|aws-cn|aws-us-gov)):[\w-]*:[\w-]*:[\d]{12}:(function|layer|event-source-mapping):[\w-]*:[\w-]*(:[\w-]*){0,1}$

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