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

crossRegionReferences: Allow Export Value Changes #30771

Closed
2 tasks
savagete2860 opened this issue Jul 6, 2024 · 3 comments
Closed
2 tasks

crossRegionReferences: Allow Export Value Changes #30771

savagete2860 opened this issue Jul 6, 2024 · 3 comments
Labels
@aws-cdk/aws-rds Related to Amazon Relational Database closed-for-staleness This issue was automatically closed because it hadn't received any attention in a while. effort/medium Medium work item – several days of effort feature-request A feature should be added or improved. p2 response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 7 days.

Comments

@savagete2860
Copy link

savagete2860 commented Jul 6, 2024

Describe the feature

When using crossRegionReferences, allow the values to change.

Use Case

I am building a CDK project to test a cross-region disaster recovery strategy for an application that relies on an RDS instance in Stack A and a read replica of the RDS in Stack B. The stacks are in different regions. Stack A's RDS is created from a snapshot. Stack A exports the created RDS, which is then passed into Stack B via the crossRegionReferences feature. It is used as the sourceDatabaseInstance value in the DatabaseInstanceReadReplica in Stack B.

In a DR event, the read replica is promoted and becomes a primary instance rather than a read replica outside of CDK (this is also something I wish CDK could do). When the DR event is over, Stack A's RDS will need to be recreated from a snapshot of the RDS in Stack B so that any data changes during the DR event are retained when migrating back to the original region. When I update Stack A with a new snapshot ID, the value of the RDS changes, creating a new RDS instance. This ends up causing an UPDATE_ROLLBACK_FAILED error with the message Received response status [FAILED] from custom resource. Message returned: Error: Some exports have changed!.

In my use case, this is expected and desirable. I want to be able to change my export and then re-run a cdk deploy on Stack B so it creates a new read replica and the infrastructure ends up in the same state it was before the DR event.

Proposed Solution

add an option like crossRegionReferences: {enabled: true/false, allow_changes: true/false}

Other Information

I know this is also an issue for things like ACM certificates where they are referenced cross region. I imagine there are other use cases as well.

Acknowledgements

  • I may be able to implement this feature request
  • This feature might incur a breaking change

CDK version used

2.146.0

Environment details (OS name and version, etc.)

macOS

@savagete2860 savagete2860 added feature-request A feature should be added or improved. needs-triage This issue or PR still needs to be triaged. labels Jul 6, 2024
@github-actions github-actions bot added the @aws-cdk/aws-rds Related to Amazon Relational Database label Jul 6, 2024
@pahud
Copy link
Contributor

pahud commented Jul 8, 2024

Thank you for the sharing of your use case.

crossRegionReference is an experimental feature that supports strong reference only, which means if the output of the producer stack is being used by the consumer stack, that output value would not be allowed to be changed. Read the doc for more details.

In your case, I guess you probably have some options to explore:

  1. Instead of updating the existing resource from Stack A, which has exported its value for Stack B, define a new RDS instance resource in stack A from the snapshot as a new source of the replica from Stack B and eventually remove the previous resource definition of the RDS instance from Stack A. This might unblock the strong reference.

  2. update the tag of ssm parameter and remove something like aws-cdk:strong-ref=stack2 which implies that this parameter is no longer referenced by stack2. This is not well-tested but base on the design doc it could unblock the reference.

Please note: I have not verified the options above in my account and you need to test it very carefully in your own testing environment. Everything that intends to unblock the strong reference could be risky. Also please bear in mind crossRegionReference is an experimental feature which is subject to API changes and generally not recommended for production.

Let me know if it works for you.

@pahud pahud added p2 effort/medium Medium work item – several days of effort response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 7 days. and removed needs-triage This issue or PR still needs to be triaged. labels Jul 8, 2024
Copy link

This issue has not received a response in a while. If you want to keep this issue open, please leave a comment below and auto-close will be canceled.

@github-actions github-actions bot added closing-soon This issue will automatically close in 4 days unless further comments are made. closed-for-staleness This issue was automatically closed because it hadn't received any attention in a while. and removed closing-soon This issue will automatically close in 4 days unless further comments are made. labels Jul 10, 2024
@aws-cdk-automation
Copy link
Collaborator

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.

@aws aws locked as resolved and limited conversation to collaborators Jul 25, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
@aws-cdk/aws-rds Related to Amazon Relational Database closed-for-staleness This issue was automatically closed because it hadn't received any attention in a while. effort/medium Medium work item – several days of effort feature-request A feature should be added or improved. p2 response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 7 days.
Projects
None yet
Development

No branches or pull requests

3 participants