Files
doc-exports/docs/fg/umn/functiongraph_03_0839.html
chenjunjie da8877ec76 FG UMN 20241021 version
Reviewed-by: Mützel, Andrea <andrea.muetzel@t-systems.com>
Co-authored-by: chenjunjie <chenjunjie@huawei.com>
Co-committed-by: chenjunjie <chenjunjie@huawei.com>
2025-05-20 13:39:19 +00:00

53 lines
9.0 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<a name="functiongraph_03_0839"></a><a name="functiongraph_03_0839"></a>
<h1 class="topictitle1">How Does FunctionGraph Implement Domain Name Resolution?</h1>
<div id="body0000001275571889"><p id="functiongraph_03_0839__p111601850324">FunctionGraph cannot directly resolve private DNS domain names. To resolve them, call DNS APIs and perform the following steps.</p>
<div class="section" id="functiongraph_03_0839__section723623122912"><h4 class="sectiontitle">Resolving a Private DNS Domain Name with an Event Function</h4><p id="functiongraph_03_0839__p0241289307">Ensure that a VPC and private DNS domain name have been created before performing the following steps:</p>
<ol id="functiongraph_03_0839__ol4140750144620"><li id="functiongraph_03_0839__li114055054619">Associate a VPC with the private domain name and add record sets.<p id="functiongraph_03_0839__p1654932474217"><a name="functiongraph_03_0839__li114055054619"></a><a name="li114055054619"></a>Log in to the DNS console and associate a VPC with the private domain name.</p>
<div class="fignone" id="functiongraph_03_0839__fig14690103117243"><span class="figcap"><b>Figure 1 </b>Associating a VPC with the private domain name</span><br><span><img id="functiongraph_03_0839__image9690331102414" src="en-us_image_0000002250724973.png" title="Click to enlarge" class="imgResize"></span></div>
<p id="functiongraph_03_0839__p1123416214332">Click the domain name, and add a type A record set.</p>
<div class="fignone" id="functiongraph_03_0839__fig1544424002811"><span class="figcap"><b>Figure 2 </b>Adding a record set</span><br><span><img id="functiongraph_03_0839__image1044414019281" src="en-us_image_0000002250645069.png" title="Click to enlarge" class="imgResize"></span></div>
</li><li id="functiongraph_03_0839__li614065010467"><a name="functiongraph_03_0839__li614065010467"></a><a name="li614065010467"></a>Create a function.<p id="functiongraph_03_0839__p07135361550"><a name="functiongraph_03_0839__li614065010467"></a><a name="li614065010467"></a>Create a function whose runtime is Python 2.7. The following is sample code.</p>
<pre class="screen" id="functiongraph_03_0839__screen045452051412"># -*- coding:utf-8 -*-
import json
import os
def handler(event, context):
os.system("curl -iv www.test.com")</pre>
</li><li id="functiongraph_03_0839__li1714025011466"><a name="functiongraph_03_0839__li1714025011466"></a><a name="li1714025011466"></a>Configure an agency with DNS and VPC permissions for the function.<p id="functiongraph_03_0839__p1798711118189"><a name="functiongraph_03_0839__li1714025011466"></a><a name="li1714025011466"></a>Log in to the IAM console, and configure an agency with the <strong id="functiongraph_03_0839__b52141631182916">DNS ReadOnlyAccess</strong> and <strong id="functiongraph_03_0839__b1462543616295">VPC Administrator</strong> permissions for FunctionGraph. </p>
<div class="fignone" id="functiongraph_03_0839__fig137075651315"><span class="figcap"><b>Figure 3 </b>Creating an agency with DNS and VPC permissions</span><br><span><img id="functiongraph_03_0839__image117075661310" src="en-us_image_0000002269988645.png" title="Click to enlarge" class="imgResize"></span></div>
<div class="note" id="functiongraph_03_0839__note2047524523718"><img src="public_sys-resources/note_3.0-en-us.png"><span class="notetitle"> </span><div class="notebody"><p id="functiongraph_03_0839__p247544533717">You need to configure the permission to read DNS resource data because the function needs to obtain such data when resolving a domain name. Otherwise, the following error message is displayed, indicating that the DNS resource data failed to be obtained.</p>
<pre class="screen" id="functiongraph_03_0839__screen310853124016">2020/08/20 10:37:12 GMT+08:00 Start invoke request 'a2f105b4-2e72-4fda-94a5-86d3837e961d', version: latest
<strong id="functiongraph_03_0839__b484310381414">[GET /v2/zones/{zone_id}/recordsets] failed, response: {"code":"DNS.1802","message":"Policy doesn't allow dns:recordset:list to be performed."}</strong>
2020/08/20 10:37:13 GMT+08:00 Finish invoke request 'a2f105b4-2e72-4fda-94a5-86d3837e961d', duration: 1030.072ms, billing duration: 1100ms, memory used: 77.039MB.</pre>
</div></div>
</li><li id="functiongraph_03_0839__li151411550134619">Configure the function.<p id="functiongraph_03_0839__p14239125822310"><a name="functiongraph_03_0839__li151411550134619"></a><a name="li151411550134619"></a>On the details page of the function created in <a href="#functiongraph_03_0839__li614065010467">step 2</a>, click the <strong id="functiongraph_03_0839__b1323612113218">Configuration</strong> tab and configure the following settings:</p>
<ol type="a" id="functiongraph_03_0839__ol1146511522414"><li id="functiongraph_03_0839__li13466657243">For <strong id="functiongraph_03_0839__b1454723833811">Permissions</strong>, select the agency created in <a href="#functiongraph_03_0839__li1714025011466">step 3</a>.</li><li id="functiongraph_03_0839__li1619781714245">Enable VPC access and select the created VPC, subnet, and domain name.</li></ol>
<div class="fignone" id="functiongraph_03_0839__fig9673104713339"><span class="figcap"><b>Figure 4 </b>Configuring the function</span><br><span><img id="functiongraph_03_0839__image136742047103314" src="en-us_image_0000002250645081.png" title="Click to enlarge" class="imgResize"></span></div>
</li><li id="functiongraph_03_0839__li2014195074618">Check the execution result.<p id="functiongraph_03_0839__p11382139132911"><a name="functiongraph_03_0839__li2014195074618"></a><a name="li2014195074618"></a>All configured IPv4 domain names can be resolved.</p>
<div class="fignone" id="functiongraph_03_0839__fig10783957192912"><span class="figcap"><b>Figure 5 </b>Executing the function</span><br><span><img id="functiongraph_03_0839__image191549363299" src="en-us_image_0000002215725106.png" title="Click to enlarge" class="imgResize"></span></div>
</li></ol>
<div class="note" id="functiongraph_03_0839__note1695220317132"><img src="public_sys-resources/note_3.0-en-us.png"><span class="notetitle"> </span><div class="notebody"><p id="functiongraph_03_0839__p10953831121312">Changes to the IP addresses corresponding to the VPC domain names you configure will take effect in 10 minutes.</p>
</div></div>
</div>
<div class="section" id="functiongraph_03_0839__section157058495714"><h4 class="sectiontitle">Resolving a Private DNS Domain Name with a Container Imagebased Function</h4><ol id="functiongraph_03_0839__ol1881444185819"><li id="functiongraph_03_0839__li381434116587">Obtain a private domain name and zone ID.<p id="functiongraph_03_0839__p1078915413574"><a name="functiongraph_03_0839__li381434116587"></a><a name="li381434116587"></a>This procedure uses a domain name with a record set as an example.</p>
<ol type="a" id="functiongraph_03_0839__ol1579018417579"><li id="functiongraph_03_0839__li187905410573">Log in to the DNS console.</li><li id="functiongraph_03_0839__li179908192214">Obtain a zone ID.<p id="functiongraph_03_0839__p3605917173819"><a name="functiongraph_03_0839__li179908192214"></a><a name="li179908192214"></a>Click <span><img id="functiongraph_03_0839__image1160131743813" src="en-us_image_0000002248343474.png"></span>, and select <strong id="functiongraph_03_0839__b175173261409">Domain Name</strong> in the search box to obtain a zone ID.</p>
</li><li id="functiongraph_03_0839__li27901446579">Obtain the private domain name corresponding to a recording set.<p id="functiongraph_03_0839__p1079019410578"><a name="functiongraph_03_0839__li27901446579"></a><a name="li27901446579"></a>Click the domain name to go to the record set list, and select a record set.</p>
</li></ol>
</li></ol><ol start="2" id="functiongraph_03_0839__ol1886674214412"><li id="functiongraph_03_0839__li5866742446">Compile the resolution logic.<p id="functiongraph_03_0839__p179134115711"><a name="functiongraph_03_0839__li5866742446"></a><a name="li5866742446"></a>Use to debug the API used to <a href="https://docs.otc.t-systems.com/domain-name-service/api-ref/apis/record_set_management/querying_record_sets_in_a_zone.html#dns-api-64004" target="_blank" rel="noopener noreferrer">query record sets in a zone</a>.</p>
<ul id="functiongraph_03_0839__ul81891233102017"><li id="functiongraph_03_0839__li13189103311203">Set <strong id="functiongraph_03_0839__b153075491429">zone_id</strong> to the zone ID obtained in the preceding step, and click <strong id="functiongraph_03_0839__b430794919421">Debug</strong>. The IP address of the private domain name is displayed in the response body.</li><li id="functiongraph_03_0839__li12621282118">Switch to the <strong id="functiongraph_03_0839__b13966105864215">Sample Code</strong> tab to obtain the complete code. For details about the dependencies, click <strong id="functiongraph_03_0839__b79672587423">View SDK Details</strong>.</li></ul>
</li></ol>
</div>
</div>
<div>
<div class="familylinks">
<div class="parentlink"><strong>Parent topic:</strong> <a href="functiongraph_03_0110_00.html">General FAQs</a></div>
</div>
</div>
<script language="JavaScript">
<!--
image_size('.imgResize');
var msg_imageMax = "view original image";
var msg_imageClose = "close";
//--></script>