-
Notifications
You must be signed in to change notification settings - Fork 4k
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: EventApi
forces you to include IAM Authorization mode
#33465
Comments
Analysis:
Proposed Solution:
Making this a P1 and we welcome PRs. |
I was not able to reproduce this, the minimal code synths fine for me on |
@gshpychka I confirmed that there was a demoApi.grantPublish(testPublisherFunction); The error message could be clearer though, as it wasn't immediately obvious that it originated from that part of the code. A more descriptive message could be: You cannot grant permissions to an EventAPI unless IAM Authorization Mode is enabled. |
@pahud This looks AI-generated, and doesn't make complete sense to me. I haven't used AppSync, though, so maybe I'm missing something regarding how granting access to it works?
Agreed, I would expect a PR like that to be approved/merged farily quickly. |
Thank you @gshpychka after re-investigate this issue with the new comment by @garysassano const demoApi = new appsync.EventApi(this, "DemoApi", {
apiName: "demo-api"
}); This actually creates the API with aws-cdk/packages/aws-cdk-lib/aws-appsync/lib/eventapi.ts Lines 213 to 215 in 085c2e3
And you will need to pass in an optional const iamProvider: appsync.AppSyncAuthProvider = {
authorizationType: appsync.AppSyncAuthorizationType.IAM,
};
const demoApi = new appsync.EventApi(this, "DemoApi", {
apiName: "demo-api",
authorizationConfig: {
authProviders: [
iamProvider
]
}
}); so you can grant() grantPublish() to the resource principal that requires IAM authorization. check https://github.com/aws/aws-cdk/tree/main/packages/aws-cdk-lib/aws-appsync#authorization-1 for more details and samples. And yes,
This error message might be a bit confusing. Feel free to submit a PR to improve this if you believe it should be improved. Let me know if it works for you. |
This issue has not received a response in a while. If you want to keep this issue open, please leave a comment below and auto-close will be canceled. |
…ode (#33501) ### Issue # (if applicable) Closes #33465 ### Reason for this change The error message when using grant methods like `grantPublish()` and `grantSubscribe()` on an Event API without IAM authorization mode needs improvement. Currently, users get a confusing error without clear guidance on how to fix it. The error should clearly explain: 1. Why the operation failed (you tried to use a grant method on an Event API with missing IAM authorization mode) 2. How to fix it (add IAM authorization mode to the auth providers list) ### Description of changes Rephrased the error message. ### Describe any new or updated permissions being added ### Description of how you validated changes ### Checklist - [ ] My code adheres to the [CONTRIBUTING GUIDE](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md) and [DESIGN GUIDELINES](https://github.com/aws/aws-cdk/blob/main/docs/DESIGN_GUIDELINES.md) ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
Comments on closed issues and PRs are hard for our team to see. |
Describe the bug
When creating a new
EventAPI
from AppSync console, this is the defaultauthorizationConfig
you get:This should be equivalent to the following code snippet:
Which is also equivalent to this more verbose code snippet:
Regression Issue
Last Known Working CDK Version
No response
Expected Behavior
I expected the following code to work:
Current Behavior
I got the following error:
ValidationError: IAM Authorization mode is not configured on this API. at path [cdk-aws-appsync-events-demo-dev/EventsApi] in aws-cdk-lib.aws_appsync.EventApi
Reproduction Steps
Create the following resource:
Possible Solution
The current workaround is to enable IAM authorization mode, even if it is not needed or used.
Additional Information/Context
No response
CDK CLI Version
2.178.2
Framework Version
No response
Node.js Version
22.13.0
OS
24.04.1
Language
TypeScript
Language Version
No response
Other information
No response
The text was updated successfully, but these errors were encountered: