Open TomasChmelik opened 3 years ago
Thanks for submitting this feature request.
I'm marking this as p2 which means we are unable to get to this immediately. We use 👍 and community engagement to determine priority.
+1
👍
Is there a workaround for this atm?
Yes
from typing import Optional
import aws_cdk
from aws_cdk import aws_apigateway
from constructs import Construct
import jsii
@jsii.implements(aws_apigateway.IAuthorizer)
class ImportedAuthorizer(Construct):
def __init__(self, scope: Construct, construct_id: str):
super().__init__(scope, construct_id)
self._authorizer_id = ""
self._authorization_type : Optional[aws_apigateway.AuthorizationType] = None
@classmethod
def from_id(cls, scope: Construct, construct_id: str, *, authorizer_id: str, authorization_type: aws_apigateway.AuthorizationType):
authorizer = cls(scope, construct_id)
authorizer._authorizer_id = authorizer_id # pylint: disable=protected-access
authorizer._authorization_type = authorization_type # pylint: disable=protected-access
return authorizer
@property
def authorizer_id(self) -> str:
return self._authorizer_id
@property
def authorization_type(self) -> Optional[aws_apigateway.AuthorizationType]:
return self._authorization_type
this allows creating any API gateway authorizer from imported authorizer_id and its type
ImportedAuthorizer.from_id(scope, 'ImportedAuthorizer', 'afd51ngf', AuthorizationType.COGNITO)
👍🏻
Add support to import existing Cognito user pool authorizers, so I could use
aws_apigateway.Method
instead ofaws_apigateway.CfnMethod
.Use Case
I have multiple stacks using same API gateway. Base stack creates the authorizer and exports authorizer ID. Other stacks should be able to use something like
apigateway.CognitoUserPoolsAuthorizer.from_authorizer_id(scope, 'Id', core.Fn.ImportValue('exported-authorizer-id'))
Proposed Solution
Other
This is a :rocket: Feature Request