diff --git a/app/server.py b/app/server.py index ad15339..d4c9afe 100644 --- a/app/server.py +++ b/app/server.py @@ -1,5 +1,6 @@ import asyncio import yaml +import boto3 from os.path import join, dirname from aiohttp import web import concurrent.futures @@ -93,6 +94,20 @@ async def post_exit(_): else: sys.exit(1) +@routes.post('/lightsail_regions') +async def post_exit(request): + data = await request.json() + client = boto3.client( + 'lightsail', + aws_access_key_id=data.get('aws_access_key'), + aws_secret_access_key=data.get('aws_secret_key') + ) + response = client.get_regions( + includeAvailabilityZones=False + ) + return web.json_response(response) + + app = web.Application() app.router.add_routes(routes) app.add_routes([web.static('/static', join(PROJECT_ROOT, 'app', 'static'))]) diff --git a/app/static/provider-lightsail.vue b/app/static/provider-lightsail.vue index b0fd906..8df377b 100644 --- a/app/static/provider-lightsail.vue +++ b/app/static/provider-lightsail.vue @@ -11,6 +11,7 @@ type="text" class="form-control" name="aws_access_key" + v-on:blur="load_regions" v-model="aws_access_key" /> @@ -21,8 +22,26 @@ type="password" class="form-control" name="aws_secret_key" + v-on:blur="load_regions" v-model="aws_secret_key"> +
+ + + + + +