Outputs - AWS CloudFormation


The optional Outputs section declares output values that you can import into other stacks (to create cross-stack references), return in response (to describe stack calls), or view on the CloudFormation console. For example, you can output the S3 bucket name for a stack to make the bucket easier to find.


CloudFormation doesn't redact or obfuscate any information you include in the Outputs section. We strongly recommend you don't use this section to output sensitive information, such as passwords or secrets.

Output values are available after the stack operation is complete. Stack output values aren't available when a stack status is in any of the IN_PROGRESS status. We don't recommend establishing dependencies between a service runtime and the stack output value because output values might not be available at all times.


The Outputs section consists of the key name Outputs, followed by a space and a single colon. You can declare a maximum of 200 outputs in a template.

The following example demonstrates the structure of the Outputs section.


Use braces to enclose all output declarations. Delimit multiple outputs with commas.

"Outputs" : { "Logical ID of resource" : { "Description" : "Information about the value", "Value" : "Value to return", "Export" : { "Name" : "Name of resource to export" } } }


Outputs: Logical ID of resource: Description: Information about the value Value: Value to return Export: Name: Name of resource to export

Output fields

The Outputs section can include the following fields.

Logical ID (also called logical name)

An identifier for the current output. The logical ID must be alphanumeric (a–z, A–Z, 0–9) and unique within the template.

Description (optional)

A String type that describes the output value. The value for the description declaration must be a literal string that's between 0 and 1024 bytes in length. You can't use a parameter or function to specify the description.

Value (required)

The value of the property returned by the aws cloudformation describe-stacks command. The value of an output can include literals, parameter references, pseudo-parameters, a mapping value, or intrinsic functions.

Export (optional)

The name of the resource output to be exported for a cross-stack reference.


The following restrictions apply to cross-stack references:

  • For each AWS account, Export names must be unique within a Region.

  • You can't create cross-stack references across Regions. You can use the intrinsic function Fn::ImportValue to import only values that have been exported within the same Region.

  • For outputs, the value of the Name property of an Export can't use Ref or GetAtt functions that depend on a resource.

    Similarly, the ImportValue function can't include Ref or GetAtt functions that depend on a resource.

  • You can't delete a stack if another stack references one of its outputs.

  • You can't modify or remove an output value that is referenced by another stack.

You can use intrinsic functions to customize the Name value of an export. There are examples in the next section.

To associate a condition with an output, define the condition in the Conditions section of the template.


The following examples illustrate how stack output works.

Stack output

In the following example, the output named BackupLoadBalancerDNSName returns the DNS name for the resource with the logical ID BackupLoadBalancer only when the CreateProdResources condition is true. (The second output shows how to specify multiple outputs.)


"Outputs" : { "BackupLoadBalancerDNSName" : { "Description": "The DNSName of the backup load balancer", "Value" : { "Fn::GetAtt" : [ "BackupLoadBalancer", "DNSName" ]}, "Condition" : "CreateProdResources" }, "InstanceID" : { "Description": "The Instance ID", "Value" : { "Ref" : "EC2Instance" } } }


Outputs: BackupLoadBalancerDNSName: Description: The DNSName of the backup load balancer Value: !GetAtt BackupLoadBalancer.DNSName Condition: CreateProdResources InstanceID: Description: The Instance ID Value: !Ref EC2Instance

Customize export name using Fn::Sub

In the following examples, the output named StackVPC returns the ID of a VPC, and then exports the value for cross-stack referencing with the name VPCID appended to the stack's name.


"Outputs" : { "StackVPC" : { "Description" : "The ID of the VPC", "Value" : { "Ref" : "MyVPC" }, "Export" : { "Name" : {"Fn::Sub": "${AWS::StackName}-VPCID" } } } }


Outputs: StackVPC: Description: The ID of the VPC Value: !Ref MyVPC Export: Name: !Sub "${AWS::StackName}-VPCID"

Customize export name using Fn::Join

The following examples use the Fn::Join function to customize the export name instead of the Fn::Sub function. The example Fn::Join function concatenates the stack name with the name VPCID using a colon as a separator.


"Outputs" : { "StackVPC" : { "Description" : "The ID of the VPC", "Value" : { "Ref" : "MyVPC" }, "Export" : { "Name" : { "Fn::Join" : [ ":", [ { "Ref" : "AWS::StackName" }, "VPCID" ] ] } } } }


Outputs: StackVPC: Description: The ID of the VPC Value: !Ref MyVPC Export: Name: !Join [ ":", [ !Ref "AWS::StackName", VPCID ] ]