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

(aws-appsync): Lambda Authorizer for AppSync GraphqlApi #16380

Closed
2 tasks
Danik-Barinshtein opened this issue Sep 4, 2021 · 5 comments · Fixed by #16743
Closed
2 tasks

(aws-appsync): Lambda Authorizer for AppSync GraphqlApi #16380

Danik-Barinshtein opened this issue Sep 4, 2021 · 5 comments · Fixed by #16743
Assignees
Labels
@aws-cdk/aws-appsync Related to AWS AppSync effort/small Small work item – less than a day of effort feature-request A feature should be added or improved. p1

Comments

@Danik-Barinshtein
Copy link

Danik-Barinshtein commented Sep 4, 2021

Hello,

Currently the GraphqlApi Construct does not support the AWS_LAMBDA AuthorizationType

Hoping to see if its possible to extend the construct with the CfnGraphqlApi's lambda authorizer config

Use Case

While I understand that the GraphqlApi is an experimental none Cfn construct, we chose to go with it due to it providing "all" the features we needed and its syntax was preferable. At this stage we are realizing that the Lambda Authorizer is the last feature we require to proceed. Before considering switching our entire CDK setup to utilize the CfnGraphqlApi I am looking to see if this feature could be added.

Proposed Solution

Extend the developed AWS_LAMBDA authorizer configuration from the CfnGraphqlApi to the GraphqlApi construct.

  • 👋 I may be able to implement this feature request
  • ⚠️ This feature might incur a breaking change

This is a 🚀 Feature Request

@Danik-Barinshtein Danik-Barinshtein added feature-request A feature should be added or improved. needs-triage This issue or PR still needs to be triaged. labels Sep 4, 2021
@github-actions github-actions bot added @aws-cdk/aws-appsync Related to AWS AppSync @aws-cdk/aws-lambda Related to AWS Lambda labels Sep 4, 2021
@Danik-Barinshtein Danik-Barinshtein changed the title Lambda Authorizer for AppSync GraphqlApi (aws-appsync) Lambda Authorizer for AppSync GraphqlApi Sep 4, 2021
@Danik-Barinshtein Danik-Barinshtein changed the title (aws-appsync) Lambda Authorizer for AppSync GraphqlApi (aws-appsync): Lambda Authorizer for AppSync GraphqlApi Sep 4, 2021
@aman-hatcroft
Copy link

It is very strange for me to see that AWS released the custom Lambda authoriser feature as an Authorization mode for GraphQL on 30th Jul 2021 without the infra automation code. Are the teams for the Appsync CDK & the actual AppSync services different ?

https://aws.amazon.com/blogs/mobile/appsync-lambda-auth/

https://aws.amazon.com/about-aws/whats-new/2021/07/aws-appsync-supports-custom-authorization-with-aws-lambda-graphsql-apis/

aws/aws-appsync-community#2

@Danik-Barinshtein . Glad that you raised this.

@nija-at nija-at removed the @aws-cdk/aws-lambda Related to AWS Lambda label Sep 8, 2021
@nija-at nija-at removed their assignment Sep 8, 2021
@otaviomacedo otaviomacedo added effort/small Small work item – less than a day of effort p1 good first issue Related to contributions. See CONTRIBUTING.md and removed needs-triage This issue or PR still needs to be triaged. labels Sep 9, 2021
@otaviomacedo
Copy link
Contributor

Marking this as a p1, as I see this is a popular feature, that more people will want.

Having said that, whenever a new feature is added to CloudFormation, but is not yet available in CDK, you can always use escape hatches. In this case, it would look something like:

const api = new appsync.GraphqlApi(this, 'Api', ...);

const cfnApi = api.node.defaultChild as CfnGraphQLApi;
cfnApi.lambdaAuthorizerConfig = {
  ...
}

@otaviomacedo otaviomacedo removed their assignment Sep 9, 2021
@kaizencc kaizencc self-assigned this Sep 24, 2021
@kaizencc
Copy link
Contributor

I'd like to pick this one up since it seems popular. I'll submit a PR early next week but in the meantime, I'd like to solicit thoughts on what the properties for LambdaConfig should be. If I took them verbatim from the docs they would be:

export interface LambdaConfig {
    /**
     * The number of seconds a response should be cached for
     */
    authorizerResultTtlInSeconds: number;

    /**
     * The ARN of the Lambda function to be called for authorization.
     */
    authorizerUri: string;

    /**
     * A regular expression for validation of tokens before the Lambda function is called. 
     */
    identityValidationExpression: string;
}

I feel like we could improve on these names (particularly authorizerResultTtlInSeconds) for the CDK. Any thoughts? It looks like we did something similar for OpenIdConnectConfig in making the CDK property names more user friendly.

@kaizencc kaizencc removed the good first issue Related to contributions. See CONTRIBUTING.md label Oct 1, 2021
@kaizencc
Copy link
Contributor

kaizencc commented Oct 1, 2021

^ It's really not a good first issue... maybe even an effort/medium but I will keep it as small because its not that important :).

@mergify mergify bot closed this as completed in #16743 Oct 6, 2021
mergify bot pushed a commit that referenced this issue Oct 6, 2021
Adds the relatively new [Lambda Authorizer for GraphqlApi](https://aws.amazon.com/blogs/mobile/appsync-lambda-auth/).

Closes: #16380. 

----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
@github-actions
Copy link

github-actions bot commented Oct 6, 2021

⚠️COMMENT VISIBILITY WARNING⚠️

Comments on closed issues are hard for our team to see.
If you need more assistance, please either tag a team member or open a new issue that references this one.
If you wish to keep having a conversation with other community members under this issue feel free to do so.

njlynch pushed a commit that referenced this issue Oct 11, 2021
Adds the relatively new [Lambda Authorizer for GraphqlApi](https://aws.amazon.com/blogs/mobile/appsync-lambda-auth/).

Closes: #16380. 

----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
TikiTDO pushed a commit to TikiTDO/aws-cdk that referenced this issue Feb 21, 2022
Adds the relatively new [Lambda Authorizer for GraphqlApi](https://aws.amazon.com/blogs/mobile/appsync-lambda-auth/).

Closes: aws#16380. 

----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
@aws-cdk/aws-appsync Related to AWS AppSync effort/small Small work item – less than a day of effort feature-request A feature should be added or improved. p1
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants