Skip to content

Commit b0d5424

Browse files
committed
chore: mid work
1 parent 52e70b5 commit b0d5424

File tree

1 file changed

+36
-4
lines changed

1 file changed

+36
-4
lines changed

GEN2_MIGRATION_GUIDE.md

Lines changed: 36 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -129,9 +129,9 @@ environment variables and give it the necessary permissions.
129129
```
130130

131131
```diff
132-
+ backend.<function-friendly-name>.addEnvironment('API_PRODUCTCATALOG_GRAPHQLAPIKEYOUTPUT', backend.data.apiKey!)
133-
+ backend.<function-friendly-name>.addEnvironment('API_PRODUCTCATALOG_GRAPHQLAPIENDPOINTOUTPUT', backend.data.graphqlUrl)
134-
+ backend.<function-friendly-name>.addEnvironment('API_PRODUCTCATALOG_GRAPHQLAPIIDOUTPUT', backend.data.apiId)
132+
+ backend.<function-friendly-name>.addEnvironment('API_<API_NAME_CAPS>_GRAPHQLAPIKEYOUTPUT', backend.data.apiKey!)
133+
+ backend.<function-friendly-name>.addEnvironment('API_<API_NAME_CAPS>_GRAPHQLAPIENDPOINTOUTPUT', backend.data.graphqlUrl)
134+
+ backend.<function-friendly-name>.addEnvironment('API_<API_NAME_CAPS>_GRAPHQLAPIIDOUTPUT', backend.data.apiId)
135135

136136
+ backend.<function-friendly-name>.resources.lambda.addToRolePolicy(new aws_iam.PolicyStatement({
137137
+ effect: aws_iam.Effect.ALLOW,
@@ -158,7 +158,39 @@ This is required in order for your Gen1 environment to keep functioning correctl
158158

159159
> See [GraphQL types protected with the IAM provider](#graphql-types-protected-by-the-iam-auth-provider) for more details.
160160
161-
#### 2.3 Post Generate | Function Secrets
161+
#### 2.3 Post Generate | Stroage Function Access
162+
163+
If your function needs to access the DynamoDB table configured as part of your storage category you need to explicitly
164+
provide it with the appropriate environment variables and give it the necessary permissions.
165+
166+
**Edit in `./amplify/backend.ts`:**
167+
168+
```diff
169+
+ backend.myfunction.addEnvironment('STORAGE_MYTABLE_ARN', mytable.tableArn);
170+
+ backend.myfunction.addEnvironment('STORAGE_MYTABLE_NAME', mytable.tableName);
171+
+ backend.myfunction.addEnvironment('STORAGE_MYTABLE_STREAMARN', mytable.tableStreamArn!);
172+
+ mytable.grantReadData(backend.myfunction.resources.lambda);
173+
```
174+
175+
> Where `myfunction` and `mytable` are the friendly names of the relevant function and table.
176+
177+
#### 2.4 Post Generate | Api Function Trigger
178+
179+
If your function is triggered based on model updates you need to explicitly create the trigger
180+
and grant the function the necessary permissions.
181+
182+
**Edit in `./amplify/backend.ts`:**
183+
184+
```diff
185+
+ const commentsTable = backend.data.resources.tables['Comment'];
186+
+ backend.myfunction.resources.lambda.addEventSource(new DynamoEventSource(commentsTable, { startingPosition: StartingPosition.LATEST }));
187+
+ commentsTable.grantStreamRead(backend.myfunction.resources.lambda.role!);
188+
+ commentsTable.grantTableListStreams(backend.myfunction.resources.lambda.role!);
189+
```
190+
191+
> Where `myfunction` is the function friendly name and `Comment` is the model name.
192+
193+
#### 2.5 Post Generate | Function Secrets
162194

163195
If your function was configured with a secret value, you must first recreate the secret using the amplify console.
164196

0 commit comments

Comments
 (0)