Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix the allow_empty_target OU path issue #786

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

danxie1999
Copy link

Why?

When I enable the allow_empty_target parameter in the adfconfig.yml file, if I set a target OU path which does not exist in my AWS organization, I will get following error.

{
  "errorMessage": "Path /TenantXXX/Shared failed to return a child OU at 'TenantXXX'",
  "errorType": "ValueError",
  "requestId": "d786ed75-3ce9-4995-a7b6-75fa40454c86",
  "stackTrace": [
    "  File \"/var/task/generate_pipeline_inputs.py\", line 223, in lambda_handler\n    pipeline_input_data = generate_pipeline_inputs(\n",
    "  File \"/var/task/generate_pipeline_inputs.py\", line 151, in generate_pipeline_inputs\n    pipeline_target.fetch_accounts_for_target()\n",
    "  File \"/opt/python/target.py\", line 319, in fetch_accounts_for_target\n    self._target_is_ou_path(\n",
    "  File \"/opt/python/target.py\", line 260, in _target_is_ou_path\n    responses = self.organizations.get_accounts_in_path(\n",
    "  File \"/opt/python/organizations.py\", line 384, in get_accounts_in_path\n    ou_id = self.ou_path_to_id(path) if not ou_id else ou_id\n",
    "  File \"/opt/python/organizations.py\", line 367, in ou_path_to_id\n    raise ValueError(\n"
  ]
}

My deployment map file look like below:

pipelines:
  - name: platform-demo-empty-target
    description: |-
      Deploys Demo Stack to test ADF features
    default_providers:
      source:
        provider: codecommit
      build:
        provider: codebuild
    params:
      restart_execution_on_update: True
    targets:
      - name: Deploy-Non-Exist-Ou-Path
        path: /TenantXXX/Shared
        properties:
          template_filename: DemoStack1.template

What?

The reason of above error is that the src/lambda_codebase/initial_commit/bootstrap_repository/adf-build/shared/python/target.py only capture the boto3 Client Error and ignore the Error raised in the method get_accounts_in_path in orgnizations.py. So, an easy fix is to change the boto3 Client Error to Exception and ignore it if the allow_empty_target was enabled.

@danxie1999 danxie1999 force-pushed the fix/allow_empty_target_error branch from fea61be to f725668 Compare February 24, 2025 05:48
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.

1 participant