简体   繁体   English

如何编写用于在 AWS 中创建 API 网关的 shell 脚本

[英]how to write a shell script for creating an API gateway in AWS

我已经使用 UI 在 AWS 中创建了一个 API 网关,我想自动化这个过程并编写一个 shell 脚本来创建 API 网关,就像我在 AWS 中配置它一样。

As already suggested, I also recommend using better tools such as cloudformation to manage the infrastructure.正如已经建议的那样,我还建议使用更好的工具(例如 cloudformation)来管理基础架构。

If you really want to use bash script, you can use AWS Cli commands in your bash script.如果您确实想使用 bash 脚本,则可以在 bash 脚本中使用 AWS Cli 命令。

create API创建 API

aws apigateway create-rest-api --name my-api aws apigateway create-rest-api --name my-api

get root resource获取根资源

API=bs8fqo6bp0 aws apigateway get-resources --rest-api-id $API API=bs8fqo6bp0 aws apigateway get-resources --rest-api-id $API

create resource创建资源

aws apigateway create-resource --rest-api-id $API --path-part test \\ --parent-id e8kitthgdb aws apigateway 创建资源 --rest-api-id $API --path-part test \\ --parent-id e8kitthgdb

here is an example from AWS docs, https://docs.aws.amazon.com/lambda/latest/dg/with-on-demand-https-example.html这是 AWS 文档中的一个示例, https://docs.aws.amazon.com/lambda/latest/dg/with-on-demand-https-example.html

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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