forked from docs/doc-exports
Reviewed-by: Sarda, Priya <prsarda@noreply.gitea.eco.tsi-dev.otc-service.com> Co-authored-by: Hongwei, King Wang <king.wanghongwei@huawei.com> Co-committed-by: Hongwei, King Wang <king.wanghongwei@huawei.com>
167 lines
15 KiB
HTML
167 lines
15 KiB
HTML
<a name="EN-US_TOPIC_0000001854169169"></a><a name="EN-US_TOPIC_0000001854169169"></a>
|
|
|
|
<h1 class="topictitle1">Example 1: Creating a VPN Gateway</h1>
|
|
<div id="body8662426"><div class="section" id="EN-US_TOPIC_0000001854169169__en-us_topic_0000001543673208_section12746625155310"><h4 class="sectiontitle">Scenario</h4><p id="EN-US_TOPIC_0000001854169169__en-us_topic_0000001543673208_p0579103005312">This section describes how to create a VPN gateway by calling APIs.</p>
|
|
</div>
|
|
<div class="section" id="EN-US_TOPIC_0000001854169169__en-us_topic_0000001543673208_section18485140165314"><h4 class="sectiontitle">Prerequisites</h4><p id="EN-US_TOPIC_0000001854169169__en-us_topic_0000001543673208_p8881251215">You have determined the region where the VPN gateway is to be deployed and obtained the endpoint for calling APIs based on the region.</p>
|
|
<p id="EN-US_TOPIC_0000001854169169__en-us_topic_0000001543673208_p1288759216">You have obtained a user token if you need to use token authentication. In addition, you need to add <strong id="EN-US_TOPIC_0000001854169169__en-us_topic_0000001543673208_b360110227418">X-Auth-Token</strong> to the request header when calling an API. For details about token authentication, see "Authentication" in the <em id="EN-US_TOPIC_0000001854169169__en-us_topic_0000001543673208_i174359341834">Virtual Private Cloud API Reference</em>.</p>
|
|
</div>
|
|
<div class="section" id="EN-US_TOPIC_0000001854169169__en-us_topic_0000001543673208_section56198192543"><h4 class="sectiontitle">Data Preparation</h4>
|
|
<div class="tablenoborder"><table cellpadding="4" cellspacing="0" summary="" id="EN-US_TOPIC_0000001854169169__en-us_topic_0000001543673208_table444111294349" width="100%" frame="border" border="1" rules="all"><caption><b>Table 1 </b>Key parameters in the request for creating a VPN gateway</caption><thead align="left"><tr id="EN-US_TOPIC_0000001854169169__en-us_topic_0000001543673208_row3459182917345"><th align="left" class="cellrowborder" valign="top" width="21.68%" id="mcps1.3.3.2.2.4.1.1"><p id="EN-US_TOPIC_0000001854169169__en-us_topic_0000001543673208_p194595291340">Parameter</p>
|
|
</th>
|
|
<th align="left" class="cellrowborder" valign="top" width="35.9%" id="mcps1.3.3.2.2.4.1.2"><p id="EN-US_TOPIC_0000001854169169__en-us_topic_0000001543673208_p2459112916345">Description</p>
|
|
</th>
|
|
<th align="left" class="cellrowborder" valign="top" width="42.42%" id="mcps1.3.3.2.2.4.1.3"><p id="EN-US_TOPIC_0000001854169169__en-us_topic_0000001543673208_p11459102913414">Example Value</p>
|
|
</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody><tr id="EN-US_TOPIC_0000001854169169__en-us_topic_0000001543673208_row983893718349"><td class="cellrowborder" valign="top" width="21.68%" headers="mcps1.3.3.2.2.4.1.1 "><p id="EN-US_TOPIC_0000001854169169__en-us_topic_0000001543673208_p12677338484">vpc_id</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="35.9%" headers="mcps1.3.3.2.2.4.1.2 "><p id="EN-US_TOPIC_0000001854169169__en-us_topic_0000001543673208_p1283814373343">Specifies the ID of the VPC to which the VPN gateway connects.</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="42.42%" headers="mcps1.3.3.2.2.4.1.3 "><p id="EN-US_TOPIC_0000001854169169__en-us_topic_0000001543673208_p5838133711347"><span id="EN-US_TOPIC_0000001854169169__en-us_topic_0000001543673208_ph11205101019245">cb4a631d-demo-a8df-va86-ca3fa348c36c</span></p>
|
|
</td>
|
|
</tr>
|
|
<tr id="EN-US_TOPIC_0000001854169169__en-us_topic_0000001543673208_row337514017345"><td class="cellrowborder" valign="top" width="21.68%" headers="mcps1.3.3.2.2.4.1.1 "><p id="EN-US_TOPIC_0000001854169169__en-us_topic_0000001543673208_p18375840133418">local_subnets</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="35.9%" headers="mcps1.3.3.2.2.4.1.2 "><p id="EN-US_TOPIC_0000001854169169__en-us_topic_0000001543673208_p83751440153410">Specifies a local subnet.</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="42.42%" headers="mcps1.3.3.2.2.4.1.3 "><p id="EN-US_TOPIC_0000001854169169__en-us_topic_0000001543673208_p1337564019342">192.168.0.0/24,192.168.1.0/24</p>
|
|
</td>
|
|
</tr>
|
|
<tr id="EN-US_TOPIC_0000001854169169__en-us_topic_0000001543673208_row87344317345"><td class="cellrowborder" valign="top" width="21.68%" headers="mcps1.3.3.2.2.4.1.1 "><p id="EN-US_TOPIC_0000001854169169__en-us_topic_0000001543673208_p673243183412">connect_subnet</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="35.9%" headers="mcps1.3.3.2.2.4.1.2 "><p id="EN-US_TOPIC_0000001854169169__en-us_topic_0000001543673208_p107354319347">Specifies the ID of the VPC subnet used by the VPN gateway.</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="42.42%" headers="mcps1.3.3.2.2.4.1.3 "><p id="EN-US_TOPIC_0000001854169169__en-us_topic_0000001543673208_p113651598498"><span id="EN-US_TOPIC_0000001854169169__en-us_topic_0000001543673208_ph3235111212410">f5741286-demo-a8df-va86-2c82bd9ee114</span></p>
|
|
</td>
|
|
</tr>
|
|
<tr id="EN-US_TOPIC_0000001854169169__en-us_topic_0000001543673208_row1858634414013"><td class="cellrowborder" valign="top" width="21.68%" headers="mcps1.3.3.2.2.4.1.1 "><p id="EN-US_TOPIC_0000001854169169__en-us_topic_0000001543673208_p75861744708">eip1.id</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="35.9%" headers="mcps1.3.3.2.2.4.1.2 "><p id="EN-US_TOPIC_0000001854169169__en-us_topic_0000001543673208_p19898105793218">Specifies the ID of the active EIP used by the VPN gateway.</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="42.42%" headers="mcps1.3.3.2.2.4.1.3 "><p id="EN-US_TOPIC_0000001854169169__en-us_topic_0000001543673208_p1058714418017"><span id="EN-US_TOPIC_0000001854169169__en-us_topic_0000001543673208_ph9236212182415">cff40e5e-demo-a8df-va86-7366077bf097</span></p>
|
|
</td>
|
|
</tr>
|
|
<tr id="EN-US_TOPIC_0000001854169169__en-us_topic_0000001543673208_row16313347004"><td class="cellrowborder" valign="top" width="21.68%" headers="mcps1.3.3.2.2.4.1.1 "><p id="EN-US_TOPIC_0000001854169169__en-us_topic_0000001543673208_p133131479014">eip2.id</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="35.9%" headers="mcps1.3.3.2.2.4.1.2 "><p id="EN-US_TOPIC_0000001854169169__en-us_topic_0000001543673208_p67772381872">Specifies the ID of the standby EIP used by the VPN gateway.</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="42.42%" headers="mcps1.3.3.2.2.4.1.3 "><p id="EN-US_TOPIC_0000001854169169__en-us_topic_0000001543673208_p33131947006"><span id="EN-US_TOPIC_0000001854169169__en-us_topic_0000001543673208_ph92375122247">d290f1ee-demo-a8df-va86-d701748f0851</span></p>
|
|
</td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
</div>
|
|
<div class="section" id="EN-US_TOPIC_0000001854169169__en-us_topic_0000001543673208_section1456802195519"><h4 class="sectiontitle">Procedure</h4><ol id="EN-US_TOPIC_0000001854169169__en-us_topic_0000001543673208_ol1033516371743"><li id="EN-US_TOPIC_0000001854169169__en-us_topic_0000001543673208_li133351379413">Create a VPN gateway associated with a VPC.<ol type="a" id="EN-US_TOPIC_0000001854169169__en-us_topic_0000001543673208_ol7630731105015"><li id="EN-US_TOPIC_0000001854169169__en-us_topic_0000001543673208_li18354814195019">Send <strong id="EN-US_TOPIC_0000001854169169__en-us_topic_0000001543673208_b1330951655714">POST https://{endpoint}/v5/{project_id}/vpn-gateways</strong>.</li><li id="EN-US_TOPIC_0000001854169169__en-us_topic_0000001543673208_li12354121485016">Add <strong id="EN-US_TOPIC_0000001854169169__en-us_topic_0000001543673208_b1923919168508">X-Auth-Token</strong> to the request header.</li><li id="EN-US_TOPIC_0000001854169169__en-us_topic_0000001543673208_li735414146508">Specify the following parameters in the request body:<div class="codecoloring" codetype="Json" id="EN-US_TOPIC_0000001854169169__en-us_topic_0000001543673208_screen15411710162010"><div class="highlight"><table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><span class="normal"> 1</span>
|
|
<span class="normal"> 2</span>
|
|
<span class="normal"> 3</span>
|
|
<span class="normal"> 4</span>
|
|
<span class="normal"> 5</span>
|
|
<span class="normal"> 6</span>
|
|
<span class="normal"> 7</span>
|
|
<span class="normal"> 8</span>
|
|
<span class="normal"> 9</span>
|
|
<span class="normal">10</span>
|
|
<span class="normal">11</span>
|
|
<span class="normal">12</span>
|
|
<span class="normal">13</span>
|
|
<span class="normal">14</span>
|
|
<span class="normal">15</span></pre></div></td><td class="code"><div><pre><span></span><span class="p">{</span>
|
|
<span class="w"> </span><span class="nt">"vpn_gateway"</span><span class="p">:</span><span class="w"> </span><span class="p">{</span>
|
|
<span class="w"> </span><span class="nt">"vpc_id"</span><span class="p">:</span><span class="w"> </span><span class="s2">"cb4a631d-demo-a8df-va86-ca3fa348c36c"</span><span class="p">,</span>
|
|
<span class="w"> </span><span class="nt">"local_subnets"</span><span class="p">:</span><span class="w"> </span><span class="p">[</span>
|
|
<span class="w"> </span><span class="s2">"192.168.0.0/24"</span><span class="p">,</span><span class="w"> </span><span class="s2">"192.168.1.0/24"</span>
|
|
<span class="w"> </span><span class="p">],</span>
|
|
<span class="w"> </span><span class="nt">"connect_subnet"</span><span class="p">:</span><span class="w"> </span><span class="s2">"f5741286-demo-a8df-va86-2c82bd9ee114"</span><span class="p">,</span>
|
|
<span class="w"> </span><span class="nt">"eip1"</span><span class="p">:</span><span class="w"> </span><span class="p">{</span>
|
|
<span class="w"> </span><span class="nt">"id"</span><span class="p">:</span><span class="w"> </span><span class="s2">"cff40e5e-demo-a8df-va86-7366077bf097"</span>
|
|
<span class="w"> </span><span class="p">},</span>
|
|
<span class="w"> </span><span class="nt">"eip2"</span><span class="p">:</span><span class="w"> </span><span class="p">{</span>
|
|
<span class="w"> </span><span class="nt">"id"</span><span class="p">:</span><span class="w"> </span><span class="s2">"d290f1ee-demo-a8df-va86-d701748f0851"</span>
|
|
<span class="w"> </span><span class="p">}</span>
|
|
<span class="w"> </span><span class="p">}</span>
|
|
<span class="p">}</span>
|
|
</pre></div></td></tr></table></div>
|
|
</div>
|
|
</li><li id="EN-US_TOPIC_0000001854169169__en-us_topic_0000001543673208_li1963133185019">Check the response.<ul id="EN-US_TOPIC_0000001854169169__en-us_topic_0000001543673208_ul1363113195012"><li id="EN-US_TOPIC_0000001854169169__en-us_topic_0000001543673208_li1463173112507">The request is successful if the following response is displayed. In the response, <strong id="EN-US_TOPIC_0000001854169169__en-us_topic_0000001543673208_b5551128115110">id</strong> indicates a VPN gateway ID.<pre class="screen" id="EN-US_TOPIC_0000001854169169__en-us_topic_0000001543673208_screen171005619358">{
|
|
"vpn_gateway": {
|
|
"id": "620d99b8-demo-a8df-va86-200b868f2d7d",
|
|
"name": "vpngw-3caf",
|
|
"network_type": "public",
|
|
"attachment_type": "vpc",
|
|
"vpc_id": "cb4a631d-demo-a8df-va86-ca3fa348c36c",
|
|
"local_subnets": ["192.168.0.0/24", "192.168.1.0/24"],
|
|
"connect_subnet": "f5741286-demo-a8df-va86-2c82bd9ee114",
|
|
"bgp_asn": 64512,
|
|
"access_vpc_id": "cb4a631d-demo-a8df-va86-ca3fa348c36c",
|
|
"access_subnet_id": "f5741286-demo-a8df-va86-2c82bd9ee114",
|
|
"flavor": "Professional1",
|
|
"used_connection_number": 0,
|
|
"used_connection_group": 0,
|
|
"enterprise_project_id": "0"
|
|
},
|
|
"request_id": "4a739f5c-edb7-4122-b31f-b77fb1b94857"
|
|
}</pre>
|
|
</li></ul>
|
|
</li></ol>
|
|
</li><li id="EN-US_TOPIC_0000001854169169__en-us_topic_0000001543673208_li1355101465012">Query details about the VPN gateway.<ol type="a" id="EN-US_TOPIC_0000001854169169__en-us_topic_0000001543673208_ol20234130522"><li id="EN-US_TOPIC_0000001854169169__en-us_topic_0000001543673208_li72356313526">Send <strong id="EN-US_TOPIC_0000001854169169__en-us_topic_0000001543673208_b1030272110592">GET https://{endpoint}/v5/{project_id}/vpn-gateways/{vgw_id}</strong>.</li><li id="EN-US_TOPIC_0000001854169169__en-us_topic_0000001543673208_li1273661465214">Add <strong id="EN-US_TOPIC_0000001854169169__en-us_topic_0000001543673208_b167110217516">X-Auth-Token</strong> to the request header.</li><li id="EN-US_TOPIC_0000001854169169__en-us_topic_0000001543673208_li16736141415527">Check the response.<ul id="EN-US_TOPIC_0000001854169169__en-us_topic_0000001543673208_ul1125434058"><li id="EN-US_TOPIC_0000001854169169__en-us_topic_0000001543673208_li1125534656">The request is successful if the following response is displayed. In the response, <strong id="EN-US_TOPIC_0000001854169169__en-us_topic_0000001543673208_b2265101819532">id</strong> indicates a VPN gateway ID.<pre class="screen" id="EN-US_TOPIC_0000001854169169__en-us_topic_0000001543673208_screen994025835015">{
|
|
"vpn_gateway": {
|
|
"id": "620d99b8-demo-a8df-va86-200b868f2d7d",
|
|
"name": "vpngw-3caf",
|
|
"network_type": "public",
|
|
"status": "ACTIVE",
|
|
"attachment_type": "vpc",
|
|
"vpc_id": "cb4a631d-demo-a8df-va86-ca3fa348c36c",
|
|
"local_subnets": [
|
|
"192.168.0.0/24", "192.168.1.0/24"
|
|
],
|
|
"connect_subnet": "f5741286-demo-a8df-va86-2c82bd9ee114",
|
|
"access_vpc_id": "cb4a631d-demo-a8df-va86-ca3fa348c36c",
|
|
"access_subnet_id": "f5741286-demo-a8df-va86-2c82bd9ee114",
|
|
"bgp_asn": 64512,
|
|
"flavor": "Professional1",
|
|
"availability_zone_ids": [
|
|
<span id="EN-US_TOPIC_0000001854169169__en-us_topic_0000001543673208_ph1114415436191"> "eu-de-01", "eu-de-02"</span>
|
|
],
|
|
"used_connection_number": 0,
|
|
"used_connection_group": 0,
|
|
"enterprise_project_id": "0",
|
|
"eip1": {
|
|
"id": "cff40e5e-demo-a8df-va86-7366077bf097",
|
|
"ip_version": 4,
|
|
"type": "5_bgp",
|
|
"ip_address": "88.***.***.8",
|
|
<span id="EN-US_TOPIC_0000001854169169__en-us_topic_0000001543673208_ph5400104664219"> "charge_mode": "traffic",</span>
|
|
"bandwidth_id": "593a1a79-demo-a8df-va86-64ec45fb23f6",
|
|
"bandwidth_size": 300,
|
|
"bandwidth_name": "vpngw-bandwidth-1391"
|
|
},
|
|
"eip2": {
|
|
"id": "d290f1ee-demo-a8df-va86-d701748f0851",
|
|
"ip_version": 4,
|
|
"type": "5_bgp",
|
|
"ip_address": "88.***.***.6",
|
|
<span id="EN-US_TOPIC_0000001854169169__en-us_topic_0000001543673208_ph1041919111437"> "charge_mode": "traffic",</span>
|
|
"bandwidth_id": "0abb9d55-demo-a8df-va86-b7500ac2a338",
|
|
"bandwidth_size": 300,
|
|
"bandwidth_name": "vpngw-bandwidth-1392"
|
|
},
|
|
"created_at": "2022-09-15T08:56:09.386Z",
|
|
"updated_at": "2022-09-15T11:13:13.677Z"
|
|
},
|
|
"request_id": "d099a7dc-ea71-45a6-a75b-dccbfe17d438"
|
|
} </pre>
|
|
</li></ul>
|
|
</li></ol>
|
|
</li></ol>
|
|
</div>
|
|
</div>
|
|
<div>
|
|
<div class="familylinks">
|
|
<div class="parentlink"><strong>Parent topic:</strong> <a href="vpn_api_0039.html">Application Examples</a></div>
|
|
</div>
|
|
</div>
|
|
|