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

chore(appsync): improve error message for missing iam authorization mode #33501

Merged
merged 7 commits into from
Feb 22, 2025
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion packages/aws-cdk-lib/aws-appsync/lib/eventapi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,9 @@ export abstract class EventApiBase extends ApiBase implements IEventApi {
*/
public grant(grantee: IGrantable, resources: AppSyncEventResource, ...actions: string[]): Grant {
if (!this.authProviderTypes.includes(AppSyncAuthorizationType.IAM)) {
throw new ValidationError('IAM Authorization mode is not configured on this API.', this);
throw new ValidationError('Cannot use grant method because IAM Authorization mode is missing in the auth providers on this API.',
this,
);
}
return Grant.addToPrincipal({
grantee,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,7 @@ describe('Event API security grant tests', () => {
const api = new appsync.EventApi(stack, 'api', { apiName: 'api' });

// THEN
expect(() => api.grantConnect(func)).toThrow('IAM Authorization mode is not configured on this API.');
expect(() => api.grantConnect(func)).toThrow('Cannot use grant method because IAM Authorization mode is missing in the auth providers on this API.');
});

test('Appsync Event API - grant publish for all channel namespaces within an API', () => {
Expand Down