close bolling
This commit is contained in:
@@ -22,6 +22,7 @@ enrollment_layer = DynamoDBPersistenceLayer(ENROLLMENT_TABLE, dynamodb_client)
|
||||
@logger.inject_lambda_context
|
||||
def lambda_handler(event: EventBridgeEvent, context: LambdaContext) -> bool:
|
||||
new_image = event.detail['new_image']
|
||||
now_ = now()
|
||||
data = user_layer.get_item(
|
||||
# Post-migration: uncomment the following line
|
||||
# KeyPair(new_image['org_id'], 'METADATA#BILLING_TERMS'),
|
||||
@@ -32,16 +33,27 @@ def lambda_handler(event: EventBridgeEvent, context: LambdaContext) -> bool:
|
||||
return False
|
||||
|
||||
try:
|
||||
enrollment_layer.put_item(
|
||||
item={
|
||||
'id': new_image['id'],
|
||||
'sk': 'METADATA#BILLING_TERMS',
|
||||
'org_id': new_image['tenant_id'],
|
||||
'billing_day': data['billing_day'],
|
||||
'created_at': now(),
|
||||
},
|
||||
cond_expr='attribute_not_exists(sk)',
|
||||
)
|
||||
with enrollment_layer.transact_writer() as transact:
|
||||
transact.update(
|
||||
key=KeyPair(new_image['id'], '0'),
|
||||
update_expr='SET subscription_covered = :subscription_covered, \
|
||||
updated_at = :updated_at',
|
||||
expr_attr_values={
|
||||
':subscription_covered': True,
|
||||
':updated_at': now_,
|
||||
},
|
||||
cond_expr='attribute_exists(sk)',
|
||||
)
|
||||
transact.put(
|
||||
item={
|
||||
'id': new_image['id'],
|
||||
'sk': 'METADATA#SUBSCRIPTION_COVERED',
|
||||
'org_id': new_image['tenant_id'],
|
||||
'billing_day': data['billing_day'],
|
||||
'created_at': now(),
|
||||
},
|
||||
cond_expr='attribute_not_exists(sk)',
|
||||
)
|
||||
except Exception:
|
||||
return False
|
||||
else:
|
||||
@@ -42,10 +42,10 @@ Resources:
|
||||
Properties:
|
||||
RetentionInDays: 90
|
||||
|
||||
EventSetTermsIfSubscribedFunction:
|
||||
EventSetSubscriptionCoveredFunction:
|
||||
Type: AWS::Serverless::Function
|
||||
Properties:
|
||||
Handler: events.stopgap.set_terms_if_subscribed.lambda_handler
|
||||
Handler: events.stopgap.set_subscription_covered.lambda_handler
|
||||
LoggingConfig:
|
||||
LogGroup: !Ref EventLog
|
||||
Policies:
|
||||
|
||||
Reference in New Issue
Block a user