awslabs / awslabs/aws-deployment-framework

[Bug]: adf-account-management StateMachine fails if first 30 characters of account name are similar.

Open
#770 2 comments 0 reactions 0 assignees View on GitHub
bug
Dominant language
Python
Stars
699
Forks
235
Avg merge
20h 53m
Merged PRs (30d)
7

Description

### Is there an existing issue for this?

- [X] I have searched the existing issues

### Describe the bug

When you create multiple accounts in a single file the StateMachine fails to start cause stepfunctions states that it has already been started:

[ERROR] ExecutionAlreadyExists: An error occurred (ExecutionAlreadyExists) when calling the StartExecution operation: Execution Already Exists: 'arn:aws:states:us-east-1:xxxxxxxxxxx:execution:adf-account-management:LongClientName___Business_Names__-29a4174a-4ce7-4597-bc58-89fda1121172-96ac41b3da60'
Traceback (most recent call last):
File "/var/task/process_account_files.py", line 206, in lambda_handler
start_executions(
File "/var/task/process_account_files.py", line 179, in start_executions
sfn_client.start_execution(
File "/var/task/botocore/client.py", line 565, in _api_call
return self._make_api_call(operation_name, kwargs)
File "/var/task/aws_xray_sdk/ext/botocore/patch.py", line 38, in _xray_traced_botocore
return xray_recorder.record_subsegment(
File "/var/task/aws_xray_sdk/core/recorder.py", line 456, in record_subsegment
return_value = wrapped(*args, **kwargs)
File "/var/task/botocore/client.py", line 1021, in _make_api_call
raise error_class(parsed_response, operation_name)

So in case the accounts follow a naming standard like:
LongClientName - BusinessName - Development/Production etc

The 30 selected first letters + id from process_account_files.py sends the exact same ID for both accounts into step functions.

### Expected Behavior

Should run for each account in the account file, with zero regard to the naming being similar.

### Current Behavior

ERROR] ExecutionAlreadyExists: An error occurred (ExecutionAlreadyExists) when calling the StartExecution operation: Execution Already Exists: 'arn:aws:states:us-east-1:xxxxxxxxxxx:execution:adf-account-management:LongClientName___Business_Names__-29a4174a-4ce7-4597-bc58-89fda1121172-96ac41b3da60'

The execution of the file stops - it will not try to run the state machines for accounts below the first failure either.

### Steps To Reproduce

Add two new accounts into the account file, with first characters being the same.

### Possible Solution

Add a short random string in front of the account name, instead of behind in step function trigger.

### Additional Information/Context

_No response_

### ADF Version

4.0.0

### Contributing a fix?

- [ ] Yes, I am working on a fix to resolve this issue

Contributor guide

Open the contributing guide

Research direction

Start in process_account_files.py, especially start_executions around line 179 and lambda_handler around line 206, then reproduce with two accounts whose names share the same first characters. Check how execution names are built and run the account-file flow. Done means each account starts its own StateMachine execution and later accounts still run after the first one.

Written by the indexing model from the issue text.

Assessment

Tech stack
aws, python
Domain
cloud, devops
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.