gpt4 book ai didi

amazon-web-services - 使用 CDK 添加 AWS Cognito 用户池角色

转载 作者:行者123 更新时间:2023-12-03 23:06:42 35 4
gpt4 key购买 nike

我已部署 https://github.com/aws-samples/amazon-elasticsearch-service-with-cognito到我的堆栈,并尝试添加 masterhttps://docs.aws.amazon.com/elasticsearch-service/latest/developerguide/fgac.html#fgac-walkthrough-iam 分组

所以我添加了以下https://github.com/aws-samples/amazon-elasticsearch-service-with-cognito/blob/master/lib/search-stack.ts#L50

diff --git a/lib/search-stack.ts b/lib/search-stack.ts
index 85de0c0..2493c92 100644
--- a/lib/search-stack.ts
+++ b/lib/search-stack.ts
@@ -3,7 +3,7 @@

import { Fn, Stack, Construct, StackProps, CfnParameter, CfnOutput } from '@aws-cdk/core';
import { CfnDomain } from '@aws-cdk/aws-elasticsearch';
-import { UserPoolAttribute, CfnUserPoolDomain, CfnIdentityPool, CfnIdentityPoolRoleAttachment, CfnUserPool } from '@aws-cdk/aws-cognito';
+import { UserPoolAttribute, CfnUserPoolDomain, CfnIdentityPool, CfnIdentityPoolRoleAttachment, CfnUserPool, CfnUserPoolGroup } from '@aws-cdk/aws-cognito';
import { Role, ManagedPolicy, ServicePrincipal, FederatedPrincipal } from '@aws-cdk/aws-iam';
import { CustomResource } from '@aws-cdk/aws-cloudformation';

@@ -55,6 +55,19 @@ export class SearchStack extends Stack {
}, "sts:AssumeRoleWithWebIdentity")
});

+ // create two groups, one for admins one for users
+
+ new CfnUserPoolGroup(this, "AdminsGroup", {
+ groupName: "master-user-group",
+ userPoolId: idPool.ref,
+
+ });
+
+ new CfnUserPoolGroup(this, "UsersGroup", {
+ groupName: "limited-user-group",
+ userPoolId: idPool.ref,
+ });
+
const esRole = new Role(this, "esRole", {
assumedBy: new ServicePrincipal('es.amazonaws.com'),
managedPolicies: [ManagedPolicy.fromAwsManagedPolicyName("AmazonESCognitoAccess")]
~

但是在重新部署角色后没有被创建!

非常感谢任何建议。

最佳答案

好的,我需要使用:


new CfnUserPoolGroup(this, "AdminsGroup", {
groupName: "master-user-group",
userPoolId: userPool.ref
});

new CfnUserPoolGroup(this, "UsersGroup", {
groupName: "limited-user-group",
userPoolId: userPool.ref
});


而不是 idPool.ref

关于amazon-web-services - 使用 CDK 添加 AWS Cognito 用户池角色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62130416/

35 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com