Skip to content

Commit 9c6554b

Browse files
authored
Merge branch 'main' into gen1-recommend-parseAmplifyConfig
2 parents 2b277ed + acbc7fb commit 9c6554b

File tree

8 files changed

+172
-10
lines changed

8 files changed

+172
-10
lines changed

cspell.json

+1
Original file line numberDiff line numberDiff line change
@@ -641,6 +641,7 @@
641641
"frontend",
642642
"frontends",
643643
"fullheight",
644+
"fullname",
644645
"Gapi",
645646
"ge",
646647
"geo_point",

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ Import and load the configuration file in your app. It is recommended you add th
155155
```ts title="src/main.ts"
156156
import { Amplify } from "aws-amplify";
157157
import { parseAmplifyConfig } from "aws-amplify/utils";
158-
import outputs from './amplify_outputs.json';
158+
import outputs from '../amplify_outputs.json';
159159

160160
const amplifyConfig = parseAmplifyConfig(outputs);
161161

src/pages/[platform]/build-a-backend/auth/concepts/external-identity-providers/index.mdx

+7-5
Original file line numberDiff line numberDiff line change
@@ -314,11 +314,13 @@ export const auth = defineAuth({
314314

315315
### Attribute mapping
316316

317-
You can map which attributes are mapped between your external identity provider and your users created in Cognito. We will be able to have the best level of protection for developers if we ensure that attribute mappings that would not work are called out by the type system.
317+
Identity provider (IdP) services store user attributes in different formats. When using external IdPs with Amazon Cognito user pools, attribute mapping allows you to standardize these varying formats into a consistent schema.
318318

319-
<Callout>
319+
Learn more about [mapping IdP attributes to user pool profiles and tokens](https://docs.aws.amazon.com/cognito/latest/developerguide/cognito-user-pools-specifying-attribute-mapping.html).
320+
321+
<Callout warning>
320322

321-
If you specify an attribute in your authentication resource as required, and it is not allowed for your external providers, signing in with that external provider will cause an error.
323+
**Note:** When a federated user signs in to your application, a mapping must be present for each attribute that your user pool requires. Additionally, you must also ensure that the target of each attribute mapping is mutable. Amazon Cognito will attempt to update each mapped attribute when a user signs in regardless of whether the latest value already matches the existing information. If these criteria are not met, Amazon Cognito will return an error and the sign in attempt will fail.
322324

323325
</Callout>
324326

@@ -330,7 +332,7 @@ import { defineAuth } from '@aws-amplify/backend';
330332
export const auth = defineAuth({
331333
loginWith: {
332334
email: true,
333-
externalAuthProviders: {
335+
externalProviders: {
334336
loginWithAmazon: {
335337
clientId: secret('LOGINWITHAMAZON_CLIENT_ID'),
336338
clientSecret: secret('LOGINWITHAMAZON_CLIENT_SECRET'),
@@ -359,7 +361,7 @@ import { defineAuth } from '@aws-amplify/backend';
359361
export const auth = defineAuth({
360362
loginWith: {
361363
email: true,
362-
externalAuthProviders: {
364+
externalProviders: {
363365
loginWithAmazon: {
364366
clientId: secret('LOGINWITHAMAZON_CLIENT_ID'),
365367
clientSecret: secret('LOGINWITHAMAZON_CLIENT_SECRET'),

src/pages/[platform]/build-a-backend/auth/concepts/user-attributes/index.mdx

+97
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,103 @@ export const auth = defineAuth({
6363

6464
User attributes are defined as [Cognito Standard Attributes](https://docs.aws.amazon.com/cognito/latest/developerguide/user-pool-settings-attributes.html#cognito-user-pools-standard-attributes). Attributes can be configured to be _required_ for user sign-up in addition to whether the values are _mutable_. When configuring your resource to allow your users to login with `email`, an email must be specified for user sign-up and cannot be changed later. However additional attributes can be configured to be optional, and mutable after sign-up.
6565

66+
```ts title="amplify/auth/resource.ts"
67+
import { defineAuth } from "@aws-amplify/backend";
68+
69+
export const auth = defineAuth({
70+
loginWith: {
71+
email: true,
72+
},
73+
userAttributes: {
74+
// Maps to Cognito standard attribute 'address'
75+
address: {
76+
mutable: true,
77+
required: true,
78+
},
79+
// Maps to Cognito standard attribute 'birthdate'
80+
birthdate: {
81+
mutable: true,
82+
required: false,
83+
},
84+
// Maps to Cognito standard attribute 'email'
85+
email: {
86+
mutable: true,
87+
required: true,
88+
},
89+
// Maps to Cognito standard attribute 'family_name'
90+
familyName: {
91+
mutable: true,
92+
required: false,
93+
},
94+
// Maps to Cognito standard attribute 'gender'
95+
gender: {
96+
mutable: true,
97+
required: false,
98+
},
99+
// Maps to Cognito standard attribute 'given_name'
100+
givenName: {
101+
mutable: true,
102+
required: false,
103+
},
104+
// Maps to Cognito standard attribute 'locale'
105+
locale: {
106+
mutable: true,
107+
required: false,
108+
},
109+
// Maps to Cognito standard attribute 'middle_name'
110+
middleName: {
111+
mutable: true,
112+
required: false,
113+
},
114+
// Maps to Cognito standard attribute 'name'
115+
fullname: {
116+
mutable: true,
117+
required: false,
118+
},
119+
// Maps to Cognito standard attribute 'nickname'
120+
nickname: {
121+
mutable: true,
122+
required: false,
123+
},
124+
// Maps to Cognito standard attribute 'phone_number'
125+
phoneNumber: {
126+
mutable: true,
127+
required: false,
128+
},
129+
// Maps to Cognito standard attribute 'picture'
130+
profilePicture: {
131+
mutable: true,
132+
required: false,
133+
},
134+
// Maps to Cognito standard attribute 'preferred_username'
135+
preferredUsername: {
136+
mutable: true,
137+
required: false,
138+
},
139+
// Maps to Cognito standard attribute 'profile'
140+
profilePage: {
141+
mutable: true,
142+
required: false,
143+
},
144+
// Maps to Cognito standard attribute 'zoneinfo'
145+
timezone: {
146+
mutable: true,
147+
required: false,
148+
},
149+
// Maps to Cognito standard attribute 'updated_at'
150+
lastUpdateTime: {
151+
mutable: true,
152+
required: false,
153+
},
154+
// Maps to Cognito standard attribute 'website'
155+
website: {
156+
mutable: true,
157+
required: false,
158+
},
159+
},
160+
});
161+
```
162+
66163
## Custom attributes
67164

68165
In addition to the provided standard attributes, you can configure [Custom Attributes](https://docs.aws.amazon.com/cognito/latest/developerguide/user-pool-settings-attributes.html#user-pool-settings-custom-attributes). These are attributes that are typically unique to your use case, such as a tenant ID or a user's display name. Custom attributes are identified by the `custom:` prefix:

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

+32
Original file line numberDiff line numberDiff line change
@@ -510,6 +510,38 @@ safePrint(echoResponse.echo.content);
510510
```
511511

512512
</InlineFilter>
513+
## Supported Argument Types in Custom Operations
514+
515+
Custom operations can accept different types of arguments. Understanding these options helps define flexible and well-structured APIs.
516+
517+
### Defining Arguments in Custom Operations
518+
519+
When defining a custom operation, you can specify arguments using different types:
520+
521+
- **Scalar Fields**: Basic types such as `string`, `integer`, `float`, etc
522+
- **Custom Types**: Define inline `customType`
523+
- **Reference Types**: Use `a.ref()` to reference enums and custom types
524+
525+
```ts title="amplify/data/resource.ts"
526+
const schema = a.schema({
527+
Status: a.enum(['ACCEPTED', 'REJECTED']),
528+
529+
getPost: a
530+
.query()
531+
.arguments({
532+
// scalar field
533+
content: a.string(),
534+
// inline custom type
535+
config: a.customType({
536+
filter: a.string(),
537+
// reference to enum
538+
status: a.ref('Status')
539+
}),
540+
})
541+
.returns(a.string())
542+
.authorization(allow => [allow.authenticated()])
543+
});
544+
```
513545

514546
## Async function handlers
515547

src/pages/[platform]/build-a-backend/functions/streaming-logs/index.mdx

+10-4
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ export function getStaticProps(context) {
3030
};
3131
}
3232

33-
Amplify enables you to stream logs from your Function directly to your terminal while running [`ampx sandbox`](/[platform]/reference/cli-commands/#npx-ampx-sandbox). To get started, specify the `--stream-function-logs` option when starting sandbox:
33+
Amplify enables you to stream logs from your AWS Lambda functions directly to your terminal while running [`ampx sandbox`](/[platform]/reference/cli-commands/#npx-ampx-sandbox). To get started, specify the `--stream-function-logs` option when starting sandbox:
3434

3535
```bash title="Terminal" showLineNumbers={false}
3636
npx ampx sandbox --stream-function-logs
@@ -42,11 +42,17 @@ npx ampx sandbox --stream-function-logs
4242

4343
</Callout>
4444

45-
Streaming Function logs directly to your terminal enable faster debug iterations, and greater insight into your Functions' executions.
45+
Streaming function logs directly to your terminal enable faster debug iterations, and greater insight into your functions' executions.
4646

4747
## Filtering
4848

49-
By default, Amplify will stream all of your Functions' logs. If you wish to only stream a subset of Functions you can specify a filter by Function name or a regular expression for Function names. For example, if you have a collection of [Auth triggers](/[platform]/build-a-backend/auth/customize-auth-lifecycle/triggers/) where the Function names include "auth"
49+
By default, Amplify will stream all of your functions' logs. If you wish to only stream a subset of functions you can specify a filter by function name or a regular expression for function names. For example, if you have a collection of [Auth triggers](/[platform]/build-a-backend/auth/customize-auth-lifecycle/triggers/) where the function names include "auth".
50+
51+
<Callout info>
52+
53+
When working with more than 5 functions, we recommend using the `--logs-filter` flag to filter the log output to specific functions.
54+
55+
</Callout>
5056

5157
```bash title="Terminal" showLineNumbers={false}
5258
npx ampx sandbox --stream-function-logs --logs-filter auth
@@ -89,7 +95,7 @@ By default, Amplify will print logs to the terminal where sandbox is running, ho
8995
npx ampx sandbox --stream-function-logs --logs-out-file sandbox.log
9096
```
9197

92-
This can be combined with `--logs-filter` to create a log file of just your Auth-related Functions, for example:
98+
This can be combined with `--logs-filter` to create a log file of just your Auth-related functions, for example:
9399

94100
```bash title="Terminal" showLineNumbers={false}
95101
npx ampx sandbox --stream-function-logs --logs-filter auth --logs-out-file sandbox-auth.log

src/pages/[platform]/deploy-and-host/fullstack-branching/secrets-and-vars/index.mdx

+4
Original file line numberDiff line numberDiff line change
@@ -159,3 +159,7 @@ console.log('REACT_APP_TEST_VARIABLE', process.env.REACT_APP_TEST_VARIABLE);
159159
### Local environment
160160

161161
When working on your local machine, you must manually load the sandbox's environment variables. First, add the environment variable in your `.env.local` file. Then, a library such as [`@dotenvx/dotenvx`](https://www.npmjs.com/package/@dotenvx/dotenvx) can load the environment variables, which you can then reference with `process.env`.
162+
163+
```bash title="Terminal" showLineNumbers={false}
164+
npx dotenvx run --env-file=.env.local -- ampx sandbox
165+
```

src/pages/[platform]/reference/cli-commands/index.mdx

+20
Original file line numberDiff line numberDiff line change
@@ -332,6 +332,26 @@ npx ampx generate graphql-client-code --format modelgen --type-target angular
332332
| Modelgen | Amplify Flutter | `amplify codegen model` | `npx ampx generate graphql-client-code --format modelgen --model-target dart --out <path_to_flutter_project>/AmplifyModels` | `<path_to_flutter_project>/AmplifyModels` |
333333

334334

335+
## npx ampx generate schema-from-database
336+
337+
Generates typescript data schema from a SQL database.
338+
339+
### Options
340+
341+
- `--stack`(_string_) - A stack name that contains an Amplify backend.
342+
- `--branch` (_string_) - Name of the git branch being deployed.
343+
- `--app-id` (_string_) - The app id of the target Amplify app.
344+
- `--out`(_string_) - A path to directory where generated schema is written [default: `./amplify/data/schema.sql.ts`].
345+
- `--connection-uri-secret`(_string_) - Amplify secret name for the database connection uri.
346+
- `--ssl-cert-secret`(_string_) - Amplify secret name for the database ssl certificate.
347+
- `--profile`(_string_) - An AWS profile name.
348+
349+
### Usage
350+
351+
```bash title="Terminal" showLineNumbers={false}
352+
npx ampx generate schema-from-database --connection-uri-secret SQL_CONNECTION_STRING --out amplify/data/schema.sql.ts
353+
```
354+
335355
## npx ampx generate forms
336356

337357
Generate React form components derived from your backend data models for your frontend application to consume.

0 commit comments

Comments
 (0)