Getting ID of an instance newly launched with ec2-api-tools

前端 未结 5 1253
没有蜡笔的小新
没有蜡笔的小新 2020-12-14 09:46

I\'m launching an EC2 instance, by invoking ec2-run-instances from simple a bash script, and want to perform further operations on that instance (e.g. associate elastic IP)

5条回答
  •  无人及你
    2020-12-14 10:20

    No need to use awk:

    # create the instance and capture the instance id
    echo "Launching instance..."
    instanceid=$(ec2-run-instances --key $pemkeypair --availability-zone $avzone $ami | egrep ^INSTANCE | cut -f2)
    if [ -z "$instanceid" ]; then
        echo "ERROR: could not create instance";
        exit;
    else
        echo "Launched with instanceid=$instanceid"
    fi
    

    from http://www.hulen.com/post/22802124410/unattended-amazon-ec2-install-script

提交回复
热议问题