@@ -119,6 +119,13 @@ def __init__(self, infra_type: str, prefix: str, project_id: str, stage_id: Opti
119119 self .settings = config_loader .load_settings ()
120120 self .defaults = config_loader .load_defaults ()
121121
122+ # if role_arn is not in self.defaults, then check for StorageServiceRole
123+ if 'role_arn' not in self .defaults ['atlantis' ]:
124+ if self .infra_type == 'storage' and 'StorageServiceRoleArn' in self .defaults ['atlantis' ]:
125+ self .defaults ['atlantis' ]['role_arn' ] = self .defaults ['atlantis' ]['StorageServiceRoleArn' ]
126+ elif self .infra_type == 'pipeline' and 'PipelineServiceRoleArn' in self .defaults ['atlantis' ]:
127+ self .defaults ['atlantis' ]['role_arn' ] = self .defaults ['atlantis' ]['PipelineServiceRoleArn' ]
128+
122129 def _validate_args (self ) -> None :
123130 """Validate arguments"""
124131
@@ -451,7 +458,7 @@ def validate_boolean(value):
451458 )
452459
453460 # Get role ARN if this is a pipeline deployment
454- if infra_type == 'pipeline' :
461+ if infra_type in [ 'pipeline' , 'storage' ] :
455462 atlantis_deploy_params ['role_arn' ] = get_validated_input (
456463 "IAM role ARN for deployments" ,
457464 atlantis_deploy_parameter_defaults .get ('role_arn' , os .getenv ('SAM_DEPLOY_ROLE' , '' )),
@@ -843,6 +850,10 @@ def set_future_defaults(self, current_params: Dict, default_file_data: Dict, ski
843850 {'name' : 'parameter_overrides' , 'params' : ['RolePath' , 'ServiceRolePath' , 'PermissionsBoundaryArn' , 'S3BucketNameOrgPrefix' , 'ParameterStoreHierarchy' ] }
844851 ]
845852
853+ if scope != 'ALL' :
854+ # add 'role_arn' to the list of parameters to check
855+ possible_defaults [0 ]['params' ].append ('role_arn' )
856+
846857 for section in possible_defaults :
847858
848859 section_name = section ['name' ]
@@ -853,7 +864,15 @@ def set_future_defaults(self, current_params: Dict, default_file_data: Dict, ski
853864
854865 if section_name in skip and param in skip [section_name ]:
855866 continue
856- param_is_not_set = True if "" == default_file_data .get (section_name , {}).get (param , "" ) else False
867+
868+ default_param = param
869+ if param == 'role_arn' :
870+ if self .infra_type == 'storage' :
871+ default_param = 'StorageServiceRoleArn'
872+ elif self .infra_type == 'pipeline' :
873+ default_param = 'PipelineServiceRoleArn'
874+
875+ param_is_not_set = True if "" == default_file_data .get (section_name , {}).get (default_param , "" ) else False
857876
858877 if param in curr_deploy_params_for_section and param_is_not_set :
859878 if curr_deploy_params_for_section [param ]:
@@ -868,7 +887,7 @@ def set_future_defaults(self, current_params: Dict, default_file_data: Dict, ski
868887 if section_name not in skip :
869888 skip [section_name ] = []
870889 skip [section_name ].append (param )
871- default_file_data [section_name ][param ] = curr_deploy_params_for_section [param ]
890+ default_file_data [section_name ][default_param ] = curr_deploy_params_for_section [param ]
872891
873892 return (default_file_data , skip )
874893
@@ -1605,8 +1624,8 @@ def build_config(self, infra_type: str, template_file: str, atlantis_deploy_para
16051624 'deployments' : deployments
16061625 }
16071626
1608- # Add role_arn if this is a pipeline deployment
1609- if infra_type == 'pipeline' :
1627+ # Add role_arn if this is a pipeline or storage deployment
1628+ if infra_type in [ 'pipeline' , 'storage' ] :
16101629 config ['atlantis' ]['deploy' ]['parameters' ]['role_arn' ] = atlantis_deploy_params ['role_arn' ]
16111630
16121631 return config
0 commit comments