Skip to content

Commit 75b1632

Browse files
committed
Merge remote-tracking branch 'upstream/main' into add-auth-example-entra-id-saml
2 parents 7970826 + fadf3ca commit 75b1632

File tree

13 files changed

+384
-176
lines changed

13 files changed

+384
-176
lines changed

src/directory/directory.mjs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -390,6 +390,9 @@ export const directory = {
390390
{
391391
path: 'src/pages/[platform]/build-a-backend/functions/streaming-logs/index.mdx'
392392
},
393+
{
394+
path: 'src/pages/[platform]/build-a-backend/functions/add-lambda-layers/index.mdx'
395+
},
393396
{
394397
path: 'src/pages/[platform]/build-a-backend/functions/grant-access-to-other-resources/index.mdx'
395398
},
@@ -685,6 +688,9 @@ export const directory = {
685688
{
686689
path: 'src/pages/[platform]/build-a-backend/add-aws-services/custom-resources/index.mdx'
687690
},
691+
{
692+
path: 'src/pages/[platform]/build-a-backend/add-aws-services/tagging-resources/index.mdx'
693+
},
688694
{
689695
path: 'src/pages/[platform]/build-a-backend/add-aws-services/overriding-resources/index.mdx'
690696
}

src/fragments/start/getting-started/reactnative/setup.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
## Create a new project
22

3-
To get started, initialize a new React Native project.
3+
To get started, initialize a new React Native project for Android or iOS.
44

55
<BlockSwitcher>
66
<Block name="Expo CLI">

src/pages/[platform]/build-a-backend/add-aws-services/overriding-resources/index.mdx

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -129,28 +129,4 @@ The `auth.resources.cfnResources.cfnUserPool` property in the above example dire
129129

130130
This is different from `auth.resources.userPool` in the first example, which is an [L2 CDK construct](https://docs.aws.amazon.com/cdk/v2/guide/constructs.html#constructs_using). These are constructs that provide a convenient interface around several related L1 constructs.
131131

132-
## Example - Add tags to resources
133-
134-
```ts title="amplify/backend.ts"
135-
import { defineBackend } from '@aws-amplify/backend';
136-
import { auth } from './auth/resource';
137-
import { data } from './data/resource';
138-
139-
const backend = defineBackend({
140-
auth,
141-
data
142-
});
143-
144-
backend.data.resources.cfnResources.cfnGraphqlApi.addPropertyOverride('Tags', [
145-
{
146-
Key: 'graphqlapi-tag-1',
147-
Value: 'graphql-tag-value-1'
148-
},
149-
{
150-
Key: 'graphqlapi-tag-2',
151-
Value: 'graphql-tag-value-2'
152-
}
153-
]);
154-
```
155-
156132
For situations where you need even more customization of your app backend, see the documentation on [custom resources](/[platform]/build-a-backend/add-aws-services/custom-resources).
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
import { getCustomStaticPath } from '@/utils/getCustomStaticPath';
2+
3+
export const meta = {
4+
title: 'Tagging resources',
5+
description: 'Decorate resources with tags for categorization.',
6+
platforms: [
7+
'android',
8+
'angular',
9+
'flutter',
10+
'javascript',
11+
'nextjs',
12+
'react',
13+
'react-native',
14+
'swift',
15+
'vue'
16+
],
17+
};
18+
19+
export async function getStaticPaths() {
20+
return getCustomStaticPath(meta.platforms);
21+
}
22+
23+
export function getStaticProps(context) {
24+
return {
25+
props: {
26+
platform: context.params.platform,
27+
meta
28+
}
29+
};
30+
}
31+
32+
Tags are a key-value pair that are applied to AWS resources to hold metadata. Tags are often used to decorate resources with metadata that helps categorize resources for billing or viewing purposes. Learn more about tags by visiting the [AWS documentation for best practices for tagging resources](https://docs.aws.amazon.com/whitepapers/latest/tagging-best-practices/what-are-tags.html).
33+
34+
Amplify applies the following tags by default:
35+
36+
| Deployment type | Tag key | Tag value |
37+
|-----------------|---------------------------|--------------------------|
38+
| sandbox | `created-by` | `amplify` |
39+
| sandbox | `amplify:deployment-type` | `sandbox` |
40+
| branch | `created-by` | `amplify` |
41+
| branch | `amplify:deployment-type` | `branch` |
42+
| branch | `amplify:app-id` | `<your-amplify-app-id>` |
43+
| branch | `amplify:branch-name` | `<your-git-branch-name>` |
44+
45+
In your Amplify backend you can use the [`Tags`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.Tags.html) class from the [AWS Cloud Development Kit (CDK)](https://docs.aws.amazon.com/cdk/latest/guide/home.html) to apply tags at the root level, which then cascades to child resources.
46+
47+
```ts title="amplify/backend.ts"
48+
import { Tags } from 'aws-cdk-lib';
49+
import { defineBackend } from '@aws-amplify/backend';
50+
import { auth } from './auth/resource';
51+
import { data } from './data/resource';
52+
53+
/**
54+
* @see https://docs.amplify.aws/react/build-a-backend/ to add storage, functions, and more
55+
*/
56+
const backend = defineBackend({
57+
auth,
58+
data
59+
});
60+
61+
const tags = Tags.of(backend.stack);
62+
// add a new tag
63+
tags.add('my-key', 'my-value');
64+
// remove tags
65+
tags.remove('my-key');
66+
```
67+

src/pages/[platform]/build-a-backend/auth/manage-users/manage-passwords/index.mdx

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -512,27 +512,35 @@ export const auth = defineAuth({
512512
513513
## Override default password policy
514514
515-
You can customize the password format acceptable by your auth backend. By default your password policy is set to the following:
515+
By default your password policy is set to the following:
516516
517517
- `MinLength`: 8 characters
518518
- `requireLowercase`: true
519519
- `requireUppercase`: true
520-
- `requireDigits`: true
520+
- `requireNumbers`: true
521+
- `requireSymbols`: true
521522
- `tempPasswordValidity`: 3 days
522523
524+
You can customize the password format acceptable by your auth resource by modifying the underlying `cfnUserPool` resource:
525+
523526
```ts title="amplify/backend.ts"
524-
// amplify/backend.ts
525527
import { defineBackend } from '@aws-amplify/backend';
526528
import { auth } from './auth/resource';
527-
import { data } from './data/resource';
528529
529530
const backend = defineBackend({
530531
auth,
531-
data
532532
});
533-
534-
// extract L1 UserPool construct
533+
// extract L1 CfnUserPool resources
535534
const { cfnUserPool } = backend.auth.resources.cfnResources;
536-
// from the CDK use `addPropertyOverride` to modify properties directly
537-
cfnUserPool.addPropertyOverride('Policies.PasswordPolicy.MinimumLength', 32);
535+
// modify cfnUserPool policies directly
536+
cfnUserPool.policies = {
537+
passwordPolicy: {
538+
minimumLength: 32,
539+
requireLowercase: true,
540+
requireNumbers: true,
541+
requireSymbols: true,
542+
requireUppercase: true,
543+
temporaryPasswordValidityDays: 20,
544+
},
545+
};
538546
```

src/pages/[platform]/build-a-backend/auth/moving-to-production/index.mdx

Lines changed: 41 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -44,33 +44,50 @@ To get started with Amazon SES in production, you must first [request production
4444

4545
After you have configured your account for production access and have verified your _sender_ email, you can configure your Cognito user pool to send emails using the verified sender:
4646

47-
```ts title="amplify/backend.ts"
48-
import { Stack } from "aws-cdk-lib/core"
49-
import { EmailIdentity } from "aws-cdk-lib/aws-ses"
50-
import { defineBackend } from "@aws-amplify/backend"
51-
import { auth } from "./auth/resource"
52-
53-
const backend = defineBackend({
54-
auth,
47+
```ts title="amplify/auth/resource.ts"
48+
import { defineAuth } from "@aws-amplify/backend"
49+
50+
/**
51+
* Define and configure your auth resource
52+
* @see https://docs.amplify.aws/react/build-a-backend/auth
53+
*/
54+
export const auth = defineAuth({
55+
loginWith: {
56+
email: true,
57+
},
58+
senders: {
59+
email: {
60+
// configure using the email registered and verified in Amazon SES
61+
fromEmail: "[email protected]",
62+
},
63+
},
5564
})
56-
57-
const { cfnUserPool } = backend.auth.resources.cfnResources
58-
const authStack = Stack.of(cfnUserPool)
59-
60-
const email = EmailIdentity.fromEmailIdentityName(
61-
authStack,
62-
"EmailIdentity",
63-
// your email configured for use in SES
64-
process.env.EMAIL
65-
)
66-
67-
cfnUserPool.emailConfiguration = {
68-
emailSendingAccount: "DEVELOPER",
69-
sourceArn: email.emailIdentityArn,
70-
}
7165
```
7266

73-
Now when emails are sent on new user sign-ups, password resets, etc., the sending account will be your verified email.
67+
Now when emails are sent on new user sign-ups, password resets, etc., the sending account will be your verified email! To customize further, you can change the display name of the sender, or optionally apply a custom address for your users to reply.
68+
69+
```ts title="amplify/auth/resource.ts"
70+
import { defineAuth } from "@aws-amplify/backend"
71+
72+
/**
73+
* Define and configure your auth resource
74+
* @see https://docs.amplify.aws/react/build-a-backend/auth
75+
*/
76+
export const auth = defineAuth({
77+
loginWith: {
78+
email: true,
79+
},
80+
senders: {
81+
email: {
82+
fromEmail: "[email protected]",
83+
// highlight-start
84+
fromName: "MyApp",
85+
replyTo: "[email protected]"
86+
// highlight-end
87+
},
88+
},
89+
})
90+
```
7491

7592
## SMS
7693

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
import { getCustomStaticPath } from '@/utils/getCustomStaticPath';
2+
3+
export const meta = {
4+
title: 'Lambda Layers',
5+
description:
6+
'Learn how to add layers to your function',
7+
platforms: [
8+
'android',
9+
'angular',
10+
'flutter',
11+
'javascript',
12+
'nextjs',
13+
'react',
14+
'react-native',
15+
'swift',
16+
'vue'
17+
]
18+
};
19+
20+
export function getStaticPaths() {
21+
return getCustomStaticPath(meta.platforms);
22+
}
23+
24+
export function getStaticProps() {
25+
return {
26+
props: {
27+
meta
28+
}
29+
};
30+
}
31+
32+
Amplify offers the ability to add layers to your Functions which contain your library dependencies. To get started, specify the `layers` property in `defineFunction`:
33+
34+
```ts title="amplify/functions/my-function/resource.ts"
35+
import { defineFunction } from "@aws-amplify/backend";
36+
37+
export const myFunction = defineFunction({
38+
name: "my-function",
39+
layers: {
40+
"@aws-lambda-powertools/logger":
41+
"arn:aws:lambda:us-east-1:094274105915:layer:AWSLambdaPowertoolsTypeScriptV2:12",
42+
},
43+
});
44+
```
45+
46+
The Lambda layer is represented by an object of key/value pairs where the key is the module name that is exported from your layer and the value is the ARN of the layer. The key (module name) is used to externalize the module dependency so it doesn't get bundled with your lambda function. A maximum of 5 layers can be attached to a function, and they must be in the same region as the function.
47+
48+
Then use the locally installed module in the function handler:
49+
```ts title="amplify/functions/my-function/handler.ts"
50+
import { Logger } from "@aws-lambda-powertools/logger";
51+
import type { Handler } from "aws-lambda";
52+
53+
const logger = new Logger({ serviceName: "serverlessAirline" });
54+
55+
export const handler: Handler = async (event, context) => {
56+
logger.info("Hello World");
57+
};
58+
```
59+
60+
For further information on creating and managing your layers refer to [AWS documentation for Lambda layers](https://docs.aws.amazon.com/lambda/latest/dg/chapter-layers.html)
61+

0 commit comments

Comments
 (0)