How to Reference the Output of One Nested SAM Application from Another Application

Viewed 691

I have an AWS SAM template that defines an application that references several other nested applications.

I need to pass the Output of one nested application to the Parameter of another nested application, but I'm not sure of the correct syntax.

Here's an example of the template that contains the nested applications:

AWSTemplateFormatVersion: '2010-09-09'
Transform: AWS::Serverless-2016-10-31
Description: >
  My Application

Metadata:
  AWS::ServerlessRepo::Application:
    Name: myapplication
    Description: My Application
    Author: me
    ReadmeUrl: README.md

Resources:
  nestedapp1:
    Type: AWS::Serverless::Application
    Properties:
      Location:
        ApplicationId: arn:aws:serverlessrepo:us-west-2:123456:applications/nestedapp1
        SemanticVersion: 0.0.1

  nestedapp2:
    Type: AWS::Serverless::Application
    Properties:
      Location:
        ApplicationId: arn:aws:serverlessrepo:us-west-2:123456:applications/nestedapp2
        SemanticVersion: 0.0.1
    Parameters:
      Parameter1: nestedapp1.Output1

nestedapp1 defines an output variable named "Output1" and nestedapp2 takes a parameter named "Parameter1".

I want to pass the value of nestedapp1.Output1 to nestedapp2.Parameter1. See the last line of the example code which isn't the correct way but illustrates what I'm trying to do.

How can I accomplish this?

1 Answers

I found out how to do this. See the last line for the correct syntax.

AWSTemplateFormatVersion: '2010-09-09'
Transform: AWS::Serverless-2016-10-31
Description: >
  My Application

Metadata:
  AWS::ServerlessRepo::Application:
    Name: myapplication
    Description: My Application
    Author: me
    ReadmeUrl: README.md

Resources:
  nestedapp1:
    Type: AWS::Serverless::Application
    Properties:
      Location:
        ApplicationId: arn:aws:serverlessrepo:us-west-2:123456:applications/nestedapp1
        SemanticVersion: 0.0.1

  nestedapp2:
    Type: AWS::Serverless::Application
    Properties:
      Location:
        ApplicationId: arn:aws:serverlessrepo:us-west-2:123456:applications/nestedapp2
        SemanticVersion: 0.0.1
      Parameters:
        Parameter1: !GetAtt nestedapp1.Outputs.OutputName
Related