Nitesh
Nitesh

Reputation: 1637

Getting "AttributeError: 'CfnUserPool' object has no attribute 'user_pool_id' " error

I am trying to create "CfnUserPoolClient" object using AWS doc -https://docs.aws.amazon.com/cdk/api/latest/python/aws_cdk.aws_cognito/CfnUserPoolClient.html

I have created "CfnUserPool" object like this -

_cognito_user_pool = _cognito.CfnUserPool(stack, id="pool-id", user_pool_name="user-auth-pool")

To create "CfnUserPoolClient" object I need ID of "CfnUserPool" object. I am using below code to create "CfnUserPoolClient" object-

_user_pool_id = _cognito_user_pool.user_pool_id
_cognito_userpool_clients = _cognito.CfnUserPoolClient(stack, id="client-id", user_pool_id=_user_pool_id, client_name="client-name")  

I am getting below error for this code -

AttributeError: 'CfnUserPool' object has no attribute 'user_pool_id'.

I think there is no attribute "user_pool_id" for "CfnUserPool" object. I have tried "id" to get user pool id like this -

_user_pool_id = _cognito_user_pool.id

But still I am getting same error and this time it is for "id".

So how can I get "user_pool_id" value for CfnUserPoolClient from CfnUserPool resource?

Upvotes: 1

Views: 624

Answers (2)

A-P
A-P

Reputation: 198

Just for the reference for others, the following will serve the purpose:

_user_pool_id = _cognito_user_pool.ref

Upvotes: 2

Nitesh
Nitesh

Reputation: 1637

Answer - I have resolved this issue by using UserPool instead of CfnUserPool. UserPool has "user_pool_id" attribute and we can fetch it's id value using this attribute.

Upvotes: 0

Related Questions