Skip to content

Fix bugs in MWAA verify_env: S3 client reference and missing json importFix/mwaa verify env#247

Open
eason1128 wants to merge 2 commits intoawslabs:masterfrom
eason1128:fix/mwaa-verify-env
Open

Fix bugs in MWAA verify_env: S3 client reference and missing json importFix/mwaa verify env#247
eason1128 wants to merge 2 commits intoawslabs:masterfrom
eason1128:fix/mwaa-verify-env

Conversation

@eason1128
Copy link

Summary

This PR fixes two bugs in the MWAA verify_env tool:

  1. Fixed incorrect S3 client reference in airflow_verifier.py: Changed s3 to self.s3 in the delete_file_from_dags_folder method call (line 286). The previous code would cause a NameError when users chose to delete the test DAG after running the full DAG run test.

  2. Added missing json import in utils.py: The module uses JSON functionality but was missing the import statement.

Changes

Testing

  • Verified that the S3 client reference now correctly points to the instance variable
  • Confirmed that the json module is properly imported for JSON operations

Impact

These fixes ensure that:

  • The test DAG deletion feature works correctly without throwing NameError
  • The utils module has all required imports for its functionality

@ankon
Copy link

ankon commented Feb 16, 2026

Also ran into the missing import:

Traceback (most recent call last):
  File ".../aws-support-tools/MWAA/verify_env/verify_env.py", line 99, in <module>
    iam_verifier.check_iam_permissions()
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^
  File ".../aws-support-tools/MWAA/verify_env/iam_verifier.py", line 51, in check_iam_permissions
    policy_list.extend(get_inline_policies(self.iam, self.env['ExecutionRoleArn'].split("/")[-1]))
                       ~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File ".../aws-support-tools/MWAA/verify_env/utils.py", line 88, in get_inline_policies
    json.dumps(iam_client.get_role_policy(RoleName=role_arn, PolicyName=policy).get("PolicyDocument", ))
    ^^^^
NameError: name 'json' is not defined. Did you forget to import 'json'?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

Comments