Skip to content

Commit

Permalink
Update the_state_machine_stack.py
Browse files Browse the repository at this point in the history
  • Loading branch information
nideveloper committed Jan 11, 2021
1 parent a75816e commit 447488e
Showing 1 changed file with 8 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,12 @@ def __init__(self, scope: core.Construct, id: str, **kwargs) -> None:

# The first thing we need to do is see if they are asking for pineapple on a pizza
pineapple_check_lambda = _lambda.Function(self, "pineappleCheckLambdaHandler",
runtime=_lambda.Runtime.NODEJS_12_X, # execution environment
handler="orderPizza.handler", # file is "orderPizza", function is "handler"
code=_lambda.Code.from_asset("lambda_fns"), # code loaded from the "lambda_fns" directory
runtime=_lambda.Runtime.NODEJS_12_X,
handler="orderPizza.handler",
code=_lambda.Code.from_asset("lambda_fns"),
)

# Step functions are built up of steps, we need to define our first step
# Refactored code because sfn.Task is Depecrated right now. Using StepFunctionsTaks.LambdaInvoke instead
# https://docs.aws.amazon.com/cdk/api/latest/docs/@aws-cdk_aws-stepfunctions.Task.html
order_pizza = step_fn_tasks.LambdaInvoke(self, 'Order Pizza Job',
lambda_function=pineapple_check_lambda,
input_path='$.flavour',
Expand Down Expand Up @@ -54,9 +52,9 @@ def __init__(self, scope: core.Construct, id: str, **kwargs) -> None:

# defines an AWS Lambda resource to connect to our API Gateway
state_machine_lambda = _lambda.Function(self, "stateMachineLambdaHandler",
runtime=_lambda.Runtime.NODEJS_12_X, # execution environment
handler="stateMachineLambda.handler", # file is "stateMachineLambda", function is "handler
code=_lambda.Code.from_asset("lambda_fns"), # code loaded from the "lambda_fns" directory
runtime=_lambda.Runtime.NODEJS_12_X,
handler="stateMachineLambda.handler",
code=_lambda.Code.from_asset("lambda_fns"),
environment={
'statemachine_arn': state_machine.state_machine_arn
}
Expand All @@ -65,7 +63,7 @@ def __init__(self, scope: core.Construct, id: str, **kwargs) -> None:
state_machine.grant_start_execution(state_machine_lambda)

# Simple API Gateway proxy integration
# defines an API Gateway REST API resource backed by our "sqs_publish_lambda" function.
# defines an API Gateway REST API resource backed by our "state_machine_lambda" function.
api_gw.LambdaRestApi(self, 'Endpoint',
handler=state_machine_lambda
)
)

0 comments on commit 447488e

Please sign in to comment.