【问题标题】:Trigger aws php sdk browser URL with CURL request in bash script在 bash 脚本中使用 CURL 请求触发 aws php sdk 浏览器 URL
【发布时间】:2020-05-17 15:22:53
【问题描述】:

我们已经使用 php 设置了 aws php sdk 来启动 aws ec2 实例。当我们使用任何浏览器运行它时,它会启动一个 ec2 实例。但是如果我们想在 bash 脚本中使用 CURL 请求而不是任何浏览器来启动它,我们该如何使用它呢? 使用浏览器请求启动实例的 URL 如下 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

【问题讨论】:

    标签: php linux amazon-web-services curl sdk


    【解决方案1】:

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

    我个人建议查看 CloudFormation 并使用 AWS CLI to create a new stack from your template

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

    【讨论】:

      【解决方案2】:

      如果是使用上述 url 的简单 get 请求,您可以像这样简单地创建一个 bash 文件:

      创建文件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

      【讨论】:

        猜你喜欢
        • 2013-03-19
        • 1970-01-01
        • 1970-01-01
        • 2019-12-20
        • 1970-01-01
        • 1970-01-01
        • 2023-03-10
        • 2020-05-07
        • 2016-08-19
        相关资源
        最近更新 更多