Skip to content

Commit a0baf31

Browse files
committed
Merge remote-tracking branch 'upstream/main' into add-auth-example-entra-id-saml
2 parents 5caf3d9 + 2d26d01 commit a0baf31

File tree

12 files changed

+189
-252
lines changed

12 files changed

+189
-252
lines changed

src/pages/[platform]/build-a-backend/add-aws-services/logging/set-up-logging/index.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,11 +113,11 @@ The `<log-group-name>` and `<region>` configured in the CDK construct will be us
113113
- `<amplify-authenticated-role-name>` and `<amplify-unauthenticated-role-name>` are Amplify roles created as part of Amplify Auth configuration via Amplify CLI.
114114

115115
```ts
116+
import * as path from "node:path"
116117
import * as cdk from "aws-cdk-lib"
117-
import { Construct } from "constructs"
118118
import * as logs from "aws-cdk-lib/aws-logs"
119-
import * as path from "path"
120119
import * as iam from "aws-cdk-lib/aws-iam"
120+
import { Construct } from "constructs"
121121

122122
export class RemoteLoggingConstraintsConstruct extends Construct {
123123
constructor(scope: Construct, id: string, props: RemoteLoggingConstraintProps) {

src/pages/[platform]/build-a-backend/add-aws-services/predictions/set-up-predictions/index.mdx

Lines changed: 9 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,6 @@ export function getStaticProps() {
2525
};
2626
}
2727

28-
### Set up the backend
29-
3028
To enable Predictions we need to set up the appropriate IAM policy for Roles in your Cognito Identity Pool in order to use an appropriate feature. Additionally, we need to use the ```addOutput``` method to patch the custom Predictions resource to the expected output configuration.
3129

3230
<Callout informational>
@@ -38,11 +36,9 @@ To learn more, check the docs of [Amazon Translate](https://docs.aws.amazon.com/
3836

3937

4038
```ts title="amplify/backend.ts"
41-
39+
import { PolicyStatement } from "aws-cdk-lib/aws-iam";
4240
import { defineBackend } from "@aws-amplify/backend";
4341
import { auth } from "./auth/resource";
44-
import { Stack } from "aws-cdk-lib";
45-
import { PolicyStatement } from "aws-cdk-lib/aws-iam";
4642

