Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TableV2: TableV2 Replica provides the incorrect TableStreamARN in CDK #31335

Closed
1 task
kevinhuynh23 opened this issue Sep 5, 2024 · 9 comments
Closed
1 task
Assignees
Labels
@aws-cdk/aws-dynamodb Related to Amazon DynamoDB guidance Question that needs advice or information. p2

Comments

@kevinhuynh23
Copy link

Describe the bug

When using Global Tables with TableV2 in CDK, the replica tables aren't referenced properly with an output export like the primary Global Table Stream ARN. For example, we create a global table in us-east-1 with replicas in us-west-2 and eu-west-1.

When getting the Stream ARN for the primary global table, CDK will create reference the exact Stream ARN i.e. arn:aws:dynamodb:us-east-1:123456789012:table/IndraMembershipDetails-Beta/stream/<timestamp>. Where as in the replica tables when using globalTable.replica("us-west-2"), it'll get the correct replica table, but the Stream ARN provided is not the exact Stream ARN, but something like this instead: arn:aws:dynamodb:us-west-2:123456789012:table/IndraMembershipDetails-Beta/stream/*.

Regression Issue

  • Select this option if this issue appears to be a regression.

Last Known Working CDK Version

No response

Expected Behavior

I would expect to use globalTable.replica("us-west-2") and retrieve the replica Stream ARN to as arn:aws:dynamodb:us-west-2:123456789012:table/IndraMembershipDetails-Beta/stream/<timestamp>.

Current Behavior

When getting the Stream ARN for the primary global table, CDK will create reference the exact Stream ARN i.e. arn:aws:dynamodb:us-east-1:123456789012:table/IndraMembershipDetails-Beta/stream/<timestamp>. Where as in the replica tables when using globalTable.replica("us-west-2"), it'll get the correct replica table, but the Stream ARN provided is not the exact Stream ARN, but something like this instead: arn:aws:dynamodb:us-west-2:123456789012:table/IndraMembershipDetails-Beta/stream/*.

Reproduction Steps

  1. Create a Global Table configuration using TableV2
  2. Configure replicas to be in two regions i.e. us-west-2 and eu-west-1
  3. Get the replica in a region i.e. globalTable.replica("us-west-2")
  4. Get the Stream ARN from the replica table

Possible Solution

No response

Additional Information/Context

No response

CDK CLI Version

2.87.0

Framework Version

No response

Node.js Version

v20.17.0

OS

Mac OS Sonoma 14.6.1

Language

TypeScript

Language Version

No response

Other information

No response

@kevinhuynh23 kevinhuynh23 added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Sep 5, 2024
@github-actions github-actions bot added the @aws-cdk/custom-resources Related to AWS CDK Custom Resources label Sep 5, 2024
@khushail khushail added needs-reproduction This issue needs reproduction. p2 and removed needs-triage This issue or PR still needs to be triaged. labels Sep 5, 2024
@khushail khushail self-assigned this Sep 5, 2024
@khushail
Copy link
Contributor

khushail commented Sep 6, 2024

Hi @kevinhuynh23 , Thanks for reaching out.

you seem to be using very old version of CDK. Could you please try running on the latest CDK 2.156. Meanwhile I will also try to reproduce this on my end.

@khushail khushail added the response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 7 days. label Sep 6, 2024
@kevinhuynh23
Copy link
Author

Hi @khushail, thanks for looking to this! We are stuck on CDK 2.87.0 due to some of our dependencies. We can look into upgrading to the latest version if there's a fix for it in the later versions!

Thanks!

@github-actions github-actions bot removed the response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 7 days. label Sep 7, 2024
@kevinhuynh23
Copy link
Author

Hi @khushail, I had sometime to work around the dependency and I tried testing the same thing on 2.155.0 and seeing the same result!

@khushail khushail added the investigating This issue is being investigated and/or work is in progress to resolve the issue. label Sep 16, 2024
@khushail
Copy link
Contributor

Hi @kevinhuynh23 , thanks for replying back with your updates.
I tried to repro the situation with the latest CDK 2.158.0. Sharing my observations -
Code snippet -

//create  a global table with replica in other regions
    const globalTable = new cdk.aws_dynamodb.TableV2(this, 'MyTable', {
      tableName: 'MyTable',
      partitionKey: { name: 'id', type: cdk.aws_dynamodb.AttributeType.STRING },
      removalPolicy: cdk.RemovalPolicy.DESTROY,
    });

    //globaltable stream arn
    new cdk.CfnOutput(this, 'GlobalTableStreamArn', {
      value: globalTable.tableStreamArn!,
    });

    //add replicas to the table
    globalTable.addReplica({ region: 'us-west-1', deletionProtection: true });

    //get the streamarn for the replicat table from region us-west-1

    new cdk.CfnOutput(this, 'ReplicaTableArn', {
      value: globalTable.replica('us-west-1').tableStreamArn!,
    });

Here is the output printed with incomplete arn -

Screenshot 2024-09-16 at 3 30 21 PM

As seen in the cdk code, this replica table is lazily created.

replicas: Lazy.any({ produce: () => this.renderReplicaTables() }),

I am still figuring out the root cause, will share updates soon. Thanks for having patience

@khushail khushail removed the needs-reproduction This issue needs reproduction. label Sep 16, 2024
@khushail
Copy link
Contributor

khushail commented Sep 19, 2024

@kevinhuynh23 , here is my observation from the code which states the stream as <steam>/* -

This method adds replica in another region with the stream arn ending with *-

const replicaStreamArn = `${replicaArn}/stream/*`;

Linked PR - e52acd8

RFC -https://github.com/aws/aws-cdk-rfcs/blob/main/text/0510-dynamodb-global-table.md
As per RFC, the reason for mentioning the stream with * as -
Screenshot 2024-09-19 at 1 34 49 PM

So It seems to be intentional the way replica arn is created.
Hope that would be helpful.
Please feel free to reach out in case of further questions. Thanks

cc: @pahud

@khushail khushail added response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 7 days. @aws-cdk/aws-dynamodb Related to Amazon DynamoDB and removed investigating This issue is being investigated and/or work is in progress to resolve the issue. bug This issue is a bug. @aws-cdk/custom-resources Related to AWS CDK Custom Resources labels Sep 19, 2024
@kevinhuynh23
Copy link
Author

@khushail Thanks for looking into this issue!

The reason the above comment mentions an addition of a potential lookup function to determine the stream arn, are there any plans to implement this?

Also, are we not able to have the Replica Stream ARN be exported as a CloudFormation export value after the creation completes? Or does CFN have no ability to reference the value?

Thanks for the help!

@github-actions github-actions bot removed the response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 7 days. label Sep 20, 2024
@khushail
Copy link
Contributor

khushail commented Sep 20, 2024

@kevinhuynh23 , I highly doubt if the replica stream ARN could be exported as value but will definitely keep looking and share here if I find anything.

Also, I did not find any such implementation plan for the mentioned function. However you could file a feature request with CDK, and get community upvotes for getting it prioritised.

@khushail khushail added the guidance Question that needs advice or information. label Sep 20, 2024
@khushail
Copy link
Contributor

@kevinhuynh23 , I would be closing this issue for now.

If you need any other help/guidance, please feel free to re-open.

Thanks !

Copy link

Comments on closed issues and PRs are hard for our team to see.
If you need help, please open a new issue that references this one.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 20, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
@aws-cdk/aws-dynamodb Related to Amazon DynamoDB guidance Question that needs advice or information. p2
Projects
None yet
Development

No branches or pull requests

2 participants