add search filter
This commit is contained in:
@@ -4,3 +4,6 @@ USER_TABLE: str = os.getenv('USER_TABLE') # type: ignore
|
||||
CHUNK_SIZE = 50
|
||||
|
||||
EMAIL_SENDER = ('EDUSEG®', 'noreply@eduseg.com.br')
|
||||
|
||||
CLOUDFLARE_ACCOUNT_ID = '5436b62470020c04b434ad31c3e4cf4e'
|
||||
CLOUDFLARE_ZONE_ID = '95c5be1f8ac60e7fd243e6dda987d758'
|
||||
|
||||
49
users-events/app/events/set_custom_domain.py
Normal file
49
users-events/app/events/set_custom_domain.py
Normal file
@@ -0,0 +1,49 @@
|
||||
from aws_lambda_powertools.utilities.data_classes import (
|
||||
EventBridgeEvent,
|
||||
event_source,
|
||||
)
|
||||
from aws_lambda_powertools.utilities.typing import LambdaContext
|
||||
from cloudflare import Cloudflare
|
||||
from layercake.dateutils import now
|
||||
from layercake.dynamodb import DynamoDBPersistenceLayer, KeyPair
|
||||
|
||||
from boto3clients import dynamodb_client
|
||||
from config import CLOUDFLARE_ZONE_ID, USER_TABLE
|
||||
|
||||
dyn = DynamoDBPersistenceLayer(USER_TABLE, dynamodb_client)
|
||||
cf_client = Cloudflare()
|
||||
|
||||
|
||||
@event_source(data_class=EventBridgeEvent)
|
||||
def lambda_handler(event: EventBridgeEvent, context: LambdaContext) -> bool:
|
||||
new_image = event.detail['new_image']
|
||||
|
||||
try:
|
||||
custom_hostname = cf_client.custom_hostnames.create(
|
||||
zone_id=CLOUDFLARE_ZONE_ID,
|
||||
hostname=new_image['hostname'],
|
||||
ssl={
|
||||
'type': 'dv',
|
||||
'method': 'http',
|
||||
'settings': {
|
||||
'tls_1_3': 'on',
|
||||
'min_tls_version': '1.2',
|
||||
},
|
||||
},
|
||||
)
|
||||
|
||||
dyn.update_item(
|
||||
key=KeyPair(
|
||||
pk=new_image['id'],
|
||||
sk=new_image['sk'],
|
||||
),
|
||||
update_expr='SET hostname_id = :hostname_id, updated_at = :now',
|
||||
expr_attr_values={
|
||||
':hostname_id': custom_hostname.id, # type: ignore
|
||||
':now': now(),
|
||||
},
|
||||
)
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
return True
|
||||
Reference in New Issue
Block a user