Using Ref for Resource in Step function inside cloudformation template

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP



Using Ref for Resource in Step function inside cloudformation template



I have a step function inside cloudformation. The cloudformation stack also create Lambdas which i will use as resource in step function. I have something like


TestLambda:
Type: "AWS::Lambda::Function"
Properties:
Handler: "test_lambda.lambda_handler"
Role: "arn:aws:iam::1234342334:role/Lambda"
Code:
ZipFile: !Sub |
from __future__ import print_function
import boto3
def lambda_handler(event, context):
print(event)
Runtime: "python2.7"

....

TestStateMachine:
Type: AWS::StepFunctions::StateMachine
Properties:
StateMachineName: "Test"
DefinitionString: |-
{
"StartAt": "State1",
"States": {
"State1" :
"Type" : "Task",
"Resource" : "$!GetAtt TestLambda.Arn",
"Next": "State2?"
,
...
...



all inside one cloudformation template.


"SCHEMA_VALIDATION_FAILED: Value is not a valid resource ARN"



I also tried !GetAtt TestLambda.Arn, it didn't work. I want the lambda and stepfunction created inside the single cloudformation template. Please let me know if there is better, cleaner way of doing it.



Thank you




1 Answer
1



You should use Fn::Sub function for that:


TestStateMachine:
Type: AWS::StepFunctions::StateMachine
Properties:
StateMachineName: "Test"
DefinitionString:
Fn::Sub:
|-
{
"StartAt": "State1",
"States": {
"State1" :
"Type" : "Task",
"Resource" : "$TestLambda.Arn",
"Next": "State2?"
,






By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Popular posts from this blog

Firebase Auth - with Email and Password - Check user already registered

Dynamically update html content plain JS

Creating a leaderboard in HTML/JS