简体   繁体   中英

Trigger aws php sdk browser URL with CURL request in bash script

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&su.netid=su.net-b2xxxxxx&UD=bLXvZGVyCg%3D%3D

I would really advise against building infrastructure via PHP sdk script in a cURL request (especially if this is external facing).

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

Then in your bash script just add the CLI command

If it's a simple get request with the above url, you can simply create a bash file like so:

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'

To run the file, give execution permission to the file with

chmod +x curl_script.sh

Run the file with

./curl_script.sh

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM