未找到 Aws CloudFormation 命令

问题描述

我写了这个 bash 命令来提取这个 json 的输出

{
    "Stacks":  [
        {
            "StackId": "arn:aws:cloudformation:us-east-1:123456789012:stack/myteststack/466df9e0-0dff-08e3-8e2f-5088487c4896","Description": "AWS CloudFormation Sample Template S3_Bucket: Sample template showing how to create a publicly accessible S3 bucket. **WARNING** This template creates an S3 bucket. You will be billed for the AWS resources used if you create a stack from this template.","Tags": [],"Outputs": [
                {
                    "Description": "Name of S3 bucket to hold website content","OutputKey": "BucketName","OutputValue": "myteststack-s3bucket-jssofi1zie2w"
                }
            ],"StackStatusReason": null,"CreationTime": "2013-08-23T01:02:15.422Z","Capabilities": [],"StackName": "myteststack","StackStatus": "CREATE_COMPLETE","disableRollback": false
        }
    ]
}

我写的代码是这样的: 同时:

          do
                status=aws cloudformation describe-stacks --region $REGION --stack-name $stack_name | jq --raw-output '.Stacks[0].StackStatus' 
                echo $status 
                if [[ $status == "UPDATE_ROLLBACK_COMPLETE" ]]; then
                      echo "Status is in ROLLBACK check errors"
                      exit 1
                else 
                      if [[ $status == "UPDATE_COMPLETE" ]]; then
                            break
                      fi
                fi
          echo Stack updating is finishing 
          done

但我收到一条错误消息,提示未找到命令 cloudformation

解决方法

您必须在命令中添加此“$()”:

status=$(aws cloudformation describe-stacks --region $REGION --stack-name $stack_name | jq --raw-output '.Stacks[0].StackStatus')