aws-cloudformation / aws-cloudformation-resource-providers-awsutilities-commandrunner

Apache License 2.0
81 stars 21 forks source link

Get outputs from other resource #60

Closed Bharath509 closed 8 months ago

Bharath509 commented 1 year ago

I'm creating msk using cloud formation template, SInce msk resource in cloud formation only gives msk arn as output, I ran an was command to get the bootstrap broker URL, But when running the command I'm not able to refer output from the msk resource (!GetAtt MskCluster.Arn)

Please help me fix this

Manideepakakula commented 1 year ago

Yeah, This is a primary use case that needs to be provided, deeply disappointed if there is no way to achieve this scenario

shantgup commented 8 months ago

You can do this, using the below format. Fn::Sub lets us specify the GetAtt like ${MskCluster.Arn}, where MskCluster is the Logical ID of the resource. For more information on this, see here.

Resources:
   CommandRunner:
      Type: AWSUtility::CloudFormation::CommandRunner
      Properties:
         Command:
            Fn::Sub: |
                echo ${MskCluster.Arn} > /command-output.txt
         LogGroup: my-cloudwatch-log-group
         Role: MyEC2InstanceProfile