Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AWS CloudFormation, Output value from Custom Resource

I wanted to output a value I get form an CloudFormation Custom Resource. I'm definitely returning the value, but I wasn't sure how to reference it in an output

This is my template.yml:

Outputs:
  customresourceoutput:
    Value:
      !GetAtt creates3bucketlambda.myvalue

Resources:
  creates3bucketlambda:
    Type: AWS::Serverless::Function
    Properties:
      Handler: index.handler
      Runtime: nodejs6.10
      CodeUri: setups3bucket
      MemorySize: 512
      Timeout: 300
      Policies:
        - AWSLambdaBasicExecutionRole
        - AmazonS3FullAccess

  Creates3BucketLoginPage:
    Type: Custom::AppConfiguration
    Properties:
      ServiceToken: !GetAtt creates3bucketlambda.Arn
      aOrg:
        !Ref aOrg

The Error I get is:

Failed to create the changeset: Waiter 
ChangeSetCreateComplete failed: Waiter encountered a terminal failure 
state Status: FAILED. Reason: Template error: resource 
creates3bucketlambda does not support attribute type myvalue in 
Fn::GetAtt

I'm not sure if I use a !Sub, !Ref

like image 392
user3888307 Avatar asked Nov 08 '25 09:11

user3888307


1 Answers

So basically you can return two things from the AWS::Serverless::Function

  customresourceoutput:
    Value:
      !GetAtt creates3bucketlambda.Arn -> arn of lambda function

and

  customresourceoutput:
    Value:
      !Ref creates3bucketlambda -> name of lambda function

More details about serverless function outputs here.

If you're interested in AWS::CloudFormation::CustomResource there is also a documentation for that.

You can use Fn::GetAtt like:

  customresourceoutput:
    Value:
      !GetAtt customerResource.responseKeyName -> name of the key from the response
like image 199
Orest Avatar answered Nov 10 '25 17:11

Orest



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!