Building a Program
Download the graceful shutdown program package as_graceful_shutdown.zip and create a function from scratch.
Creating a Function
- Log in to the FunctionGraph console, and choose Functions > Function List in the navigation pane.
- Click Create Function.
- Click Create from scratch and configure the function information. After setting the basic information, click Create Function.
- Function Type: Select Event Function.
- Function Name: Enter as_graceful_shutdown.
- Agency: Select ASOperation created in Creating an Agency.
- Runtime: Select Python 3.6.
- On the Code tab of the as_graceful_shutdown function details page, choose Upload > Local ZIP, upload the sample code as_graceful_shutdown.zip. Choose Configuration > Basic Settings, set the following parameters, and click Save.
- Memory: Select 128.
- Execution Timeout: Enter 10.
- Handler: Retain the default value index.handler.
- App: Retain the default value default.
- Description: Enter Graceful shutdown with AS.
Setting Environment Variables
On the details page of function as_graceful_shutdown, choose Configuration > Environment Variables, set environment variables according to Table 1, and click Save.
Environment Variable |
Description |
---|---|
region |
Region of your AS group. |
projectId |
Project ID of your AS group. |
ak |
Access key ID, which is a unique identifier used in conjunction with a secret access key to sign requests cryptographically. For details about how to obtain an AK, see Obtaining an AK/SK. |
sk |
Secret access key used together with an AK to sign requests cryptographically. It identifies a request sender and prevents the request from being modified. For details about how to obtain an SK, see Obtaining an AK/SK. |
Adding Dependencies
- Create dependencies huaweicloudsdk_ecs_core_py3.6 and huaweicloudsdk_as_core_py3.6. For more information, see Creating a Dependency.
You can also download the dependencies provided by FunctionGraph if needed:
- huaweicloudsdk_ecs_core_py3.6
- huaweicloudsdk_as_core_py3.6 (coming soon)
- Return to the FunctionGraph console, and choose Functions > Dependencies in the navigation pane. Click Create Dependency, and create dependencies huaweicloudsdk_ecs_core_py3.6 and huaweicloudsdk_as_core_py3.6 successively.
- Set the dependency information and click OK.
- Name: Enter huaweicloudsdk_ecs_core_py3.6 or huaweicloudsdk_as_core_py3.6.
- Code Entry Mode: Select Upload ZIP.
- Upload File: Select the target ZIP file.
- Runtime: Select Python 3.6.
Figure 1 Creating a dependency
- Go to the details page of function as_graceful_shutdown, click the Code tab, and click Add in the Dependencies area at the bottom.
- Add dependencies huaweicloudsdk_ecs_core_py3.6 and huaweicloudsdk_as_core_py3.6.
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot