turn the cert expires optional

This commit is contained in:
2025-09-24 11:08:43 -03:00
parent a7096974d5
commit 9e8ac8866f

View File

@@ -40,7 +40,12 @@ def lambda_handler(event: EventBridgeEvent, context: LambdaContext) -> bool:
started_at: datetime = fromisoformat(new_image['started_at']) # type: ignore
completed_at: datetime = fromisoformat(new_image['completed_at']) # type: ignore
cert_expires_at = completed_at + timedelta(days=int(cert['exp_interval']))
# The certificate may not expire
cert_expires_at = (
completed_at + timedelta(days=int(cert['exp_interval']))
if 'exp_interval' in cert
else None
)
try:
# Send template URI and data to Paperforge API to generate a PDF
@@ -58,7 +63,12 @@ def lambda_handler(event: EventBridgeEvent, context: LambdaContext) -> bool:
'completed_at': completed_at.strftime('%d/%m/%Y'),
'today': _datefmt(now_),
'year': now_.strftime('%Y'),
},
}
| (
{'expires_at': cert_expires_at.strftime('%d/%m/%Y')}
if cert_expires_at
else {}
),
},
),
)
@@ -93,8 +103,8 @@ def lambda_handler(event: EventBridgeEvent, context: LambdaContext) -> bool:
':now': now_,
':issued_cert': {
'issued_at': now_,
'expires_at': cert_expires_at,
}
| ({'expires_at': cert_expires_at} if cert_expires_at else {})
| ({'s3_uri': s3_uri} if s3_uri else {}),
},
cond_expr='attribute_exists(sk)',