iam-policy-generator
iam-policy-generator copied to clipboard
Generate Resource ARNs
Since fetched policy.json file contains a reference to ARNTemplate, this can be used to generate automatically a policy resource schema (thus offering an helper to generate a string for resource field in PolicyStatement).
How it should work
- Generate a resource ARNs after receiving params
- Provide an helper to specify ANY Arn component
- Generate wildcard ARNs when ANY is filled
- Generate resource strings into the array
- Support custom resource string passing
How to implement
- After downloading policy.json file, extract template and build that into a
.ts
enum - Make template hooks into strings be of the same kind (some of them are in the form
${}
other in the form<>
) - Replace
${partition}
with aws, since it is always an AWS - Add a method to PolicyGenerator.ts to generate resources
- Use a templating engine to fill the template when resource string needs to be provided
As suggested by @alexcasalboni PolicyGenerator: change .addResource() method to accept an Arn class and define an enum
to hold ANY value
Partition is not always aws
: https://docs.aws.amazon.com/govcloud-us/latest/UserGuide/using-govcloud-arns.html:
In the AWS GovCloud (US) Regions, ARNs begin with:
arn:aws-us-gov
Great suggestion, it is going to be addressed in the upcoming 2.0 release