0

I want to call another Rule that I have created to be used to serve multiple targets in my Makefile to create AWS Cloudformation Stacks. The Rule looks like this:

aws/create_stack:
   aws cloudformation create-stack \
   --stack-name $(stack_name) \
   --region $(region) \
   --capabilities CAPABILITY_IAM CAPABILITY_NAMED_IAM CAPABILITY_AUTO_EXPAND

I want to call the rule from another rule and define Variables for the rule at execution time like this:

aws/parameters: aws/create_stack
    $(MAKE) aws/create_stack stack_name=parameter region=$(REGION) 

But for some reason when I execute the Makefile the Variables set in the receipe of the Caller Rule are not used by the first Rule I'm calling.

when I set the Variable separately outside of the Rule (aws/parameters) - it works. How do I have to re-write it to keep the Variable assignment in the Rule (aws/parameter)?

Thank you A

2 Answers 2

1

There's no need to use recursion ($(MAKE) ...) here. Just use target-specific variables:

parameters: stack_name := parameter
parameters: region := $(REGION)
parameters: create_stack
    @echo parameters done

create_stack:
    @echo create_stack: stack_name is $(stack_name)
    @echo create_stack: region is $(region)
Sign up to request clarification or add additional context in comments.

Comments

0

As @Beta wrote you can use the "dependency approach"; a more condensed version looks like this:

aws/parameters: stack_name := parameter
aws/parameters: region := $(REGION)
was/parameters: aws/create_stack

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.