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

(AppSync) additionalAuthenticationProviders seems to be a required parameter #8668

Closed
asnaseer-resilient opened this issue Jun 20, 2020 · 2 comments
Assignees
Labels
@aws-cdk/aws-appsync Related to AWS AppSync bug This issue is a bug. needs-triage This issue or PR still needs to be triaged.

Comments

@asnaseer-resilient
Copy link

I used to be able to deploy my AppSync stack with this relevant code snippet using CDK v1.39.0:

    const graphQlApi = new cdkAppsync.GraphQLApi(this, 'GraphQL', {
      name: CDK_UTILS.resourceName('app-sync-graphql-api'),
      schemaDefinitionFile: 'schema.graphql',
      authorizationConfig: {
        defaultAuthorization: {
          userPool,
          defaultAction: cdkAppsync.UserPoolDefaultAction.ALLOW
        }
      }
    });

When upgrading to v1.46.0, I changed the above snippet to:

    const graphQlApi = new cdkAppsync.GraphQLApi(this, 'GraphQL', {
      name: CDK_UTILS.resourceName('app-sync-graphql-api'),
      schemaDefinitionFile: 'schema.graphql',
      authorizationConfig: {
        defaultAuthorization: {
          // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access
          authorizationType: cdkAppsync.AuthorizationType.USER_POOL,
          userPoolConfig: {
            userPool,
            defaultAction: cdkAppsync.UserPoolDefaultAction.ALLOW
          }
        }
      }
    });

NOTE: I had to add an eslint comment on the assignment of authorizationType as it was complaining about this.

I then received this error on deployment:

.../node_modules/@aws-cdk/aws-appsync/lib/graphqlapi.js:100
            additionalAuthenticationProviders: ((_g = props.authorizationConfig) === null || _g === void 0 ? void 0 : _g.additionalAuthorizationModes.length) ? this.formatAdditionalAuthorizationModes(props.authorizationConfig.additionalAuthorizationModes)
                                                                                                                                                      ^
TypeError: Cannot read property 'length' of undefined
    at new GraphQLApi (.../node_modules/@aws-cdk/aws-appsync/lib/graphqlapi.js:100:151)
    at new AppSyncConstruct (.../app-sync/app-sync-construct.js:36:28)

From the error I am guessing that the implementation assumes that additionalAuthenticationProviders parameters is always specified so I changed the above code to this:

    const graphQlApi = new cdkAppsync.GraphQLApi(this, 'GraphQL', {
      name: CDK_UTILS.resourceName('app-sync-graphql-api'),
      schemaDefinitionFile: 'schema.graphql',
      authorizationConfig: {
        defaultAuthorization: {
          // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access
          authorizationType: cdkAppsync.AuthorizationType.USER_POOL,
          userPoolConfig: {
            userPool,
            defaultAction: cdkAppsync.UserPoolDefaultAction.ALLOW
          }
        },
        additionalAuthorizationModes: []     // <--- workaround here
      }
    });

This got rid of the error but I believe we should not have to specify an empty array and am therefore raising this as a bug.

My deployments are run via CircleCI but I see the same error even when deploying locally (Mac OS Catalina 10.15.5 with Node 12.14.0) using a command like this:

cdk deploy appSync --app .build/stacks/cfd-api-stacks.js -o .build/cdk.out/appSync --no-staging --exclusively --require-approval never

Environment

  • CLI Version : 1.46.0
  • Node.js Version: circleci/node:12.14.1
  • OS : CircleCI node_executor
  • Language (Version): TypeScript 3.9.5, eslint 7.2.0

This is 🐛 Bug Report

@asnaseer-resilient asnaseer-resilient added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Jun 20, 2020
@civilizeddev
Copy link
Contributor

duplicate of #8666

@SomayaB SomayaB added the @aws-cdk/aws-appsync Related to AWS AppSync label Jun 22, 2020
@SomayaB SomayaB changed the title AppSync additionalAuthenticationProviders seems to be a required parameter (AppSync) additionalAuthenticationProviders seems to be a required parameter Jun 22, 2020
mergify bot pushed a commit that referenced this issue Jun 23, 2020
…odes' is undefined (#8673)

fix(appsync): Not to throw an Error even if 'additionalAuthorizationModes' is undefined

fixes #8666 #8668

----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
@MrArnoldPalmer
Copy link
Contributor

Resolved via #8673

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
@aws-cdk/aws-appsync Related to AWS AppSync bug This issue is a bug. needs-triage This issue or PR still needs to be triaged.
Projects
None yet
Development

No branches or pull requests

4 participants