4

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?

Avalanchis
  • 4,500
  • 3
  • 39
  • 48
  • Is it possible to nest `nestedapp2` inside of `nestedapp1` instead of the `root`. From there you might be able to pass the correct param to `nestedapp2`. (just wondering) – petey Sep 17 '20 at 19:03

1 Answers1

4

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
Dharman
  • 30,962
  • 25
  • 85
  • 135
Avalanchis
  • 4,500
  • 3
  • 39
  • 48
  • 1
    How did you manage to make OutputName available in the SAR App nested1? – Patrick W. Apr 28 '21 at 19:05
  • @PatrickW the output variable is defined in the template for nestedapp1. This page may be helpful: https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/outputs-section-structure.html – Avalanchis Apr 29 '21 at 20:03