簡體   English   中英

如何獲取在 cdk 腳本中創建的資源的 Arn

[英]How to get the Arn of a resource created in a cdk script

我目前正在嘗試使用 AWS CDK,但在我看來,這應該很容易。

(我正在使用 python,但我相信任何“啟用 cdk”的語言都一樣)

我可以創建一個認知用戶池(它有效):

    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 Authorizer,但我需要 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]
    )

我怎樣才能做到這一點?

正如在class CfnUserPool (construct) 的屬性中一樣,有attrArn

provider_arns=[
    pool.attr_arn
]

正如您所看到的文檔,沒有關於該屬性的描述,CDK 及其文檔仍處於此級別。 請准備缺陷、不正確的文檔、不能從 CDK 運行的示例。 它應該是測試版。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM