amplify-cli icon indicating copy to clipboard operation
amplify-cli copied to clipboard

Issue Title: Unable to Change Authorization Type for API to Cognito User Pools in Amplify

Open stephenjen opened this issue 1 year ago • 1 comments

How did you install the Amplify CLI?

npm

If applicable, what version of Node.js are you using?

v17.5.0

Amplify CLI Version

12.12.6

What operating system are you using?

Mac

Did you make any manual changes to the cloud resources managed by Amplify? Please describe the changes made.

After using Amplify add api to create the api gateway for my Lamda function, I changed the authorization for the API gateway for the state to Cognito pool, then deployed the change.

Describe the bug

I used Amplify add api to create the API gateway for my Lamda function. During this process, I selected Restrict API access to Y for Authenticated users only. Despite this, the authorizationType in amplifyconfiguration.dart shows "authorizationType": "AWS_IAM".

I then changed the authorization for the API gateway via AWS Console for the state to Cognito pool, then deployed the change. But amplifyconfiguration.dart still shows "authorizationType": "AWS_IAM".

I ran amplify pull --restore, but the amplifyconfiguration.dart still shows AWS_IAM as the authorization type.

Additionally, my parameters.json file located in amplify/backend/api/<my_api_name>/build/ is empty ({}), and the correct parameters.json file does not exist in the amplify/backend/api/<my_api_name>/ directory.

Expected behavior

API gateway to use congito user pool to authenticate API calls

Reproduction steps

  1. Create and test Lamda function
  2. Run Amplify api add to add the REST api for the Lamda function
  3. Run Amplify push to push changes to AWS
  4. Noticed amplifyconfiguration has AWS_AMI as authorizationType

Project Identifier

No response

Log output

# Put your logs below this line


Additional information

No response

Before submitting, please confirm:

  • [X] I have done my best to include a minimal, self-contained set of instructions for consistently reproducing the issue.
  • [X] I have removed any sensitive information from my code snippets and submission.

stephenjen avatar Sep 28 '24 03:09 stephenjen

Hey @stephenjen, thank you for reaching out. To modify the authorizer on the REST API, you would need to override the resource. Refer to AWS Amplify documentation on authorizing API requests with Cognito User Pools.

ykethan avatar Sep 30 '24 19:09 ykethan

Closing the issue due to inactivity. Do reach out to us if you are still experiencing this issue

ykethan avatar Oct 21 '24 15:10 ykethan

This issue is now closed. Comments on closed issues are hard for our team to see. If you need more assistance, please open a new issue that references this one.

github-actions[bot] avatar Oct 21 '24 15:10 github-actions[bot]