如何获取在cdk脚本中创建的资源的Arn

2024-05-16 04:38:30 发布

您现在位置:Python中文网/ 问答频道 /正文

我目前正在试验AWS CDK,我一直在做一些在我看来应该很简单的事情

(我正在使用python,但我相信任何“支持cdk”的语言都是一样的)

我可以创建一个cognito用户池(它可以工作):

    pool = cognito.CfnUserPool(self, "cdk_test_pool", 
        admin_create_user_config=cognito.CfnUserPool.AdminCreateUserConfigProperty(
            allow_admin_create_user_only=True
        ), 
        auto_verified_attributes=["email"], 
        policies=cognito.CfnUserPool.PoliciesProperty(
            password_policy=cognito.CfnUserPool.PasswordPolicyProperty(
                minimum_length=6, 
                require_lowercase=True, 
                require_numbers=True, 
                require_symbols=True, 
                require_uppercase=True
            )
        ), 
        user_pool_name="cdk_test_pool"
    )

现在我想创建一个apigateway授权程序,但我需要UserPool Arn:

    poolArn = ????????
    authorizer = apigateway.CfnAuthorizer(self, "cdk-test-authorizer",
        rest_api_id="hello-api", 
        type="COGNITO_USER_POOLS", 
        identity_source="method.request.header.Authorization", 
        name="cdk-test-authorizer", 
        provider_arns=[poolArn]
    )

我该怎么做


Tags: nametestselftrueadmincreaterequirepool
1条回答
网友
1楼 · 发布于 2024-05-16 04:38:30

正如在Properties of the class CfnUserPool (construct)中一样,有属性

provider_arns=[
    pool.attr_arn
]

正如您所看到的文档,没有关于属性的描述,CDK及其文档仍然处于这样的级别。请准备缺陷、不正确的文档、CDK不适用的示例。它应该是测试版

相关问题 更多 >