@@ -30,8 +30,9 @@ def get_boto_session() -> boto.Session:
3030 return session
3131
3232
33- def _create_provider_and_credential (db : Session , proxy : Proxy ,
34- identity ) -> ProviderAccount :
33+ def _create_provider_and_credential (
34+ db : Session , proxy : Proxy , identity ,
35+ external_id : Optional [int ]) -> ProviderAccount :
3536 account_id = identity ['Account' ]
3637 org = proxy .service ('organizations' )
3738 try :
@@ -43,7 +44,9 @@ def _create_provider_and_credential(db: Session, proxy: Proxy,
4344 org_id = f'OrgDummy:{ account_id } '
4445 else :
4546 raise
46- provider = ProviderAccount (provider = 'aws' , name = org_id )
47+ provider = ProviderAccount (provider = 'aws' ,
48+ name = org_id ,
49+ external_id = external_id )
4750 db .add (provider )
4851 db .flush ()
4952 _require_credential (db , provider .id , identity )
@@ -87,18 +90,20 @@ def walk_graph(org, graph) -> Generator[Tuple[str, str, Dict], None, None]:
8790
8891
8992def build_aws_import_job (db : Session , session : boto .Session ,
90- confirm : ConfirmAcct ) -> ImportJob :
93+ confirm : ConfirmAcct ,
94+ external_id : Optional [int ]) -> ImportJob :
9195 proxy = Proxy .build (session )
9296 sts = session .create_client ('sts' )
9397 identity = sts .get_caller_identity ()
94- provider = _get_or_create_provider (db , proxy , identity , confirm )
98+ provider = _get_or_create_provider (db , proxy , identity , confirm , external_id )
9599 desc = _build_import_job_desc (proxy , identity )
96100 org_id = desc ['aws_org' ]['Id' ]
97101 return ImportJob .create (provider , desc , org_id )
98102
99103
100104def _get_or_create_provider (db : Session , proxy : Proxy , identity : Dict ,
101- confirm : ConfirmAcct ) -> ProviderAccount :
105+ confirm : ConfirmAcct ,
106+ external_id : Optional [int ]) -> ProviderAccount :
102107 org = proxy .service ('organizations' )
103108 try :
104109 org_resp = org .get ('describe_organization' )['Organization' ]
@@ -118,7 +123,7 @@ def _get_or_create_provider(db: Session, proxy: Proxy, identity: Dict,
118123 add = confirm (identity )
119124 if not add :
120125 raise GFError ('User cancelled' )
121- return _create_provider_and_credential (db , proxy , identity )
126+ return _create_provider_and_credential (db , proxy , identity , external_id )
122127
123128
124129def _build_import_job_desc (proxy : Proxy , identity : Dict ) -> Dict :
0 commit comments