How to pop a stack, create successful information until all resources are created on the stack

I am trying to create a stack with aws cloudformation create-stack --stack-name ... --template-body file://...to create a stack. It displays the stack identifier immediately after the command is executed. But the resources required by the stack are lost upon creation.

I want to display some message until all resources are created.

I do not want to describe the stack in a loop. and displays a message until it receives a stack creating a complete signal.

+6
source share
3 answers

After the initial request to create the stack, you will need to request one more:

 aws cloudformation wait stack-create-complete --stack-name $STACK_ID_FROM_CREATE_STACK

From aws docs http://docs.aws.amazon.com/cli/latest/reference/cloudformation/wait/stack-create-complete.html

, CREATE_COMPLETE. 30 . 255 120 .

+15

Google cloud AWS:: CF.

gcloud deployment-manager deployments create [stack_name]

:

 --async
    Return immediately and print information about the Operation in
    progress rather than waiting for the Operation to complete.
    (default=False)

gcloud async, , . , , "/ ".

, AWS:: CF . aws cli, , .

, , , gcloud cli , , : API , .

, script API AWS:: CF ?

+3

bash aws cloudformation create-stack. aws cloudformation wait stack-create-complete, 60 (120 30 ). , , , , , "CREATE_COMPLETE". bash :

aws --region ${AWS_REGION} --profile ${AWS_PROFILE} cloudformation create-stack --template-body ${STACK_TEMPLATE} --stack-name ${STACK_NAME}
if [[ $? -eq 0 ]]; then
    # Wait for create-stack to finish
    echo  "Waiting for create-stack command to complete"
    CREATE_STACK_STATUS=$(aws --region ${AWS_REGION} --profile ${AWS_PROFILE} cloudformation describe-stacks --stack-name ${STACK_NAME} --query 'Stacks[0].StackStatus' --output text)
    while [[ $CREATE_STACK_STATUS == "REVIEW_IN_PROGRESS" ]] || [[ $CREATE_STACK_STATUS == "CREATE_IN_PROGRESS" ]]
    do
        # Wait 30 seconds and then check stack status again
        sleep 30
        CREATE_STACK_STATUS=$(aws --region ${AWS_REGION} --profile ${AWS_PROFILE} cloudformation describe-stacks --stack-name ${STACK_NAME} --query 'Stacks[0].StackStatus' --output text)
    done
fi
0

Source: https://habr.com/ru/post/1620067/


All Articles