Amplify-cli: Hooking Up Existing Cognito User Pool With GraphQL API

Created on 31 May 2020  路  4Comments  路  Source: aws-amplify/amplify-cli

Hello,

I am having trouble finding this out, but I wanted to know if it is possible to create a graphQL API through the CLI and use an existing Cognito User Pool? I don't think there is any straight forward process but I wanted to enquire anyways.

I was able to do a somewhat hacky workaround where I would add auth through the Amplify CLI and then modify the cloudformation template to just return the corresponding values in the output.

Which Category is your question related to?
GraphQL/Auth

Amplify CLI Version

You can use amplify -v to check the amplify cli version on your system

What AWS Services are you utilizing?
AppSync Cognito Amplify

Provide additional details e.g. code snippets
Below is my lower section of my auth cloudformation file:

.
.
.
Conditions:
  ShouldNotCreateEnvResources: !Equals [ !Ref env, NONE ]
  AlwaysFalse: !Equals [ "true", "false"]
  MasterEnv: !Equals [ !Ref env, "master"]

Resources:
  EmptyResource:
    Type: Custom::EmptyResource,
    Condition: AlwaysFalse

Outputs:

  UserPoolId:
    Value: !If [MasterEnv, ####Prod Cognito Pool#####, <<<<<<Dev Cognito Pool>>>>>>>]
    Description:  Id for the user pool
  IdentityPoolId:
    Value: !If [MasterEnv,  ####Prod Identity Pool#####, <<<<<<Dev Identity Pool>>>>>>>]
    Description:  Identity Pool Id for the user pool
  UserPoolName:
    Value: "NONE"
auth enhancement question

Most helpful comment

Yes we do have plans and current working on design for importing existing Cognito configs. I will mark this enhancement and if you have any ideas we would love to hear any feedback you have.

All 4 comments

That would be the right way to go around it by replacing your Userpool values and then adding it to your API through the CLI

Thank you for your response. Do you know if there are any plans to natively support this feature through the CLI without this workaround?

Yes we do have plans and current working on design for importing existing Cognito configs. I will mark this enhancement and if you have any ideas we would love to hear any feedback you have.

Closing in favor the import RFC: https://github.com/aws-amplify/amplify-cli/issues/3977
Please follow that issue for updates.

Was this page helpful?
0 / 5 - 0 ratings