# CrossStackReferences

Ergonomic API for configuring cross-stack reference strength on a construct.

Obtainable from: CrossStackReferences.of

- Source: [`core/lib/cross-stack-reference-strength.ts`](https://github.com/aws/aws-cdk/blob/v2.277.0/packages/aws-cdk-lib/core/lib/cross-stack-reference-strength.ts#L45)
- Type last changed: v2.258.0 · 4 Jun 2026

## Example

TypeScript:

```ts
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
import * as cdk from 'aws-cdk-lib';
const crossStackReferences = cdk.CrossStackReferences.of(this);
```

Python:

```python
# The code below shows an example of how to instantiate this type.
# The values are placeholders you should change.
import aws_cdk as cdk

cross_stack_references = cdk.CrossStackReferences.of(self)
```

Java:

```java
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
import software.amazon.awscdk.*;

CrossStackReferences crossStackReferences = CrossStackReferences.of(this);
```

C# / .NET:

```csharp
// Install: dotnet add package Amazon.CDK.Lib
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
using Amazon.CDK;

var crossStackReferences = CrossStackReferences.Of(this);
```

Golang:

```go
// Install: go get github.com/aws/aws-cdk-go/awscdk/v2
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
import cdk "github.com/aws/aws-cdk-go/awscdk"

crossStackReferences := cdk.CrossStackReferences_Of(this)
```

## Methods

- `consume(strength: ReferenceStrength): void` — Set the default reference strength used when this scope consumes references from other stacks.

  This controls the consuming side: sets the context key that determines how
  incoming cross-stack references are resolved for this scope and its descendants.

  Equivalent to `scope.node.setContext(DEFAULT_CROSS_STACK_REFERENCES, strength)`.

  **Parameters**

  - `strength` — - The reference strength to use.

- `of(scope: IConstruct): CrossStackReferences // chainable` (static) — Returns a `CrossStackReferences` configurator for the given construct.

  **Parameters**

  - `scope` — The construct to configure.

- `produce(strength: ReferenceStrength): void` — Set how this resource is referenced when consumed from another stack.

  This controls the producing side: any cross-stack reference pointing at
  this resource will use the specified strength instead of the global default.

  Equivalent to `scope.applyCrossStackReferenceStrength(strength)`.

  **Parameters**

  - `strength` — - The reference strength to use.
