-
Notifications
You must be signed in to change notification settings - Fork 1.1k
API key troubleshoot guide #7909
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
Merged
Merged
Changes from 12 commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
90a873f
Resolving API Key Not Found issue
AnilMaktala de0cfec
updates
AnilMaktala b23ec57
updated
AnilMaktala c227803
added titles
AnilMaktala c54b7cf
updated title
AnilMaktala 8c4aedb
updated file path
AnilMaktala b2f0631
fixed styling
AnilMaktala 1e1edae
fixed styling
AnilMaktala b1e1021
aligned text
AnilMaktala 6467e16
fixed format
AnilMaktala 35374bc
text alignment
AnilMaktala 118ea2e
updated filepath
AnilMaktala 80cd2a2
Update src/pages/gen1/[platform]/build-a-backend/troubleshooting/apik…
AnilMaktala 3a63f77
Update src/pages/gen1/[platform]/build-a-backend/troubleshooting/apik…
AnilMaktala bf5f2ca
added apikey-not-found entry in directory.mjs
AnilMaktala File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
112 changes: 112 additions & 0 deletions
112
...ages/gen1/[platform]/build-a-backend/troubleshooting/apikey-not-found/index.mdx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,112 @@ | ||
import { getCustomStaticPath } from '@/utils/getCustomStaticPath'; | ||
|
||
export const meta = { | ||
title: 'API Key Not Found issue', | ||
description: 'Resolving API Key Not Found issue', | ||
platforms: [ | ||
'angular', | ||
'javascript', | ||
'nextjs', | ||
'react', | ||
'react-native', | ||
'vue' | ||
] | ||
}; | ||
|
||
export const getStaticPaths = async () => { | ||
return getCustomStaticPath(meta.platforms); | ||
}; | ||
|
||
export function getStaticProps(context) { | ||
return { | ||
props: { | ||
platform: context.params.platform, | ||
meta | ||
} | ||
}; | ||
} | ||
|
||
If you're encountering an "API Key Not Found" issue in your Amplify project, follow the steps below to troubleshoot and resolve the problem: | ||
|
||
## Step 1: Modify `parameters.json` to Remove API Key | ||
|
||
1. Navigate to the `amplify/backend/api/<apiName>/parameters.json` file in your project. | ||
2. Add the following line to the file: | ||
|
||
```json title="amplify/backend/api/<apiName>/parameters.json" | ||
AnilMaktala marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
{ | ||
"CreateAPIKey": 0 | ||
} | ||
``` | ||
Ensure that a comma is placed after the previous line if this is added at the end of the JSON object. | ||
|
||
## Step 2: Remove API Key from Lambda Function Attributes | ||
|
||
1. Open the `amplify/backend/backend-config.json` file. | ||
2. Locate any JSON attribute arrays that include `GraphQLAPIKeyOutput`. | ||
3. Modify the arrays by removing the `GraphQLAPIKeyOutput` entry. For example: | ||
|
||
* Change this: | ||
|
||
```json title="amplify/backend/backend-config.json" | ||
{ | ||
"attributes": [ | ||
"GraphQLAPIIdOutput", | ||
"GraphQLAPIEndpointOutput", | ||
"GraphQLAPIKeyOutput" | ||
] | ||
} | ||
``` | ||
|
||
* To this: | ||
|
||
```json title="amplify/backend/backend-config.json" | ||
{ | ||
"attributes": [ | ||
"GraphQLAPIIdOutput", | ||
"GraphQLAPIEndpointOutput" | ||
] | ||
} | ||
``` | ||
Perform this change for each Lambda function that utilizes the API. | ||
|
||
|
||
## Step 3: Apply the Changes | ||
|
||
1. Push the changes to the cloud: | ||
|
||
```terminal | ||
amplify push -y | ||
``` | ||
Once this process is complete, the API key should be removed from both the application and the associated Lambda functions. | ||
|
||
## Step 4: Restore the API Key | ||
|
||
1. Remove the `CreateAPIKey: 0` entry from `amplify/backend/api/<apiName>/parameters.json`. | ||
2. Push the changes to restore the API key to the application: | ||
|
||
```terminal | ||
amplify push -y | ||
``` | ||
After this step, the API key should be restored to the application but will not be associated with the Lambda functions. | ||
|
||
|
||
## Step 5: Update Lambda Function Resources | ||
|
||
1. Use the following command to update each Lambda function that was previously associated with the API: | ||
|
||
```terminal | ||
amplify update function | ||
``` | ||
2. Follow the prompts to remove the API from the Lambda’s resources. | ||
3. Use the same command to restore the API to each Lambda function: | ||
|
||
```terminal | ||
amplify update function | ||
``` | ||
4. Finally, push the changes to apply them: | ||
|
||
```terminal | ||
amplify push -y | ||
``` | ||
This should complete the process and resolve the "API Key Not Found" issue. |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.