id: s3-object-lock-retention-audit
namespace: company.team
description: |
Audit one S3-compatible bucket for versioning, Object Lock defaults and
noncurrent-version lifecycle coverage. Count every version before making
a cost claim. A human may approve only two monotonic repairs: enable
versioning or raise the default retention for future writes.
concurrency: { limit: 1, behavior: QUEUE }
triggers:
- id: bucket_policy_webhook
type: io.kestra.plugin.core.trigger.Webhook
key: s3-object-lock-audit-change-me
description: "Call POST
/api/v1/main/executions/webhook/company.team/s3-object-lock-retention-aud\
it/s3-object-lock-audit-change-me after a bucket policy change."
- id: daily_backstop
type: io.kestra.plugin.core.trigger.Schedule
cron: "0 4 * * *"
disabled: true
description: Enable after configuring the target bucket; the webhook is the
primary event path.
inputs:
- id: endpoint
type: STRING
defaults: http://minio-s3lock:9000
description: S3-compatible endpoint reachable from the worker; use HTTPS outside
a local test network.
- id: bucket
type: STRING
defaults: s3lock-locked
description: One bucket to audit; run a separate execution for each protected bucket.
- id: required_mode
type: SELECT
values: [ GOVERNANCE, COMPLIANCE ]
defaults: GOVERNANCE
description: Minimum Object Lock mode for future versions; COMPLIANCE is
stronger than GOVERNANCE.
- id: min_retention_days
type: INT
defaults: 30
description: Minimum bucket default retention for new versions, never a request
to shorten an existing rule.
- id: max_noncurrent_days
type: INT
defaults: 365
description: Maximum allowed noncurrent expiration period in an enabled,
bucket-wide lifecycle rule.
- id: noncurrent_age_days
type: INT
defaults: 90
description: Age threshold for reporting old noncurrent bytes; this flow never
deletes them.
- id: max_versions
type: INT
defaults: 10000
description: Hard scan cap; the audit fails instead of silently undercounting a
larger bucket.
- id: offer_repair
type: BOOL
defaults: false
description: Pause for approval of safe policy repairs; false performs a
read-only audit.
tasks:
- id: validate_inputs
type: io.kestra.plugin.scripts.python.Script
description: Reject unsafe endpoints, bucket names and limits before any S3 call.
taskRunner: { type: io.kestra.plugin.core.runner.Process }
packageManager: PIP
dependencies: [ kestra ]
env:
S3_ENDPOINT: "{{ inputs.endpoint }}"
BUCKET: "{{ inputs.bucket }}"
REQUIRED_MODE: "{{ inputs.required_mode }}"
MIN_RETENTION_DAYS: "{{ inputs.min_retention_days }}"
MAX_NONCURRENT_DAYS: "{{ inputs.max_noncurrent_days }}"
NONCURRENT_AGE_DAYS: "{{ inputs.noncurrent_age_days }}"
MAX_VERSIONS: "{{ inputs.max_versions }}"
script: |
import os
import re
from urllib.parse import urlparse
from kestra import Kestra
bucket = os.environ['BUCKET']
url = urlparse(os.environ['S3_ENDPOINT'])
if not re.fullmatch(r'[a-z0-9][a-z0-9.-]{1,61}[a-z0-9]', bucket) or '..' in bucket:
raise ValueError('bucket must be a DNS-style name of 3-63 lowercase characters')
if url.scheme not in ('http', 'https') or not url.hostname or url.username or url.password or url.query or url.fragment or url.path not in ('', '/'):
raise ValueError('endpoint must be a plain HTTP(S) origin with no credentials or path')
for name in ('MIN_RETENTION_DAYS', 'MAX_NONCURRENT_DAYS', 'NONCURRENT_AGE_DAYS'):
if not 1 <= int(os.environ[name]) <= 36500:
raise ValueError(f'{name} must be 1-36500')
if not 1 <= int(os.environ['MAX_VERSIONS']) <= 1000000:
raise ValueError('MAX_VERSIONS must be 1-1000000')
if os.environ['REQUIRED_MODE'] not in ('GOVERNANCE', 'COMPLIANCE'):
raise ValueError('required_mode must be GOVERNANCE or COMPLIANCE')
Kestra.outputs({'validated': True})
- id: audit_bucket
type: io.kestra.plugin.scripts.python.Script
description: Read bucket settings and paginate all object versions; fail at the
scan cap.
taskRunner: { type: io.kestra.plugin.core.runner.Process }
packageManager: PIP
dependencies: [ "boto3==1.40.58", kestra ]
retry: { type: exponential, interval: PT2S, maxInterval: PT30S, maxAttempts: 3 }
env:
S3_ENDPOINT: "{{ inputs.endpoint }}"
BUCKET: "{{ inputs.bucket }}"
S3_ACCESS_KEY: "{{ secret('MINIO_ACCESS_KEY_ID') }}"
S3_SECRET_KEY: "{{ secret('MINIO_SECRET_KEY_ID') }}"
REQUIRED_MODE: "{{ inputs.required_mode }}"
MIN_RETENTION_DAYS: "{{ inputs.min_retention_days }}"
MAX_NONCURRENT_DAYS: "{{ inputs.max_noncurrent_days }}"
NONCURRENT_AGE_DAYS: "{{ inputs.noncurrent_age_days }}"
MAX_VERSIONS: "{{ inputs.max_versions }}"
script: |
import hashlib
import json
import os
from datetime import datetime, timezone, timedelta
import boto3
from botocore.config import Config
from botocore.exceptions import ClientError
from kestra import Kestra
bucket = os.environ['BUCKET']
client = boto3.client('s3', endpoint_url=os.environ['S3_ENDPOINT'], region_name='us-east-1',
aws_access_key_id=os.environ['S3_ACCESS_KEY'], aws_secret_access_key=os.environ['S3_SECRET_KEY'],
config=Config(s3={'addressing_style': 'path', 'signature_version': 's3v4',
'retries': {'mode': 'standard', 'max_attempts': 3},
'connect_timeout': 5, 'read_timeout': 15}))
def missing(error, codes):
return error.response.get('Error', {}).get('Code') in codes
def policy():
client.head_bucket(Bucket=bucket)
versioning = client.get_bucket_versioning(Bucket=bucket).get('Status', 'Off')
try:
lock = client.get_object_lock_configuration(Bucket=bucket).get('ObjectLockConfiguration', {})
except ClientError as error:
if not missing(error, {'ObjectLockConfigurationNotFoundError', 'NoSuchObjectLockConfiguration', 'ObjectLockConfigurationNotFound'}):
raise
lock = {}
try:
lifecycle = client.get_bucket_lifecycle_configuration(Bucket=bucket).get('Rules', [])
except ClientError as error:
if not missing(error, {'NoSuchLifecycleConfiguration'}):
raise
lifecycle = []
return {'versioning': versioning, 'lock': lock, 'lifecycle': lifecycle}
snapshot = policy()
raw = json.dumps(snapshot, sort_keys=True, default=str, separators=(',', ':'))
policy_hash = hashlib.sha256(raw.encode()).hexdigest()
lock = snapshot['lock']
default = lock.get('Rule', {}).get('DefaultRetention', {})
current_days = int(default.get('Days') or (default.get('Years') or 0) * 365)
required_mode = os.environ['REQUIRED_MODE']
mode = default.get('Mode', '')
mode_good = mode == 'COMPLIANCE' or (required_mode == 'GOVERNANCE' and mode == 'GOVERNANCE')
lock_enabled = lock.get('ObjectLockEnabled') == 'Enabled'
retention_good = lock_enabled and mode_good and current_days >= int(os.environ['MIN_RETENTION_DAYS'])
max_noncurrent_days = int(os.environ['MAX_NONCURRENT_DAYS'])
lifecycle_good = any(
rule.get('Status') == 'Enabled'
and rule.get('Filter', {}) in ({}, {'Prefix': ''})
and rule.get('Prefix', '') == ''
and 0 < int(rule.get('NoncurrentVersionExpiration', {}).get('NoncurrentDays', 0)) <= max_noncurrent_days
for rule in snapshot['lifecycle']
)
findings = []
if snapshot['versioning'] != 'Enabled': findings.append('versioning_disabled')
if not lock_enabled: findings.append('object_lock_absent_manual_migration')
elif not retention_good: findings.append('default_retention_too_weak')
if not lifecycle_good: findings.append('noncurrent_lifecycle_missing_or_too_long')
current_versions = noncurrent_versions = noncurrent_bytes = old_noncurrent_bytes = delete_markers = 0
cutoff = datetime.now(timezone.utc) - timedelta(days=int(os.environ['NONCURRENT_AGE_DAYS']))
max_versions = int(os.environ['MAX_VERSIONS'])
for page in client.get_paginator('list_object_versions').paginate(Bucket=bucket, PaginationConfig={'PageSize': 1000}):
for version in page.get('Versions', []):
if current_versions + noncurrent_versions + delete_markers >= max_versions:
raise RuntimeError(f'version scan exceeded max_versions={max_versions}; increase the cap and rerun')
if version['IsLatest']:
current_versions += 1
else:
noncurrent_versions += 1
size = int(version.get('Size') or 0)
noncurrent_bytes += size
if version['LastModified'] < cutoff: old_noncurrent_bytes += size
for marker in page.get('DeleteMarkers', []):
if current_versions + noncurrent_versions + delete_markers >= max_versions:
raise RuntimeError(f'version scan exceeded max_versions={max_versions}; increase the cap and rerun')
delete_markers += 1
status = 'HEALTHY' if not findings else 'DRIFT'
result = {
'bucket': bucket, 'status': status, 'findings': findings,
'versioning': snapshot['versioning'], 'object_lock_enabled': lock_enabled,
'retention_mode': mode or 'NONE', 'retention_days': current_days,
'lifecycle_rule_count': len(snapshot['lifecycle']), 'lifecycle_good': lifecycle_good,
'current_versions': current_versions, 'noncurrent_versions': noncurrent_versions,
'noncurrent_bytes': noncurrent_bytes, 'old_noncurrent_bytes': old_noncurrent_bytes,
'delete_markers': delete_markers, 'policy_hash': policy_hash,
'repair_versioning': snapshot['versioning'] != 'Enabled',
'repair_retention': lock_enabled and not retention_good,
}
result['repairable'] = result['repair_versioning'] or result['repair_retention']
result['signature'] = hashlib.sha256(json.dumps({
'status': status, 'findings': findings, 'policy_hash': policy_hash,
}, sort_keys=True).encode()).hexdigest()[:24]
Kestra.outputs(result)
print(f"{bucket}: {status}; findings={','.join(findings) or 'none'}; noncurrent={noncurrent_versions} / {noncurrent_bytes} bytes")
- id: load_last_state
type: io.kestra.plugin.core.kv.Get
key: "s3_object_lock_{{ inputs.bucket }}"
errorOnMissing: false
- id: changed_policy
type: io.kestra.plugin.core.flow.If
condition: "{{ outputs.audit_bucket.vars.signature !=
(outputs.load_last_state.value ?? '') }}"
then:
- id: alert_on_drift_or_recovery
type: io.kestra.plugin.core.flow.If
condition: "{{ outputs.audit_bucket.vars.status == 'DRIFT' or
(outputs.load_last_state.value ?? '') != '' }}"
then:
- id: notify_policy_change
type: io.kestra.plugin.slack.notifications.SlackIncomingWebhook
url: "{{ secret('SLACK_WEBHOOK_URL') }}"
messageText: >-
S3 retention audit {{ outputs.audit_bucket.vars.status }} for
bucket {{ inputs.bucket }}. Findings: {{
outputs.audit_bucket.vars.findings | join(', ') }}. Noncurrent
versions: {{ outputs.audit_bucket.vars.noncurrent_versions }};
bytes: {{ outputs.audit_bucket.vars.noncurrent_bytes }}; older
than {{ inputs.noncurrent_age_days }} days: {{
outputs.audit_bucket.vars.old_noncurrent_bytes }} bytes. Review
Object Lock and lifecycle settings before changing policy.
Execution {{ execution.id }}.
- id: remember_policy_state
type: io.kestra.plugin.core.kv.Set
key: "s3_object_lock_{{ inputs.bucket }}"
value: "{{ outputs.audit_bucket.vars.signature }}"
kvType: STRING
- id: offer_approved_repair
type: io.kestra.plugin.core.flow.If
condition: "{{ inputs.offer_repair and outputs.audit_bucket.vars.repairable }}"
then:
- id: show_repair_plan
type: io.kestra.plugin.core.log.Log
message: >-
Bucket {{ inputs.bucket }} policy hash {{
outputs.audit_bucket.vars.policy_hash }}. Available actions: enable
versioning={{ outputs.audit_bucket.vars.repair_versioning }}, raise
default retention={{ outputs.audit_bucket.vars.repair_retention }}.
Missing Object Lock and lifecycle rules require a separate manual
migration or reviewed policy change.
- id: wait_for_approval
type: io.kestra.plugin.core.flow.Pause
description: No selection within two hours means no write. Review the policy
hash and proposed actions.
pauseDuration: PT2H
behavior: RESUME
onResume:
- id: actions
type: MULTISELECT
values: [ Enable versioning, Raise default retention ]
required: false
- id: selected_repair
type: io.kestra.plugin.core.flow.If
condition: "{{ (outputs.wait_for_approval.onResume.actions ?? []) contains
'Enable versioning' or (outputs.wait_for_approval.onResume.actions ??
[]) contains 'Raise default retention' }}"
then:
- id: apply_approved_repair
type: io.kestra.plugin.scripts.python.Script
description: Re-read and hash the live bucket policy before any approved write;
do not automatically retry ambiguous writes.
taskRunner: { type: io.kestra.plugin.core.runner.Process }
packageManager: PIP
dependencies: [ "boto3==1.40.58", kestra ]
env:
S3_ENDPOINT: "{{ inputs.endpoint }}"
BUCKET: "{{ inputs.bucket }}"
S3_ACCESS_KEY: "{{ secret('MINIO_ACCESS_KEY_ID') }}"
S3_SECRET_KEY: "{{ secret('MINIO_SECRET_KEY_ID') }}"
EXPECTED_POLICY_HASH: "{{ outputs.audit_bucket.vars.policy_hash }}"
REQUIRED_MODE: "{{ inputs.required_mode }}"
MIN_RETENTION_DAYS: "{{ inputs.min_retention_days }}"
ACTIONS: "{{ (outputs.wait_for_approval.onResume.actions ?? []) | toJson }}"
script: |
import hashlib
import json
import os
import boto3
from botocore.config import Config
from botocore.exceptions import ClientError
from kestra import Kestra
bucket = os.environ['BUCKET']
client = boto3.client('s3', endpoint_url=os.environ['S3_ENDPOINT'], region_name='us-east-1',
aws_access_key_id=os.environ['S3_ACCESS_KEY'], aws_secret_access_key=os.environ['S3_SECRET_KEY'],
config=Config(s3={'addressing_style': 'path', 'signature_version': 's3v4',
'retries': {'mode': 'standard', 'max_attempts': 3},
'connect_timeout': 5, 'read_timeout': 15}))
def optional(method, codes, key, default):
try: return method(Bucket=bucket).get(key, default)
except ClientError as error:
if error.response.get('Error', {}).get('Code') in codes: return default
raise
def policy():
client.head_bucket(Bucket=bucket)
return {
'versioning': client.get_bucket_versioning(Bucket=bucket).get('Status', 'Off'),
'lock': optional(client.get_object_lock_configuration,
{'ObjectLockConfigurationNotFoundError', 'NoSuchObjectLockConfiguration', 'ObjectLockConfigurationNotFound'},
'ObjectLockConfiguration', {}),
'lifecycle': optional(client.get_bucket_lifecycle_configuration,
{'NoSuchLifecycleConfiguration'}, 'Rules', []),
}
live = policy()
raw = json.dumps(live, sort_keys=True, default=str, separators=(',', ':'))
if hashlib.sha256(raw.encode()).hexdigest() != os.environ['EXPECTED_POLICY_HASH']:
raise RuntimeError('bucket policy changed during approval; no repair was attempted')
actions = json.loads(os.environ['ACTIONS'])
if not isinstance(actions, list) or not actions or len(actions) != len(set(actions)):
raise ValueError('approval actions must be a nonempty, unique list')
if set(actions) - {'Enable versioning', 'Raise default retention'}:
raise ValueError('unknown repair action')
performed = []
if 'Enable versioning' in actions and live['versioning'] == 'Enabled':
raise RuntimeError('versioning is already enabled; rerun the audit')
if 'Raise default retention' in actions and live['lock'].get('ObjectLockEnabled') != 'Enabled':
raise RuntimeError('Object Lock is not enabled; do not alter default retention')
if 'Enable versioning' in actions:
client.put_bucket_versioning(Bucket=bucket, VersioningConfiguration={'Status': 'Enabled'})
performed.append('versioning_enabled')
if 'Raise default retention' in actions:
lock = live['lock']
old = lock.get('Rule', {}).get('DefaultRetention', {})
old_days = int(old.get('Days') or (old.get('Years') or 0) * 365)
new_days = max(old_days, int(os.environ['MIN_RETENTION_DAYS']))
old_mode = old.get('Mode', '')
required_mode = os.environ['REQUIRED_MODE']
new_mode = 'COMPLIANCE' if old_mode == 'COMPLIANCE' or required_mode == 'COMPLIANCE' else 'GOVERNANCE'
if old_mode == new_mode and old_days >= new_days:
raise RuntimeError('default retention already meets this policy; rerun the audit')
period = {'Years': int(old['Years'])} if old.get('Years') and old_days >= new_days else {'Days': new_days}
client.put_object_lock_configuration(Bucket=bucket, ObjectLockConfiguration={
'ObjectLockEnabled': 'Enabled',
'Rule': {'DefaultRetention': {'Mode': new_mode, **period}}
})
performed.append(f'default_retention_{new_mode}_{new_days}d')
Kestra.outputs({'performed': performed})
print(f"{bucket}: approved repairs completed: {', '.join(performed)}")
- id: verify_repair
type: io.kestra.plugin.scripts.python.Script
description: Re-audit the live bucket after the write; the flow only reports
success after this read.
taskRunner: { type: io.kestra.plugin.core.runner.Process }
packageManager: PIP
dependencies: [ "boto3==1.40.58", kestra ]
retry: { type: exponential, interval: PT2S, maxInterval: PT30S, maxAttempts: 3 }
env:
S3_ENDPOINT: "{{ inputs.endpoint }}"
BUCKET: "{{ inputs.bucket }}"
S3_ACCESS_KEY: "{{ secret('MINIO_ACCESS_KEY_ID') }}"
S3_SECRET_KEY: "{{ secret('MINIO_SECRET_KEY_ID') }}"
REQUIRED_MODE: "{{ inputs.required_mode }}"
MIN_RETENTION_DAYS: "{{ inputs.min_retention_days }}"
MAX_NONCURRENT_DAYS: "{{ inputs.max_noncurrent_days }}"
NONCURRENT_AGE_DAYS: "{{ inputs.noncurrent_age_days }}"
MAX_VERSIONS: "{{ inputs.max_versions }}"
script: |
import hashlib
import json
import os
from datetime import datetime, timezone, timedelta
import boto3
from botocore.config import Config
from botocore.exceptions import ClientError
from kestra import Kestra
bucket = os.environ['BUCKET']
client = boto3.client('s3', endpoint_url=os.environ['S3_ENDPOINT'], region_name='us-east-1',
aws_access_key_id=os.environ['S3_ACCESS_KEY'], aws_secret_access_key=os.environ['S3_SECRET_KEY'],
config=Config(s3={'addressing_style': 'path', 'signature_version': 's3v4',
'retries': {'mode': 'standard', 'max_attempts': 3},
'connect_timeout': 5, 'read_timeout': 15}))
def missing(error, codes):
return error.response.get('Error', {}).get('Code') in codes
def policy():
client.head_bucket(Bucket=bucket)
versioning = client.get_bucket_versioning(Bucket=bucket).get('Status', 'Off')
try:
lock = client.get_object_lock_configuration(Bucket=bucket).get('ObjectLockConfiguration', {})
except ClientError as error:
if not missing(error, {'ObjectLockConfigurationNotFoundError', 'NoSuchObjectLockConfiguration', 'ObjectLockConfigurationNotFound'}):
raise
lock = {}
try:
lifecycle = client.get_bucket_lifecycle_configuration(Bucket=bucket).get('Rules', [])
except ClientError as error:
if not missing(error, {'NoSuchLifecycleConfiguration'}):
raise
lifecycle = []
return {'versioning': versioning, 'lock': lock, 'lifecycle': lifecycle}
snapshot = policy()
raw = json.dumps(snapshot, sort_keys=True, default=str, separators=(',', ':'))
policy_hash = hashlib.sha256(raw.encode()).hexdigest()
lock = snapshot['lock']
default = lock.get('Rule', {}).get('DefaultRetention', {})
current_days = int(default.get('Days') or (default.get('Years') or 0) * 365)
required_mode = os.environ['REQUIRED_MODE']
mode = default.get('Mode', '')
mode_good = mode == 'COMPLIANCE' or (required_mode == 'GOVERNANCE' and mode == 'GOVERNANCE')
lock_enabled = lock.get('ObjectLockEnabled') == 'Enabled'
retention_good = lock_enabled and mode_good and current_days >= int(os.environ['MIN_RETENTION_DAYS'])
max_noncurrent_days = int(os.environ['MAX_NONCURRENT_DAYS'])
lifecycle_good = any(
rule.get('Status') == 'Enabled'
and rule.get('Filter', {}) in ({}, {'Prefix': ''})
and rule.get('Prefix', '') == ''
and 0 < int(rule.get('NoncurrentVersionExpiration', {}).get('NoncurrentDays', 0)) <= max_noncurrent_days
for rule in snapshot['lifecycle']
)
findings = []
if snapshot['versioning'] != 'Enabled': findings.append('versioning_disabled')
if not lock_enabled: findings.append('object_lock_absent_manual_migration')
elif not retention_good: findings.append('default_retention_too_weak')
if not lifecycle_good: findings.append('noncurrent_lifecycle_missing_or_too_long')
current_versions = noncurrent_versions = noncurrent_bytes = old_noncurrent_bytes = delete_markers = 0
cutoff = datetime.now(timezone.utc) - timedelta(days=int(os.environ['NONCURRENT_AGE_DAYS']))
max_versions = int(os.environ['MAX_VERSIONS'])
for page in client.get_paginator('list_object_versions').paginate(Bucket=bucket, PaginationConfig={'PageSize': 1000}):
for version in page.get('Versions', []):
if current_versions + noncurrent_versions + delete_markers >= max_versions:
raise RuntimeError(f'version scan exceeded max_versions={max_versions}; increase the cap and rerun')
if version['IsLatest']:
current_versions += 1
else:
noncurrent_versions += 1
size = int(version.get('Size') or 0)
noncurrent_bytes += size
if version['LastModified'] < cutoff: old_noncurrent_bytes += size
for marker in page.get('DeleteMarkers', []):
if current_versions + noncurrent_versions + delete_markers >= max_versions:
raise RuntimeError(f'version scan exceeded max_versions={max_versions}; increase the cap and rerun')
delete_markers += 1
status = 'HEALTHY' if not findings else 'DRIFT'
result = {
'bucket': bucket, 'status': status, 'findings': findings,
'versioning': snapshot['versioning'], 'object_lock_enabled': lock_enabled,
'retention_mode': mode or 'NONE', 'retention_days': current_days,
'lifecycle_rule_count': len(snapshot['lifecycle']), 'lifecycle_good': lifecycle_good,
'current_versions': current_versions, 'noncurrent_versions': noncurrent_versions,
'noncurrent_bytes': noncurrent_bytes, 'old_noncurrent_bytes': old_noncurrent_bytes,
'delete_markers': delete_markers, 'policy_hash': policy_hash,
'repair_versioning': snapshot['versioning'] != 'Enabled',
'repair_retention': lock_enabled and not retention_good,
}
result['repairable'] = result['repair_versioning'] or result['repair_retention']
result['signature'] = hashlib.sha256(json.dumps({
'status': status, 'findings': findings, 'policy_hash': policy_hash,
}, sort_keys=True).encode()).hexdigest()[:24]
Kestra.outputs(result)
print(f"{bucket}: {status}; findings={','.join(findings) or 'none'}; noncurrent={noncurrent_versions} / {noncurrent_bytes} bytes")
- id: notify_repair_result
type: io.kestra.plugin.slack.notifications.SlackIncomingWebhook
url: "{{ secret('SLACK_WEBHOOK_URL') }}"
messageText: >-
Approved S3 policy repair for {{ inputs.bucket }}: {{
outputs.apply_approved_repair.vars.performed | join(', ') }}.
Re-audit status {{ outputs.verify_repair.vars.status }}; remaining
findings {{ outputs.verify_repair.vars.findings | join(', ') }}.
Execution {{ execution.id }}.
- id: remember_repaired_state
type: io.kestra.plugin.core.kv.Set
key: "s3_object_lock_{{ inputs.bucket }}"
value: "{{ outputs.verify_repair.vars.signature }}"
kvType: STRING
errors:
- id: alert_on_failure
type: io.kestra.plugin.slack.notifications.SlackIncomingWebhook
url: "{{ secret('SLACK_WEBHOOK_URL') }}"
messageText: >-
{% set failed = (errorLogs() | toJson | jq('[.[] | .taskId | select(. !=
null)] | first') | first) ?? 'unknown_task' %} S3 retention audit {{
execution.id }} failed in {{ failed }}. Cause category: {% if failed ==
'validate_inputs' %}input validation failed{% elseif failed ==
'audit_bucket' %}S3 policy or version scan failed{% elseif failed ==
'apply_approved_repair' %}the policy changed during approval or an
approved write failed{% elseif failed == 'verify_repair' %}post-repair S3
read failed{% else %}workflow task failed{% endif %}. Inspect that task's
execution logs for the exact error. If a write timed out, inspect the live
bucket before retrying. No object was deleted.
outputs:
- id: audit
type: JSON
value: "{{ outputs.audit_bucket.vars ?? {} }}"
- id: post_repair
type: JSON
value: "{{ outputs.verify_repair.vars ?? {} }}"