@@ -30,82 +30,83 @@ If you're encountering an "API Key Not Found" issue in your Amplify project, fol
30
30
31
31
## Step 1: Modify ` parameters.json ` to Remove API Key
32
32
33
- 1 . Navigate to the ` amplify/backend/api/<apiName>/parameters.json ` file in your project.
34
- 2 . Add the following line to the file:
33
+ 1 . Navigate to the ` amplify/backend/api/<apiName>/parameters.json ` file in your project.
34
+ 2 . Add the following line to the file:
35
35
36
- ``` tsx title="parameters.json"
37
- {
38
- " CreateAPIKey" : 0
39
- }
40
- ```
41
- Ensure that a comma is placed after the previous line if this is added at the end of the JSON object.
36
+ ``` json title="parameters.json"
37
+ {
38
+ "CreateAPIKey" : 0
39
+ }
40
+ ```
41
+ Ensure that a comma is placed after the previous line if this is added at the end of the JSON object.
42
42
43
43
## Step 2: Remove API Key from Lambda Function Attributes
44
44
45
- 1 . Open the ` amplify/backend/backend-config.json ` file.
46
- 2 . Locate any JSON attribute arrays that include ` GraphQLAPIKeyOutput ` .
47
- 3 . Modify the arrays by removing the ` GraphQLAPIKeyOutput ` entry. For example:
48
- * Change this:
49
-
50
- ``` tsx title="backend-config.json"
51
- {
52
- " attributes" : [
53
- " GraphQLAPIIdOutput" ,
54
- " GraphQLAPIEndpointOutput" ,
55
- " GraphQLAPIKeyOutput"
56
- ]
57
- }
58
- ```
59
-
60
- * To this:
61
-
62
- ``` tsx title="backend-config.json"
63
- {
64
- " attributes" : [
65
- " GraphQLAPIIdOutput" ,
66
- " GraphQLAPIEndpointOutput"
67
- ]
68
- }
69
- ```
70
- Perform this change for each Lambda function that utilizes the API.
45
+ 1 . Open the ` amplify/backend/backend-config.json ` file.
46
+ 2 . Locate any JSON attribute arrays that include ` GraphQLAPIKeyOutput ` .
47
+ 3 . Modify the arrays by removing the ` GraphQLAPIKeyOutput ` entry. For example:
48
+
49
+ * Change this:
50
+
51
+ ``` json title="backend-config.json"
52
+ {
53
+ "attributes" : [
54
+ " GraphQLAPIIdOutput" ,
55
+ " GraphQLAPIEndpointOutput" ,
56
+ " GraphQLAPIKeyOutput"
57
+ ]
58
+ }
59
+ ```
60
+
61
+ * To this:
62
+
63
+ ``` json title="backend-config.json"
64
+ {
65
+ "attributes" : [
66
+ " GraphQLAPIIdOutput" ,
67
+ " GraphQLAPIEndpointOutput"
68
+ ]
69
+ }
70
+ ```
71
+ Perform this change for each Lambda function that utilizes the API.
71
72
72
73
73
74
## Step 3: Apply the Changes
74
75
75
- 1 . Push the changes to the cloud:
76
+ 1 . Push the changes to the cloud:
76
77
77
- ``` sh
78
- amplify push -y
79
- ```
80
- Once this process is complete, the API key should be removed from both the application and the associated Lambda functions.
78
+ ``` sh
79
+ amplify push -y
80
+ ```
81
+ Once this process is complete, the API key should be removed from both the application and the associated Lambda functions.
81
82
82
83
## Step 4: Restore the API Key
83
84
84
- 1 . Remove the ` CreateAPIKey: 0 ` entry from ` amplify/backend/api/<apiName>/parameters.json ` .
85
- 2 . Push the changes to restore the API key to the application:
85
+ 1 . Remove the ` CreateAPIKey: 0 ` entry from ` amplify/backend/api/<apiName>/parameters.json ` .
86
+ 2 . Push the changes to restore the API key to the application:
86
87
87
- ``` sh
88
- amplify push -y
89
- ```
90
- After this step, the API key should be restored to the application but will not be associated with the Lambda functions.
88
+ ``` sh
89
+ amplify push -y
90
+ ```
91
+ After this step, the API key should be restored to the application but will not be associated with the Lambda functions.
91
92
92
93
93
94
## Step 5: Update Lambda Function Resources
94
95
95
- 1 . Use the following command to update each Lambda function that was previously associated with the API:
96
+ 1 . Use the following command to update each Lambda function that was previously associated with the API:
96
97
97
- ``` sh
98
- amplify update function
99
- ```
100
- 2 . Follow the prompts to remove the API from the Lambda’s resources.
101
- 3 . Use the same command to restore the API to each Lambda function:
98
+ ``` sh
99
+ amplify update function
100
+ ```
101
+ 2 . Follow the prompts to remove the API from the Lambda’s resources.
102
+ 3 . Use the same command to restore the API to each Lambda function:
102
103
103
- ``` sh
104
- amplify update function
105
- ```
106
- 4 . Finally, push the changes to apply them:
104
+ ``` sh
105
+ amplify update function
106
+ ```
107
+ 4 . Finally, push the changes to apply them:
107
108
108
- ``` sh
109
- amplify push -y
110
- ```
111
- This should complete the process and resolve the "API Key Not Found" issue.
109
+ ``` sh
110
+ amplify push -y
111
+ ```
112
+ This should complete the process and resolve the "API Key Not Found" issue.
0 commit comments