aws / aws/aws-cdk

(route53-patterns): certificate-redirect-stack cannot reference ... Set crossRegionReferences=true to enable cross region references

Open
#29,453 5 comments 1 reaction 0 assignees View on GitHub
@aws-cdk/aws-route53-patterns bug p3
Dominant language
TypeScript
Stars
12.9k
Forks
4.6k
Avg merge
2d 3h
Merged PRs (30d)
83

Description

### Describe the bug

I'm attempting to remove some deprecation and I set `"@aws-cdk/aws-route53-patters:useCertificate": "true"` however, I'm running into this error:

>Error: Stack "certificate-redirect-stack-c8b5b42c242cdd1d88a8dbbb939528db6298ad5b05" cannot reference {.../...DotAppZone/Resource[Ref]} in stack "...". Cross stack references are only supported for stacks deployed to the same environment or between nested stacks and their parent stack. Set crossRegionReferences=true to enable cross region references

My stack already has `crossRegionReferences: true` in its props.

### Expected Behavior

No error

### Current Behavior

See error above

### Reproduction Steps

cdk.json:
```json
{
"app": "npx ts-node bin/cloud-infra.ts",
"versionReporting": false,
"context": {
"aws-cdk:enableDiffNoFail": "true",
"@aws-cdk/core:stackRelativeExports": "true",
"@aws-cdk/aws-route53-patters:useCertificate": "true"
}
}
```

```ts
new route53patterns.HttpsRedirect(this, "RedirectWwwToNonWww", {
recordNames: [`www.${domain}`],
targetDomain: domain,
zone,
});
```

### Possible Solution

I noticed that in here: https://github.com/aws/aws-cdk/blob/840ec977b09a48395c6be411250836edbc81b14c/packages/aws-cdk-lib/aws-route53-patterns/lib/website-redirect.ts#L134-L136 there's no `crossRegionReferences: true`.

That seems suspect; shouldn't that stack also enable cross-region references?

### Additional Information/Context

_No response_

### CDK CLI Version

2.130.0

### Framework Version

_No response_

### Node.js Version

20

### OS

macOS

### Language

TypeScript

### Language Version

_No response_

### Other information

_No response_

Contributor guide

Open the contributing guide

Research direction

Start in packages/aws-cdk-lib/aws-route53-patterns/lib/website-redirect.ts around lines 134-136 and inspect how HttpsRedirect creates or configures its stack references. Reproduce the issue with the supplied cdk.json and TypeScript example, then verify that enabling the relevant cross-region behavior removes the error without breaking the redirect.

Written by the indexing model from the issue text.

Assessment

Tech stack
aws, typescript
Domain
cloud, infrastructure
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.