aws / aws-cdk

The AWS Cloud Development Kit is a framework for defining cloud infrastructure in code
https://aws.amazon.com/cdk
Apache License 2.0
11.35k stars 3.77k forks source link

aws-cognito-identitypool-alpha: fromIdentityPoolArn Method throws when using a string from a StringParameter lookup #29780

Open Xenoha opened 2 months ago

Xenoha commented 2 months ago

Describe the bug

When using the construct to lookup an IdentityPool from a SSM StringParameter. The construct throws validation errors because it is expecting an actual string of two parts separated by a ':'.

Expected Behavior

Should be able to lookup an Identity pool with a SSM StringParameter stringValue.

Current Behavior

Code at lines 118 of the Identitypool.js file throws // if (!(idParts.length === 2)) // throw new Error('Invalid Identity Pool Id: Identity Pool Ids must follow the format <region>:<id>'); // if (idParts[0] !== pool.region) // throw new Error('Invalid Identity Pool Id: Region in Identity Pool Id must match stack region');

Reproduction Steps

const identityPool = IdentityPool.fromIdentityPoolArn(this, 'some-identityPool', indentityPoolStringParameter.stringValue)

Possible Solution

Review other constructs best practices for allowing SSM StringParameter lookup stringValue strings.

Additional Information/Context

No response

CDK CLI Version

2.135.0

Framework Version

No response

Node.js Version

20.12.0

OS

Linux

Language

TypeScript

Language Version

Typescript 5.4.4

Other information

No response

khushail commented 2 months ago

Thanks @Xenoha for reaching out . I can see in the code why this is producing an error - https://github.com/aws/aws-cdk/blob/6f21c1d91237f4caf83283492226f447b882654a/packages/%40aws-cdk/aws-cognito-identitypool-alpha/lib/identitypool.ts#L330

https://github.com/aws/aws-cdk/blob/6f21c1d91237f4caf83283492226f447b882654a/packages/%40aws-cdk/aws-cognito-identitypool-alpha/lib/identitypool.ts#L310

ndltuan commented 1 week ago

I encountered a similar error, how do I fix them.

"@aws-cdk/aws-cognito-identitypool-alpha": "^2.100.0-alpha.0", "aws-cdk-lib": "^2.100.0",