(aws-appsync): userPoolConfig authorizer ignores the userpool region
See original GitHub issueWhen adding an authorizer to the appSync, using the userPoolConfig, we can import the authorizer from the Arn, however the the CF will add the deployment region rather than the authorizer region for that particular instance.
Reproduction Steps
const currentAuthorizer = cognito.UserPool.fromUserPoolArn(this, 'AuthInAnotherRegion', userPoolArn);
const featuresApi = new appsync.GraphqlApi(this, 'GqlApi', {
name: 'feature-control',
schema: appsync.Schema.fromAsset('graphql/schema.graphql'),
authorizationConfig: {
defaultAuthorization: {
authorizationType: appsync.AuthorizationType.USER_POOL,
userPoolConfig: {
userPool: currentAuthorizer,
},
},
});
What did you expect to happen?
Resources:
GqlApi4E487465:
Type: AWS::AppSync::GraphQLApi
Properties:
AuthenticationType: AMAZON_COGNITO_USER_POOLS
Name: feature-control
UserPoolConfig:
AwsRegion: eu-west-2
DefaultAction: ALLOW
UserPoolId: eu-west-2_USERPOOLID
Metadata:
aws:cdk:path: FeaturesBackendFrankFurt/GqlApi/Resource
What actually happened?
Resources:
GqlApi4E487465:
Type: AWS::AppSync::GraphQLApi
Properties:
AuthenticationType: AMAZON_COGNITO_USER_POOLS
Name: feature-control
UserPoolConfig:
AwsRegion: eu-central-1
DefaultAction: ALLOW
UserPoolId: eu-west-2_USERPOOLID
Metadata:
aws:cdk:path: FeaturesBackendFrankFurt/GqlApi/Resource
Environment
- CDK CLI Version : 1.94.1
- Framework Version:
- Node.js Version: 14.16.0
- OS : macOS Darwin
- Language (Version): typescript
Other
I have tried overwriting the env to see if that would be picked up as a workaround to no avail:
defaultAuthorization: {
authorizationType: appsync.AuthorizationType.USER_POOL,
userPoolConfig: {
userPool: currentAuthorizer,
},
},
I expect the region to be picked up based on the retuned authorizer. As it most likely will include its own region (or picked up from the id as it is also included…)
This is 🐛 Bug Report
Thanks!
Issue Analytics
- State:
- Created 3 years ago
- Comments:5 (2 by maintainers)
Top Results From Across the Web
UserPoolConfig - AppSync - AWS Documentation
A regular expression for validating the incoming Amazon Cognito user pool app client ID. If this value isn't set, no filtering is applied....
Read more >AWS AppSync Developer Guide - Amazon S3
AWS AppSync console. The first page you see is Getting Started, which has information such as your endpoint URL and authorization mode.
Read more >Serverless Appsync Plugin
Deploy AppSync API's in minutes using this Serverless plugin. Getting Started. Be sure to check out all that AWS AppSync has to offer....
Read more >Class: AWS.AppSync - API Manual
AWS AppSync provides API actions for creating and interacting with ... The signing region for AWS IAM authorization. ... The user pool ID....
Read more >Authenticate AppSync queries console with Cognito User Pools
Sub ${AWS::Region} DefaultAction: ALLOW. Should be: ... AMAZON_COGNITO_USER_POOLS UserPoolConfig: UserPoolId: !Ref UserPool AwsRegion: !
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
The issue is related to the way the
Cognito UserPools
are imported. You won’t be able to parse the value from the arn as it’s recreated on import. Created a PR to fix the issue.Found a workaround (not sure if it is intended to be used this way… ).
The code will set the region based on the
userPoll.stack.region
, by passing a new Stack and setting the region I wan as props, it will pick up the right region. It does look a but hacky, but it works: