Skip to content

Commit 9b77d27

Browse files
authored
update reference auth with groups (#8234)
* update reference auth with groups
1 parent 9f56b87 commit 9b77d27

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

cspell.json

+1
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,7 @@
247247
"aws-sdk-ios",
248248
"aws.cognito.signin.user.admin",
249249
"aws",
250+
"Authadmin",
250251
"AWSAPI",
251252
"AWSAPIGateway",
252253
"AWSAPIPlugin",

src/pages/[platform]/build-a-backend/auth/use-existing-cognito-resources/index.mdx

+18
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,24 @@ export const auth = referenceAuth({
150150
});
151151
```
152152

153+
Additionally, you can also use the `groups` property to reference groups in your user pool. This is useful if you want to work with groups in your application and provide access to resources such as storage based on group membership.
154+
155+
```ts title="amplify/auth/resource.ts"
156+
import { referenceAuth } from '@aws-amplify/backend';
157+
import { getUser } from "../functions/get-user/resource";
158+
159+
export const auth = referenceAuth({
160+
userPoolId: 'us-east-1_xxxx',
161+
identityPoolId: 'us-east-1:b57b7c3b-9c95-43e4-9266-xxxx',
162+
authRoleArn: 'arn:aws:iam::xxxx:role/amplify-xxxx-mai-amplifyAuthauthenticatedU-xxxx',
163+
unauthRoleArn: 'arn:aws:iam::xxxx:role/amplify-xxxx-mai-amplifyAuthunauthenticate-xxxx',
164+
userPoolClientId: 'xxxx',
165+
groups: {
166+
admin: "arn:aws:iam::xxxx:role/amplify-xxxx-mai-amplifyAuthadminGroupRole-xxxx",
167+
},
168+
});
169+
```
170+
153171
In a team setting you may want to reference a different set of auth resources depending on the deployment context. For instance if you have a `staging` branch that should reuse resources from a separate "staging" environment compared to a `production` branch that should reuse resources from the separate "production" environment. In this case we recommend using environment variables.
154172

155173
```ts title="amplify/auth/resource.ts"

0 commit comments

Comments
 (0)