4743
const backend = defineBackend({
4844
auth,
@@ -88,24 +84,21 @@ backend.addOutput({
8884
targetLanguage: "es",
8985
},
9086
proxy: false,
91-
region: Stack.of(backend.auth.resources.unauthenticatedUserIamRole)
92-
.region,
87+
region: backend.auth.stack.region,
9388
},
9489
speechGenerator: {
9590
defaults: {
9691
voiceId: "Ivy",
9792
},
9893
proxy: false,
99-
region: Stack.of(backend.auth.resources.unauthenticatedUserIamRole)
100-
.region,
94+
region: backend.auth.stack.region,
10195
},
10296
transcription: {
10397
defaults: {
10498
language: "en-US",
10599
},
106100
proxy: false,
107-
region: Stack.of(backend.auth.resources.unauthenticatedUserIamRole)
108-
.region,
101+
region: backend.auth.stack.region,
109102
},
110103
},
111104
identify: {
@@ -116,24 +109,21 @@ backend.addOutput({
116109
},
117110
celebrityDetectionEnabled: true,
118111
proxy: false,
119-
region: Stack.of(backend.auth.resources.unauthenticatedUserIamRole)
120-
.region,
112+
region: backend.auth.stack.region,
121113
},
122114
identifyLabels: {
123115
defaults: {
124116
type: "ALL",
125117
},
126118
proxy: false,
127-
region: Stack.of(backend.auth.resources.unauthenticatedUserIamRole)
128-
.region,
119+
region: backend.auth.stack.region,
129120
},
130121
identifyText: {
131122
defaults: {
132123
format: "ALL",
133124
},
134125
proxy: false,
135-
region: Stack.of(backend.auth.resources.unauthenticatedUserIamRole)
136-
.region,
126+
region: backend.auth.stack.region,
137127
},
138128
},
139129
interpret: {
@@ -142,17 +132,14 @@ backend.addOutput({
142132
type: "ALL",
143133
},
144134
proxy: false,
145-
region: Stack.of(backend.auth.resources.unauthenticatedUserIamRole)
146-
.region,
135+
region: backend.auth.stack.region,
147136
},
148137
},
149138
},
150139
},
151140
});
152-
153-
154-
155141
```
142+
156143
## Install Amplify Libraries
157144

158145
To install the Amplify library to use predictions features, run the following commands in your project's root folder:

src/pages/[platform]/build-a-backend/data/connect-to-existing-data-sources/connect-external-ddb-table/index.mdx

Lines changed: 16 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -481,19 +481,18 @@ To delete your external DynamoDB table, you can navigate to the AppSync console
481481
[Reference](https://docs.aws.amazon.com/appsync/latest/devguide/js-resolver-reference-dynamodb.html#js-aws-appsync-resolver-reference-dynamodb-getitem) - The `GetItem` request lets you tell the AWS AppSync DynamoDB function to make a `GetItem` request to DynamoDB, and enables you to specify:
482482
483483
- The key of the item in DynamoDB
484-
485484
- Whether to use a consistent read or not
486485
487486
**Example:**
488487
489488
```js
490489
export function request(ctx) {
491-
const {foo, bar} = ctx.args
490+
const { foo, bar } = ctx.args;
492491
return {
493-
operation : "GetItem",
494-
key : util.dynamodb.toMapValues({foo, bar}),
495-
consistentRead : true
496-
}
492+
operation: 'GetItem',
493+
key: util.dynamodb.toMapValues({ foo, bar }),
494+
consistentRead: true
495+
};
497496
}
498497
```
499498
@@ -502,21 +501,20 @@ export function request(ctx) {
502501
[PutItem](https://docs.aws.amazon.com/appsync/latest/devguide/js-resolver-reference-dynamodb.html#js-aws-appsync-resolver-reference-dynamodb-putitem) - The `PutItem` request mapping document lets you tell the AWS AppSync DynamoDB function to make a `PutItem` request to DynamoDB, and enables you to specify the following:
503502
504503
- The key of the item in DynamoDB
505-
506504
- The full contents of the item (composed of key and attributeValues)
507-
508505
- Conditions for the operation to succeed
509506
510507
**Example:**
511508
512509
```js
513510
import { util } from '@aws-appsync/utils';
511+
514512
export function request(ctx) {
515-
const { foo, bar, ...values} = ctx.args
513+
const { foo, bar, ...values } = ctx.args;
516514
return {
517515
operation: 'PutItem',
518-
key: util.dynamodb.toMapValues({foo, bar}),
519-
attributeValues: util.dynamodb.toMapValues(values),
516+
key: util.dynamodb.toMapValues({ foo, bar }),
517+
attributeValues: util.dynamodb.toMapValues(values)
520518
};
521519
}
522520
```
@@ -526,15 +524,14 @@ export function request(ctx) {
526524
[UpdateItem](https://docs.aws.amazon.com/appsync/latest/devguide/js-resolver-reference-dynamodb.html#js-aws-appsync-resolver-reference-dynamodb-updateitem) - The `UpdateItem` request enables you to tell the AWS AppSync DynamoDB function to make a `UpdateItem` request to DynamoDB and allows you to specify the following:
527525
528526
- The key of the item in DynamoDB
529-
530527
- An update expression describing how to update the item in DynamoDB
531-
532528
- Conditions for the operation to succeed
533529
534530
**Example:**
535531
536532
```js
537533
import { util } from '@aws-appsync/utils';
534+
538535
export function request(ctx) {
539536
const { id } = ctx.args;
540537
return {
@@ -543,8 +540,8 @@ export function request(ctx) {
543540
update: {
544541
expression: 'ADD #voteField :plusOne, version :plusOne',
545542
expressionNames: { '#voteField': 'upvotes' },
546-
expressionValues: { ':plusOne': { N: 1 } },
547-
},
543+
expressionValues: { ':plusOne': { N: 1 } }
544+
}
548545
};
549546
}
550547
```
@@ -554,17 +551,17 @@ export function request(ctx) {
554551
[DeleteItem](https://docs.aws.amazon.com/appsync/latest/devguide/js-resolver-reference-dynamodb.html#js-aws-appsync-resolver-reference-dynamodb-deleteitem) - The `DeleteItem` request lets you tell the AWS AppSync DynamoDB function to make a `DeleteItem` request to DynamoDB, and enables you to specify the following:
555552
556553
- The key of the item in DynamoDB
557-
558554
- Conditions for the operation to succeed
559555
560556
**Example:**
561557
562558
```js
563559
import { util } from '@aws-appsync/utils';
560+
564561
export function request(ctx) {
565562
return {
566563
operation: 'DeleteItem',
567-
key: util.dynamodb.toMapValues({ id: ctx.args.id }),
564+
key: util.dynamodb.toMapValues({ id: ctx.args.id })
568565
};
569566
}
570567
```
@@ -574,17 +571,11 @@ export function request(ctx) {
574571
[Query](https://docs.aws.amazon.com/appsync/latest/devguide/js-resolver-reference-dynamodb.html#js-aws-appsync-resolver-reference-dynamodb-query) - The Query request object lets you tell the AWS AppSync DynamoDB resolver to make a Query request to DynamoDB, and enables you to specify the following:
575572
576573
- Key expression
577-
578574
- Which index to use
579-
580575
- Any additional filter
581-
582576
- How many items to return
583-
584577
- Whether to use consistent reads
585-
586578
- query direction (forward or backward)
587-
588579
- Pagination token
589580
590581
**Example:**
@@ -598,9 +589,9 @@ export function request(ctx) {
598589
operation: 'Query',
599590
query: {
600591
expression: 'ownerId = :ownerId',
601-
expressionValues: util.dynamodb.toMapValues({ ':ownerId': owner }),
592+
expressionValues: util.dynamodb.toMapValues({ ':ownerId': owner })
602593
},
603-
index: 'owner-index',
594+
index: 'owner-index'
604595
};
605596
}
606597
```
@@ -609,15 +600,10 @@ export function request(ctx) {
609600
[Scan](https://docs.aws.amazon.com/appsync/latest/devguide/js-resolver-reference-dynamodb.html#js-aws-appsync-resolver-reference-dynamodb-scan) - The `Scan` request lets you tell the AWS AppSync DynamoDB function to make a `Scan` request to DynamoDB, and enables you to specify the following:
610601
611602
- A filter to exclude results
612-
613603
- Which index to use
614-
615604
- How many items to return
616-
617605
- Whether to use consistent reads
618-
619606
- Pagination token
620-
621607
- Parallel scans
622608
623609
**Example:**

src/pages/[platform]/build-a-backend/data/custom-business-logic/connect-amazon-rekognition/index.mdx

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -75,12 +75,10 @@ export const storage = defineStorage({
7575
To use the Amazon Rekognition service, you need to add Amazon Rekognition as an HTTP Data Source and configure the proper IAM policy for Lambda to effectively utilize the desired feature and grant permission to access the storage. In this case, you can add the `rekognition:DetectText` and `rekognition:DetectLabels` actions to the policy. Update the `amplify/backend.ts` file as shown below.
7676

7777
```ts title= "amplify/backend.ts"
78-
78+
import { PolicyStatement } from 'aws-cdk-lib/aws-iam';
7979
import { defineBackend } from '@aws-amplify/backend';
8080
import { auth } from './auth/resource';
8181
import { data } from './data/resource';
82-
import { Stack } from 'aws-cdk-lib';
83-
import { PolicyStatement } from 'aws-cdk-lib/aws-iam';
8482
import { storage } from './storage/resource';
8583

8684
const backend = defineBackend({
@@ -89,19 +87,17 @@ const backend = defineBackend({
8987
storage
9088
});
9189

92-
const dataStack = Stack.of(backend.data)
93-
9490
// Set environment variables for the S3 Bucket name
9591
backend.data.resources.cfnResources.cfnGraphqlApi.environmentVariables = {
9692
S3_BUCKET_NAME: backend.storage.resources.bucket.bucketName,
9793
};
9894

9995
const rekognitionDataSource = backend.data.addHttpDataSource(
10096
"RekognitionDataSource",
101-
`https://rekognition.${dataStack.region}.amazonaws.com`,
97+
`https://rekognition.${backend.data.stack.region}.amazonaws.com`,
10298
{
10399
authorizationConfig: {
104-
signingRegion: dataStack.region,
100+
signingRegion: backend.data.stack.region,
105101
signingServiceName: "rekognition",
106102
},
107103
}

src/pages/[platform]/build-a-backend/data/custom-business-logic/connect-amazon-translate/index.mdx

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -60,24 +60,21 @@ npm add @aws-sdk/client-translate
6060

6161
```ts title="amplify/backend.ts"
6262
import { defineBackend } from '@aws-amplify/backend';
63-
import { auth } from './auth/resource';
64-
import { data } from "./data/resource";
65-
import { Stack } from 'aws-cdk-lib';
6663
import { PolicyStatement } from 'aws-cdk-lib/aws-iam';
64+
import { auth } from './auth/resource';
65+
import { data } from './data/resource';
6766

6867
const backend = defineBackend({
6968
auth,
7069
data
7170
});
7271

73-
const dataStack = Stack.of(backend.data)
74-
7572
const translateDataSource = backend.data.addHttpDataSource(
7673
"TranslateDataSource",
77-
`https://translate.${dataStack.region}.amazonaws.com`,
74+
`https://translate.${backend.data.stack.region}.amazonaws.com`,
7875
{
7976
authorizationConfig: {
80-
signingRegion: dataStack.region,
77+
signingRegion: backend.data.stack.region,
8178
signingServiceName: "translate",
8279
},
8380
}

0 commit comments

Comments
 (0)