@@ -209,12 +209,12 @@ func (p *Platform) DeleteStack(region string, wait bool) error {
209
209
}
210
210
211
211
log .Debug ("deleting function" )
212
- if err := p .deleteFunction (); err != nil && ! isNotFound (err ) {
212
+ if err := p .deleteFunction (region ); err != nil && ! isNotFound (err ) {
213
213
return errors .Wrap (err , "deleting function" )
214
214
}
215
215
216
216
log .Debug ("deleting role" )
217
- if err := p .deleteRole (); err != nil && ! isNotFound (err ) {
217
+ if err := p .deleteRole (region ); err != nil && ! isNotFound (err ) {
218
218
return errors .Wrap (err , "deleting role" )
219
219
}
220
220
@@ -341,8 +341,9 @@ func (p *Platform) updateFunction(c *lambda.Lambda, stage string) (version strin
341
341
}
342
342
343
343
// deleteFunction deletes the lambda function.
344
- func (p * Platform ) deleteFunction () error {
345
- c := lambda .New (session .New (aws .NewConfig ()))
344
+ func (p * Platform ) deleteFunction (region string ) error {
345
+ // TODO: sessions all over... refactor
346
+ c := lambda .New (session .New (aws .NewConfig ().WithRegion (region )))
346
347
347
348
_ , err := c .DeleteFunction (& lambda.DeleteFunctionInput {
348
349
FunctionName : & p .config .Name ,
@@ -406,9 +407,9 @@ func (p *Platform) createRole() error {
406
407
}
407
408
408
409
// deleteRole deletes the role and policy.
409
- func (p * Platform ) deleteRole () error {
410
+ func (p * Platform ) deleteRole (region string ) error {
410
411
name := fmt .Sprintf ("%s-api-function" , p .config .Name )
411
- c := iam .New (session .New (aws .NewConfig ()))
412
+ c := iam .New (session .New (aws .NewConfig (). WithRegion ( region ) ))
412
413
413
414
_ , err := c .DeleteRolePolicy (& iam.DeleteRolePolicyInput {
414
415
RoleName : & name ,
@@ -481,6 +482,7 @@ func (p *Platform) removeProxy() error {
481
482
482
483
// isNotFound returns true if it's a "function not found" error.
483
484
func isNotFound (err error ) bool {
485
+ // TODO: move these to util
484
486
return err != nil && strings .Contains (err .Error (), "not found" )
485
487
}
486
488
0 commit comments