How to fix AWS CDK error: “Export [export name] cannot be updated as it is in use by [stack name]”

So you tried updating your AWS CloudFormation stack and got the error that another stack is using the value of that specific export name. The resource name that we import in another stack has to match the name of the exported resource exactly.
This usually happens when a depending stack has not yet been deployed and you are trying to manipulate an export name that the stack thinks it needs to be associated with. You are now down the rabbit hole and regretting your decision to update your stack at all (audible sigh).
First, figure out which stack is using the exported value. You can use the AWS CLI or AWS CloudFormation console to find this.
For the AWS CLI run the following command to list the exported values from all your stacks
aws cloudformation list-exports
You will see a long output of all your exports that look like the following
[
{
"ExportingStackId": "arn:aws:cloudformation:eu-east-2:123456789:stack/test/123456789",
"Name": "test:ExportsOutputFnGetAttmediumtest123",
"Value": "arn:aws:lambda:eu-east-2:123456789:function:test"
}
]
Find the export name that is in your error message when you try to deploy and then run the following command:
aws cloudformation list-imports --export-name "test:ExportsOutputFnGetAttmediumtest123"
Replace “test:ExportsOutputFnGetAttmediumtest123” with the “Name” of your export found in the export list. You will now see the stacks that import this exported resource.
You can also go to AWS CloudFormation console and click Exports on your top left.

Search for the export name that is displayed in your error message, click on it and you will be taken to a page that shows which stacks import the exported resource.
Now that we have the associated stack, we need to update the AWS CloudFormation template by replacing the instrinsic function with the export value.
Go to the AWS CloudFormation console, click Stacks in your top left, then find and click the depending stack that needs to be changed.
Below the stack name you will see Stack info, click on Template then the button for “View in Designer”. Manually replace the instrinsic function with the value output for the exporting resource. Search by the export “Name” you found with the list-exports command. It should look something like the following in your template:
{
"Type": "AWS::Lambda::Permission",
"Properties": {
"Action": "lambda:InvokeFunction",
"FunctionName": {
"Fn::ImportValue": "test:ExportsOutputFnGetAttmediumtest123"
},
"Principal": "apigateway.amazonaws.com"
}
Delete the section for FunctionName and replace it with the “Value” for the exported resource. You can find this in the export list or by searching for it in the AWS Management Console.
{
"Type": "AWS::Lambda::Permission",
"Properties": {
"Action": "lambda:InvokeFunction",
"arn:aws:lambda:eu-east-1:123456789:function:test",// Added line
"Principal": "apigateway.amazonaws.com"
}
Replace all occurrances of this intrinsic function with the explicit value.
Once completed, in your top left you will see a paper icon, click on that and then click Save in the dropdown menu. Name the template and save to Local file.
Almost there! Go back to your AWS CloudFormation console and the depending stack that you just saved the template for. Click on the stack and at the top below the name you should see Delete, Update, Stack actions, Create stack. Click Update, and then click Replace current template. Upload the template file that your saved locally and click Next.

Click Next through the Options section and then choose Update on the Review screen after verifying the settings (which should all be the same).
When your stack is in the UPDATE_COMPLETE state you are now ready to redeploy the stack that is exporting the values without an error!