AWS Cloudformation, Output value from Custom Resource

Deadly 提交于 2019-12-13 03:13:35

问题


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,


回答1:


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


来源:https://stackoverflow.com/questions/51351764/aws-cloudformation-output-value-from-custom-resource

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!