在bash脚本中使用CURL请求触发AWS PHP SDK浏览器URL

We have setup aws php sdk with php to launch aws ec2 instances. When we run it with any browser it's launch an ec2 instance.But if we want to launch using CURL request in bash script instead of any browser how can we use it ? URL which launch instance using browser request is as below http://exapmle.com:8080/awsphp/launch.php?Server=web&Region=ap-southeast-1&Ami=ami-0xxxxxxxxxx&SG=sg-9xxxxx&Key=webkey&AZ=ap-southeast-1a&instancesize=c4.xlarge&subnetid=subnet-b2xxxxxx&UD=bLXvZGVyCg%3D%3D

评论
  • (OoO)
    (OoO) 回复

    我真的建议不要在cURL请求中通过PHP sdk脚本构建基础结构(特别是如果这是面向外部的)。

    Personally I'd suggest looking at CloudFormation and using the AWS CLI to create a new stack from your template.

    然后在您的bash脚本中只需添加CLI命令

  • 萌小丁
    萌小丁 回复

    如果这是带有上述网址的简单get请求,则可以像这样简单地创建一个bash文件:

    create a file curl_script.sh

    #!/bin/bash
    
    curl --location --request GET 'http://exapmle.com:8080/awsphp/launch.php?Server=web&Region=ap-southeast-1&Ami=ami-0xxxxxxxxxx&SG=sg-9xxxxx&Key=webkey&AZ=ap-southeast-1a&instancesize=c4.xlarge&subnetid=subnet-b2xxxxxx&UD=bLXvZGVyCg%3D%3D'
    

    要运行文件,请使用以下命令授予文件执行权限

    chmod +x curl_script.sh

    使用运行文件

    ./curl_script.sh