Skip to content

aws-appsync: EventApi forces you to include IAM Authorization mode #33465

@garysassano

Description

@garysassano

Describe the bug

When creating a new EventAPI from AppSync console, this is the default authorizationConfig you get:

Image

This should be equivalent to the following code snippet:

const demoApi = new EventApi(this, "DemoApi", {
  apiName: "demo-api"
});

Which is also equivalent to this more verbose code snippet:

const demoApi = new EventApi(this, "DemoApi", {
  apiName: "demo-api",
  authorizationConfig: {
    authProviders: [
      {
        authorizationType: AppSyncAuthorizationType.API_KEY,
      },
    ],
    connectionAuthModeTypes: [AppSyncAuthorizationType.API_KEY],
    defaultPublishAuthModeTypes: [AppSyncAuthorizationType.API_KEY],
    defaultSubscribeAuthModeTypes: [AppSyncAuthorizationType.API_KEY],
  },
});

Regression Issue

  • Select this option if this issue appears to be a regression.

Last Known Working CDK Version

No response

Expected Behavior

I expected the following code to work:

const demoApi = new EventApi(this, "DemoApi", {
  apiName: "demo-api"
});

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:

const demoApi = new EventApi(this, "DemoApi", {
  apiName: "demo-api"
});

Possible Solution

The current workaround is to enable IAM authorization mode, even if it is not needed or used.

const demoApi = new EventApi(this, "DemoApi", {
  apiName: "demo-api",
  authorizationConfig: {
    authProviders: [
      {
        authorizationType: AppSyncAuthorizationType.API_KEY,
      },
      {
        authorizationType: AppSyncAuthorizationType.IAM,
      },
    ],
    connectionAuthModeTypes: [AppSyncAuthorizationType.API_KEY],
    defaultPublishAuthModeTypes: [AppSyncAuthorizationType.API_KEY],
    defaultSubscribeAuthModeTypes: [AppSyncAuthorizationType.API_KEY],
  },
});

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    @aws-cdk/aws-appsyncRelated to AWS AppSyncbugThis issue is a bug.closing-soonThis issue will automatically close in 4 days unless further comments are made.effort/mediumMedium work item – several days of effortp3response-requestedWaiting on additional info and feedback. Will move to "closing-soon" in 7 days.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions