@@ -28,12 +28,12 @@ public class DeleteDeploymentCommand : CancellableAsyncCommand<DeleteDeploymentC
2828
2929 private readonly IAWSClientFactory _awsClientFactory ;
3030 private readonly IToolInteractiveService _interactiveService ;
31- private readonly IAmazonCloudFormation _cloudFormationClient ;
3231 private readonly IConsoleUtilities _consoleUtilities ;
3332 private readonly ILocalUserSettingsEngine _localUserSettingsEngine ;
3433 private readonly IAWSUtilities _awsUtilities ;
3534 private readonly IProjectParserUtility _projectParserUtility ;
3635 private readonly IAWSResourceQueryer _awsResourceQueryer ;
36+ private IAmazonCloudFormation ? _cloudFormationClient ;
3737 private const int MAX_RETRIES = 4 ;
3838
3939 /// <summary>
@@ -51,7 +51,6 @@ public DeleteDeploymentCommand(
5151 _awsClientFactory = awsClientFactory ;
5252 _interactiveService = interactiveService ;
5353 _consoleUtilities = consoleUtilities ;
54- _cloudFormationClient = _awsClientFactory . GetAWSClient < IAmazonCloudFormation > ( ) ;
5554 _localUserSettingsEngine = localUserSettingsEngine ;
5655 _awsUtilities = awsUtilities ;
5756 _projectParserUtility = projectParserUtility ;
@@ -80,6 +79,9 @@ public override async Task<int> ExecuteAsync(CommandContext context, DeleteDeplo
8079 awsOption . Region = RegionEndpoint . GetBySystemName ( awsRegion ) ;
8180 } ) ;
8281
82+ // Create CloudFormation client after credentials are configured
83+ _cloudFormationClient = _awsClientFactory . GetAWSClient < IAmazonCloudFormation > ( ) ;
84+
8385 if ( string . IsNullOrEmpty ( settings . DeploymentName ) )
8486 {
8587 _interactiveService . WriteErrorLine ( string . Empty ) ;
@@ -123,7 +125,7 @@ public override async Task<int> ExecuteAsync(CommandContext context, DeleteDeplo
123125
124126 try
125127 {
126- await _cloudFormationClient . DeleteStackAsync ( new DeleteStackRequest
128+ await _cloudFormationClient ! . DeleteStackAsync ( new DeleteStackRequest
127129 {
128130 StackName = settings . DeploymentName
129131 } ) ;
@@ -218,7 +220,7 @@ private async Task WaitForStackDelete(string stackName)
218220 {
219221 await Task . Delay ( waitTime ) ;
220222
221- var response = await _cloudFormationClient . DescribeStacksAsync ( new DescribeStacksRequest
223+ var response = await _cloudFormationClient ! . DescribeStacksAsync ( new DescribeStacksRequest
222224 {
223225 StackName = stackName
224226 } ) ;
0 commit comments