11月初,阿裡雲ROS正式釋出API 網關(API Gateway)資源,為雲計算使用者提供高性能、高可用的 API 托管服務,幫助使用者對外開放其部署在 ECS、容器服務等阿裡雲産品上的應用,提供完整的 API 釋出、管理、維護生命周期管理。使用者隻需進行簡單的操作,即可快速、低成本、低風險地開放資料或服務。
使用者隻需要按照自己的需求,根據ROS的模闆規範,定義自己的API管理模闆,就可以輕輕松松實作API組的建立/更新,API的建立/更新,API的釋出或者版本切換,以及API授權,簽名,流控等等的配置預更新。
以建立和釋出一個新API到測試環境為例。首先使用者先根據ROS的模闆規範定義自己的模闆,模闆中會包含下面的幾個資源,具體的資源介紹詳見幫助文檔,
ALIYUN::ApiGateway::Group,
ALIYUN::ApiGateway::API,
ALIYUN::ApiGateway::Deployment
一個最簡單的模闆定義如下:
{
"ROSTemplateFormatVersion": "2015-09-01",
"Description": "Create an API Gateway",
"Parameters": {
},
"Resources": {
"Outputs": {
}
然後在ROS的控制台(ros.console.aliyun.com)送出你的模闆:
進入ROS的控制台如下圖所示,然後點選“建立資源棧”按鈕。

接着會展示新的頁面如下,需要在新的頁面中選擇region,填入上面提供的模闆,然後點選“下一步”。
緊接着會切換到這個頁面,需要再屬于一些建立時的參數資訊,資源棧的名稱,以及你需要在哪個環境釋出API。參數設定好之後,點選“建立”按鈕。
ROS 編排引擎就會根據模闆和參數資訊,建立API分組,API,并最終釋出到測試環境。傳回到資源棧管理頁面,可以看到如下面的資訊,名為“my_api_v1”的資源棧建立成功。
點選資源棧名,就可以檢視資源棧的相關屬性。我們上面的模闆中定義了要輸出API分組的ID和API 的ID。
跳轉到API 網關的控制台,就可以看到我們通過模闆所建立的API。
以上是通過ROS的控制台來建立,釋出API。
ROS 目前支援的所有 API 網關的資源類型如下:
ALIYUN::ApiGateway::Group
<a href="https://help.aliyun.com/document_detail/61467.html?spm=5176.doc61480.6.650.0oTm2p">https://help.aliyun.com/document_detail/61467.html?spm=5176.doc61480.6.650.0oTm2p</a>
建立 API 分組
ALIYUN::ApiGateway::StageConfig::SignatureBinding
<a href="https://help.aliyun.com/document_detail/61483.html?spm=5176.doc61482.6.652.43jUI8">https://help.aliyun.com/document_detail/61483.html?spm=5176.doc61482.6.652.43jUI8</a>
建立 API 分組中測試、預發、線上環境變量
ALIYUN::ApiGateway::Api
<a href="https://help.aliyun.com/document_detail/61459.html?spm=5176.doc28930.6.645.VIyhF4">https://help.aliyun.com/document_detail/61459.html?spm=5176.doc28930.6.645.VIyhF4</a>
建立 API
ALIYUN::ApiGateway::App
<a href="https://help.aliyun.com/document_detail/61468.html?spm=5176.doc61459.6.646.jep7UM">https://help.aliyun.com/document_detail/61468.html?spm=5176.doc61459.6.646.jep7UM</a>
建立應用
ALIYUN::ApiGateway::Authorization
<a href="https://help.aliyun.com/document_detail/61478.html?spm=5176.doc61468.6.647.wFQfvi">https://help.aliyun.com/document_detail/61478.html?spm=5176.doc61468.6.647.wFQfvi</a>
給 API 授權應用的通路權限
ALIYUN::ApiGateway::CustomDomain
<a href="https://help.aliyun.com/document_detail/61479.html?spm=5176.doc61478.6.648.O62moc">https://help.aliyun.com/document_detail/61479.html?spm=5176.doc61478.6.648.O62moc</a>
給 API 分組建立綁定自定義域名
<a href="https://help.aliyun.com/document_detail/61480.html?spm=5176.doc61479.6.649.s0Ltp0">https://help.aliyun.com/document_detail/61480.html?spm=5176.doc61479.6.649.s0Ltp0</a>
釋出 API 或快速切換 API 版
ALIYUN::ApiGateway::Signature
<a href="https://help.aliyun.com/document_detail/61482.html?spm=5176.doc61467.6.651.JHTCZz">https://help.aliyun.com/document_detail/61482.html?spm=5176.doc61467.6.651.JHTCZz</a>
建立後端簽名密鑰
ALIYUN::ApiGateway::SignatureBinding
綁定 API 與後端簽名密鑰
ALIYUN::ApiGateway::TrafficControl
<a href="https://help.aliyun.com/document_detail/61485.html?spm=5176.doc61484.6.654.u6Ymvw">https://help.aliyun.com/document_detail/61485.html?spm=5176.doc61484.6.654.u6Ymvw</a>
建立使用者自定義的流控政策
ALIYUN::ApiGateway::TrafficControlBinding
<a href="https://help.aliyun.com/document_detail/61488.html?spm=5176.doc61485.6.655.cz94Ob">https://help.aliyun.com/document_detail/61488.html?spm=5176.doc61485.6.655.cz94Ob</a>
給 API 綁定使用者自定義流控
ALIYUN::ApiGateway::VpcAccessConfig
<a href="https://help.aliyun.com/document_detail/61489.html?spm=5176.doc61488.6.656.KXYFQT">https://help.aliyun.com/document_detail/61489.html?spm=5176.doc61488.6.656.KXYFQT</a>
配置 VPC 授權以便專有網絡的 API 能對外提供服務
ROS也支援openAPI的方式做資源的操作,具體可以參考ROS雲栖部落格索引
<a href="https://yq.aliyun.com/articles/57553?spm=5176.100239.0.0.LzywAe">https://yq.aliyun.com/articles/57553?spm=5176.100239.0.0.LzywAe</a>
中的這兩篇文章,
1、《阿裡雲資源編排服務Python SDK使用入門 》
<a href="https://yq.aliyun.com/articles/6904?spm=5176.100239.blogcont57553.66.N4yGwL">https://yq.aliyun.com/articles/6904?spm=5176.100239.blogcont57553.66.N4yGwL</a>
2、《阿裡雲資源編排服務Java SDK使用入門》
<a href="https://yq.aliyun.com/articles/113503?spm=5176.100239.blogcont57553.67.N4yGwL">https://yq.aliyun.com/articles/113503?spm=5176.100239.blogcont57553.67.N4yGwL</a>
同時使用者也可以通過ROS的指令行
<a href="https://yq.aliyun.com/articles/215216?spm=5176.100239.blogcont57553.72.N4yGwL">https://yq.aliyun.com/articles/215216?spm=5176.100239.blogcont57553.72.N4yGwL</a>
工具建立實作資源的建立,更新等等操作。