OpsCanary
awscdk cfnPractitioner

Streamlining Cross-Account and Cross-Region References with Fn::GetStackOutput

5 min read AWS DevOps BlogMay 14, 2026Reviewed for accuracy
Share
PractitionerHands-on experience recommended

In a multi-account and multi-Region AWS environment, referencing outputs from one stack in another can become cumbersome. Traditionally, you would rely on Fn::ImportValue, which only works within the same account and Region. Fn::GetStackOutput changes the game by allowing you to reference outputs across accounts and Regions directly in your CloudFormation templates and AWS CDK applications. This means you can streamline your infrastructure as code and reduce the complexity of your deployments.

Fn::GetStackOutput works by identifying the referenced stack and its output. If you provide a RoleArn, it assumes that role to access the target account. It then calls DescribeStacks to retrieve the output value from the specified stack and Region, resolving the value before continuing with template processing. Key parameters include StackName, OutputName, Region, and RoleArn, allowing for flexible configurations based on your architecture.

However, be cautious. Fn::GetStackOutput creates weak references, meaning the producer stack doesn’t know it’s being referenced. There’s no dependency tracking, so if you delete the producer stack or remove the output, your consumer stack will fail on the next update. Also, changes in the producer stack’s output won’t automatically propagate to the consumer stack; you’ll need to manually update it. Use Fn::ImportValue when you need strong referential integrity within the same account and Region, as it prevents deletion of stacks that export values consumed by others.

Key takeaways

  • Utilize Fn::GetStackOutput for cross-account and cross-Region stack output references.
  • Specify RoleArn to access outputs in different AWS accounts.
  • Understand that Fn::GetStackOutput creates weak references, lacking dependency tracking.
  • Manually update consumer stacks to reflect changes in producer stack outputs.
  • Use Fn::ImportValue for strong referential integrity within the same account and Region.

Why it matters

In production, simplifying cross-account and cross-Region references can significantly reduce deployment complexity and errors. This leads to faster iterations and more reliable infrastructure management.

Code examples

YAML
1# ProducerStack - deployed in us-west-2, account 111111111111
2Resources:
3  MyVPC:
4    Type: AWS::EC2::VPC
5    Properties:
6      CidrBlock: 10.0.0.0/16
7Outputs:
8  VpcId:
9    Value: !Ref MyVPC
YAML
1Resources:
2  MyInstance:
3    Type: AWS::EC2::Instance
4    Properties:
5      VpcId:
6        Fn::GetStackOutput:
7          StackName: ProducerStack
8          OutputName: VpcId
YAML
1Resources:
2  MyInstance:
3    Type: AWS::EC2::Instance
4    Properties:
5      VpcId:
6        Fn::GetStackOutput:
7          StackName: ProducerStack
8          OutputName: VpcId
9          RoleArn: arn:aws:iam::111111111111:role/GetStackOutputRole

When NOT to use this

Use Fn::ImportValue when you need strong referential integrity within the same account and Region. CloudFormation prevents you from deleting a stack that exports values consumed by other stacks.

Want the complete reference?

Read official docs

Test what you just learned

Quiz questions written from this article

Take the quiz →
DigitalOceanSponsor

Simple, affordable cloud — VMs, Kubernetes, and managed databases in minutes. Trusted by 600,000+ developers. Spin up a Droplet in 60 seconds.

Try DigitalOcean →

Get the daily digest

One email. 5 articles. Every morning.

No spam. Unsubscribe anytime.