Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor factory hierarchy to extend PolicyStatement #15

Open
alexcasalboni opened this issue May 4, 2020 · 0 comments
Open

Refactor factory hierarchy to extend PolicyStatement #15

alexcasalboni opened this issue May 4, 2020 · 0 comments
Labels
feature New Feature request nice to have Medium priority

Comments

@alexcasalboni
Copy link
Contributor

I thought of an alternative convention to get rid of the .build() and to make the code more readable.

Something like this:

    exampleFunction.addToRolePolicy(
      PolicyStatementFactory.buildPolicyStatement() // this returns a sub-class of the official PolicyStatement
        .setEffect(Effect.ALLOW)
        .addResource(exampleBucket.bucketArn)
        .addActions([Action.S3.LIST_BUCKET, Action.S3.PUT_OBJECT])
        // no final .build() here
    );

Basically, you wouldn't instantiate an object of class PolicyStatementFactory, but you'd use a static method to get an empty object of class GeneratedPolicyStatement, which would be a sub-class of PolicyStatement. I think this is also what @lusentis had in mind :)

@aletheia aletheia added feature New Feature request nice to have Medium priority question Further information is requested labels May 4, 2020
@aletheia aletheia removed the question Further information is requested label May 19, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New Feature request nice to have Medium priority
Projects
None yet
Development

No branches or pull requests

2 participants