aws-ia / terraform-aws-control_tower_account_factory

AWS Control Tower Account Factory
Apache License 2.0
604 stars 386 forks source link

An issue with an AWS Lambda function using the handler "aft_account_request_action_trigger.lambda_handler #420

Open jekushak opened 5 months ago

jekushak commented 5 months ago

Hello Community,

I'm having issues with an AWS Lambda function that uses the aft_account_request_action_trigger. lambda_handler handler. When I run it, I get two error messages: "Invalid event structure" and "AttributeError: 'AccountRequestRecordHandler' object has no attribute '_ct_management_sesion'". The Lambda function uses the AccountRequestRecordHandler class, and it seems that there are problems with the event structure and attribute availability.

Details:

The "Invalid event structure" error occurs during event validation. The "AttributeError" occurs when trying to access the "_ct_management_sesion" attribute in the "AccountRequestRecordHandler" class. Code snippet:

python https://github.com/aws-ia/terraform-aws-control_tower_account_factory/blob/main/sources/aft-lambda-layer/aft_common/account_request_record_handler.py

I would greatly appreciate any help in diagnosing and resolving this issue!

Error Logs { "time_stamp": "2024-01-25 08:48:53,331", "module": "aft_account_request_action_trigger", "log_level": "ERROR", "log_message": { "FILE": "aft_account_request_action_trigger.py", "METHOD": "lambda_handler", "EXCEPTION": "'AccountRequestRecordHandler' object has no attribute '_ct_management_sesion'" } } Traceback (most recent call last): File "/var/task/aft_account_request_action_trigger.py", line 31, in lambda_handler record_handler.process_request() File "/opt/python/lib/python3.11/site-packages/aft_common/account_request_record_handler.py", line 143, in process_request self.handle_customization_request() File "/opt/python/lib/python3.11/site-packages/aft_common/account_request_record_handler.py", line 92, in handle_customization_request account_id = self._get_account_id( ^^^^^^^^^^^^^^^^^^^^^ File "/opt/python/lib/python3.11/site-packages/aft_common/account_request_record_handler.py", line 46, in _get_account_id orgs = OrganizationsAgent(ct_management_session=self._ct_management_sesion) ^^^^^^^^^^^^^^^^^^^^^^^^^^ AttributeError: 'AccountRequestRecordHandler' object has no attribute '_ct_management_sesion'

[ERROR] AttributeError: 'AccountRequestRecordHandler' object has no attribute '_ct_management_sesion' Traceback (most recent call last): File "/var/task/aft_account_request_action_trigger.py", line 31, in lambda_handler record_handler.process_request() File "/opt/python/lib/python3.11/site-packages/aft_common/account_request_record_handler.py", line 143, in process_request self.handle_customization_request() File "/opt/python/lib/python3.11/site-packages/aft_common/account_request_record_handler.py", line 92, in handle_customization_request account_id = self._get_account_id( File "/opt/python/lib/python3.11/site-packages/aft_common/account_request_record_handler.py", line 46, in _get_account_id orgs = OrganizationsAgent(ct_management_session=self._ct_management_sesion)

snebhu3 commented 5 months ago

@jekushak thank you for reaching out. You should not see this error ideally. (Ref) Which version of AFT are you using? If not using the latest version, please may you update and retry?