AppConfig PythonAWS Appconfig Python
These are the High-Level Steps
Prerequisites
How to Create AWS AppConfig ResourcesTo save the configuration for your application, first, build the AWS AppConfig resources. These sources consist of:
AWS CloudFormation template can be launched to create a variety of resources. Ascertain that your command line environment is configured to use AWS Region us-east-1, which is the same region as the template. In Order to Create, on Your Own, Resources, the Below-Given Steps must be Followed:
The JSON document of yours as a configuration version 1 will be handed in when the software requests it. How to Create the Python ApplicationMake the Python programme next. The Virtual Environment space should be utilized to install the libraries(Python) as a good exercise.The solution makes use of the FastAPI package to provide API capabilities, as well as the AWS AppConfig utility and unicorn to provide an HTTP server. Note: The Python package installer, pip, and python were taken into consideration when writing these instructions since they both presume a Python 3 installation. Instead, pip3 and python3 may be required.1. Make a folder where you will build and store the project. 2. Create a virtual environment: 3. Get the virtual environment active: Note: You must run this command in each new terminal window or shell that you open.In your editor, save the following text as rqumnts.txt in the appconfig-demo folder. 4. Install the libraries. 5. Create a new file in your editor with the following contents, and then save it as main.py and place it in the appconfig-demo folder. This code first imports the necessary libraries before creating an instance of the AppConfigHelper class. The library has instructed the configuration to obtain from the AWS AppConfig API by the first three values given. These are the names you supplied to the application, environment, and profile previously. The final value is the time between API queries for new configuration modifications. When calling the API, the library adheres to AWS AppConfig's best practices. It mentions a client ID and the configuration document's most recent receipt version. AWS AppConfig can deliver the configuration in intervals in accordance with the deployment strategy being used, thanks to the client ID. The API can rapidly alert you whether you already have the right configuration version, thanks to the last-received version of the configuration. If this value is omitted from the API request, AWS AppConfig responds with the whole configuration file, which results in an extra fee. A client sending a request with an Assuming-Modified-Since header and obtaining a 304 Not Modified response code is analogous to this (if you are familiar with HTTP requests and caching). The code creates a handler for your HTTP API's /process-string path, which accepts an input parameter to operate with. The AppConfigHelper instance's update config() function is the first thing the handler calls. The library makes a call to the AWS AppConfig API to see whether any new configurations have been added if it has been more than 15 seconds since the previous check. The handler then examines the values of the two feature flags in the received configuration (which was made available by the library as the config property) and modifies the input text as needed. The JSON file was automatically processed by the helper library. Finally, the result is returned to FastAPI and unicorn so that it can be transmitted to the requestor. Test the ApplicationStart the application now and test it to check if it reverses the input string but does not capitalize it in accordance with the feature flags you set.
Your program has the configuration and is inverting the input as instructed, but it is not changing it to all capitalised characters. Deploy a Configuration Update that Enables all-caps Mode
Now, the output value must be capitalized and in reverse. Before making the adjustment again, wait 15 seconds to ensure the library checks for a new configuration version. Cleaning UpAlthough there are no fees associated with storing AWS AppConfig resources, if you won't be using them again, you may want to wipe away the resources.
ConclusionUsing the AWS AppConfig helper module, we discovered how to combine AWS AppConfig with a Python application. Some other features, like what we call syntactic configuration and semantic configuration validation, deployment rate controls, monitoring your application, and rolling back in the event of errors, along with dynamically deploying configuration updates to your applications, can be verified by using the codes given above. Next TopicBoto3 Python Module |
We provides tutorials and interview questions of all technology like java tutorial, android, java frameworks
G-13, 2nd Floor, Sec-3, Noida, UP, 201301, India