我是這樣做的:
apply: init
@terraform apply -auto-approve
BUCKET=$(shell terraform output -json | jq '.S3_Bucket.value')
DYNAMODB=$(shell terraform output -json | jq '.dynamo_db_lock.value')
@echo $${BUCKET}
make顯示兩個變數都被設定了(我用的是:=,但這對我不起作用,因為我需要在執行apply時設定它們),但它仍然在回顯空白:
...
輸出。
S3_Bucket = "bucket1"
dynamo_db_lock = "dyna1"
BUCKET="bucket"
DYNAMODB="dyna1"
<-- echo應該在這里列印出來
我想在事后用這個變數做一個sed...
謝謝大家!
CodePudding
每一個makefile配方行都在它自己的shell中運行。 因此,在一個配方行中設定的shell變數不會影響其他配方行。 你可以通過對所有行的命名來解決這個問題。
apply: init
@terraform apply -auto-approve
@BUCKET=$(shell terraform output -json | jq '.S3_Bucket.value')。
DYNAMODB=$(shell terraform output -json | jq '.dynamo_db_lock.value')。
echo $${BUCKET}
轉載請註明出處,本文鏈接:https://www.uj5u.com/caozuo/316465.html
標籤:
