in source/manifest/manifest_parser.py [0:0]
def parse_stack_set_manifest_v2(self) -> list:
self.logger.info("Parsing Core Resources from {} file"
.format(os.environ.get('MANIFEST_FILE_PATH')))
build = BuildStateMachineInput(self.manifest.region)
org = OrganizationsData()
organizations_data = org.get_organization_details()
state_machine_inputs = []
for resource in self.manifest.resources:
if resource.deploy_method == 'stack_set':
self.logger.info(f">>>> START : {resource.name} >>>>")
accounts_in_ou = []
# build OU to accounts map if OU list present in manifest
if resource.deployment_targets.organizational_units:
accounts_in_ou = org.get_accounts_in_ou(
organizations_data.get("OuIdToAccountMap"),
organizations_data.get("OuNameToIdMap"),
resource.deployment_targets.organizational_units
)
# convert account numbers to string type
account_list = convert_list_values_to_string(
resource.deployment_targets.accounts)
self.logger.info(">>>>>> ACCOUNT LIST")
self.logger.info(account_list)
sanitized_account_list = org.get_final_account_list(
account_list, organizations_data.get("AccountsInAllNestedOUs"),
accounts_in_ou, organizations_data.get("NameToAccountMap"))
self.logger.info("Print merged account list - accounts in "
"manifest + account under OU in manifest")
self.logger.info(sanitized_account_list)
if resource.deploy_method.lower() == 'stack_set':
sm_input = build.stack_set_state_machine_input_v2(
resource, sanitized_account_list)
state_machine_inputs.append(sm_input)
else:
raise ValueError(
f"Unsupported deploy_method: {resource.deploy_method} "
f"found for resource {resource.name}")
self.logger.info(f"<<<<<<<<< FINISH : {resource.name} <<<<<<<<")
# Exit if there are no CloudFormation resources
if len(state_machine_inputs) == 0:
self.logger.info("CloudFormation resources not found in the "
"manifest")
sys.exit(0)
else:
return state_machine_inputs