Export output cloudformation

18 views
Skip to first unread message

Frank

unread,
Nov 16, 2022, 8:44:24 AM11/16/22
to cloudtools-dev
Hi,

I'm trying to output some information about my AWS template resources as below and that is fine.

t.add_output(
[
Output(
"SecurityGroup",
Description="Security Group for ECS Fargate",
Value=Ref(fargateSecurityGroup),
),
]
)

However I'm trying to export that output so I different stack can use the resources to build different stuff, I'm trying something like this but I haven't been able to solve it yet.

t.add_output(
[
Output(
"Subnet",
Description="Subnet ID",
Value=GetAtt(subnet, "SubnetId"),
Export=Name("Fn::Sub","${AWS::StackName}-TestOutput")
),
]
)

ERROR: Export=Name("Fn::Sub","${AWS::StackName}-TestOutput")
NameError: name 'Name' is not defined

In plain yaml it is like this:

Outputs: 
  PublicSubnet: 
      Description: The subnet ID to use for public web servers 
      Value: 
        Ref: PublicSubnet 
      Export: 
        Name: 
          'Fn::Sub': '${AWS::StackName}-SubnetID'

So far not sure how to do it. Have you ever used this function?, if yes, Can you advise?, thanks.

Kyle Finley

unread,
Nov 16, 2022, 10:49:11 AM11/16/22
to Frank, cloudtools-dev

You are looking for ExportSub. Both of which are imported as `from troposphere import Export, Sub`.

`Export=Export(Name=Sub("${AWS::StackName}-SubnetID"))`


--
You received this message because you are subscribed to the Google Groups "cloudtools-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cloudtools-de...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/cloudtools-dev/318a5dd3-0635-4936-8794-8af4000b663cn%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages