diff --git a/src/lambda_codebase/initial_commit/bootstrap_repository/adf-bootstrap/deployment/lambda_codebase/pipeline_management/process_deployment_map.py b/src/lambda_codebase/initial_commit/bootstrap_repository/adf-bootstrap/deployment/lambda_codebase/pipeline_management/process_deployment_map.py index 0f538f113..7cdf94251 100644 --- a/src/lambda_codebase/initial_commit/bootstrap_repository/adf-bootstrap/deployment/lambda_codebase/pipeline_management/process_deployment_map.py +++ b/src/lambda_codebase/initial_commit/bootstrap_repository/adf-bootstrap/deployment/lambda_codebase/pipeline_management/process_deployment_map.py @@ -173,13 +173,16 @@ def start_executions( full_pipeline_name = pipeline.get('name', 'no-pipeline-name') # AWS Step Functions supports max 80 characters. # Since the run_id equals 49 characters plus the dash, we have 30 - # characters available. To ensure we don't run over, lets use a - # truncated version concatenated with an hash generated from - # the pipeline name - truncated_pipeline_name = full_pipeline_name[:24] - name_bytes_to_hash = bytes(full_pipeline_name + run_id, 'utf-8') - execution_unique_hash = hashlib.md5(name_bytes_to_hash).hexdigest()[:5] - sfn_execution_name = f"{truncated_pipeline_name}-{execution_unique_hash}-{run_id}" + # characters available. To ensure we don't run over in case of 80+ + # characters, lets use a truncated version concatenated with an + # hash generated from the pipeline name. If below 80 characters, the + # full_pipeline_name + run_id is used. + sfn_execution_name = f"{full_pipeline_name}-{run_id}" + if len(sfn_execution_name) > 80: + truncated_pipeline_name = full_pipeline_name[:60] + name_bytes_to_hash = bytes(full_pipeline_name, 'utf-8') + execution_unique_hash = hashlib.md5(name_bytes_to_hash).hexdigest()[:5] + sfn_execution_name = f"{truncated_pipeline_name}-{execution_unique_hash}-{run_id}"[:80] sfn_client.start_execution( stateMachineArn=PIPELINE_MANAGEMENT_STATEMACHINE, name=sfn_execution_name,