Skip to content

Commit 3daaf50

Browse files
Merge branch 'dev'
2 parents 0094629 + 9e889b5 commit 3daaf50

File tree

10 files changed

+63
-20
lines changed

10 files changed

+63
-20
lines changed

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
## Release 2025-06-25
2+
3+
### AWS.Deploy.CLI (2.0.1)
4+
* Fixed intermittent IAM permission failures in delete-deployment command by ensuring CloudFormation client is created after AWS credentials are configured
5+
### AWS.Deploy.Recipes.CDK.Common (2.0.1)
6+
### AWS.Deploy.ServerMode.Client (2.0.1)
7+
18
## Release 2025-06-16
29

310
### AWS.Deploy.CLI (2.0.0)

src/AWS.Deploy.CLI/AWS.Deploy.CLI.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
<NoWarn>$(NoWarn);1570;1591;ASP0000</NoWarn>
2323
<RollForward>Major</RollForward>
2424
<PackageReadmeFile>README.md</PackageReadmeFile>
25-
<Version>2.0.0</Version>
25+
<Version>2.0.1</Version>
2626
</PropertyGroup>
2727

2828
<ItemGroup>

src/AWS.Deploy.CLI/Commands/DeleteDeploymentCommand.cs

Lines changed: 5 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,6 @@
11
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
22
// SPDX-License-Identifier: Apache-2.0
33

4-
using System;
5-
using System.Linq;
6-
using System.Threading;
7-
using System.Threading.Tasks;
84
using Amazon;
95
using Amazon.CloudFormation;
106
using Amazon.CloudFormation.Model;
@@ -28,7 +24,6 @@ public class DeleteDeploymentCommand : CancellableAsyncCommand<DeleteDeploymentC
2824

2925
private readonly IAWSClientFactory _awsClientFactory;
3026
private readonly IToolInteractiveService _interactiveService;
31-
private readonly IAmazonCloudFormation _cloudFormationClient;
3227
private readonly IConsoleUtilities _consoleUtilities;
3328
private readonly ILocalUserSettingsEngine _localUserSettingsEngine;
3429
private readonly IAWSUtilities _awsUtilities;
@@ -51,7 +46,6 @@ public DeleteDeploymentCommand(
5146
_awsClientFactory = awsClientFactory;
5247
_interactiveService = interactiveService;
5348
_consoleUtilities = consoleUtilities;
54-
_cloudFormationClient = _awsClientFactory.GetAWSClient<IAmazonCloudFormation>();
5549
_localUserSettingsEngine = localUserSettingsEngine;
5650
_awsUtilities = awsUtilities;
5751
_projectParserUtility = projectParserUtility;
@@ -123,10 +117,7 @@ public override async Task<int> ExecuteAsync(CommandContext context, DeleteDeplo
123117

124118
try
125119
{
126-
await _cloudFormationClient.DeleteStackAsync(new DeleteStackRequest
127-
{
128-
StackName = settings.DeploymentName
129-
});
120+
await _awsResourceQueryer.DeleteStack(settings.DeploymentName);
130121

131122
// Fire and forget the monitor
132123
// Monitor updates the stdout with current status of the CloudFormation stack
@@ -218,20 +209,17 @@ private async Task WaitForStackDelete(string stackName)
218209
{
219210
await Task.Delay(waitTime);
220211

221-
var response = await _cloudFormationClient.DescribeStacksAsync(new DescribeStacksRequest
222-
{
223-
StackName = stackName
224-
});
212+
var response = await _awsResourceQueryer.DescribeStacks(stackName);
225213

226-
stack = response.Stacks == null || response.Stacks.Count == 0 ? null : response.Stacks[0];
214+
stack = response.Count == 0 ? null : response[0];
227215
shouldRetry = false;
228216
}
229-
catch (AmazonCloudFormationException exception) when (exception.ErrorCode.Equals("ValidationError") && exception.Message.Equals($"Stack with id {stackName} does not exist"))
217+
catch (ResourceQueryException exception) when (exception.InnerException is AmazonCloudFormationException amazonCloudFormationException && amazonCloudFormationException.ErrorCode.Equals("ValidationError") && amazonCloudFormationException.Message.Equals($"Stack with id {stackName} does not exist"))
230218
{
231219
_interactiveService.WriteDebugLine(exception.PrettyPrint());
232220
shouldRetry = false;
233221
}
234-
catch (AmazonCloudFormationException exception) when (exception.ErrorCode.Equals("Throttling"))
222+
catch (ResourceQueryException exception) when (exception.InnerException is AmazonCloudFormationException amazonCloudFormationException && amazonCloudFormationException.ErrorCode.Equals("Throttling"))
235223
{
236224
_interactiveService.WriteDebugLine(exception.PrettyPrint());
237225
shouldRetry = true;

src/AWS.Deploy.CLI/ServerMode/Services/SessionAWSResourceQuery.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,16 @@ public async Task<Distribution> GetCloudFrontDistribution(string distributionId)
243243
return (await GetAndCache(async () => await _awsResourceQueryer.GetCloudFrontDistribution(distributionId), new object[] { distributionId }))!;
244244
}
245245

246+
public async Task<List<Stack>> DescribeStacks(string stackName)
247+
{
248+
return (await GetAndCache(async () => await _awsResourceQueryer.DescribeStacks(stackName), new object[] { stackName }))!;
249+
}
250+
251+
public async Task<DeleteStackResponse> DeleteStack(string stackName)
252+
{
253+
return (await GetAndCache(async () => await _awsResourceQueryer.DeleteStack(stackName), new object[] { stackName }))!;
254+
}
255+
246256
/// <inheritdoc/>
247257
public async Task<Vpc?> GetDefaultVpc()
248258
{

src/AWS.Deploy.Common/Data/IAWSResourceQueryer.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ public enum BeanstalkPlatformType { Linux, Windows }
3636
/// </remarks>
3737
public interface IAWSResourceQueryer
3838
{
39+
Task<List<Stack>> DescribeStacks(string stackName);
40+
Task<DeleteStackResponse> DeleteStack(string stackName);
3941
Task<Vpc?> GetDefaultVpc();
4042
Task<ResourceDescription> GetCloudControlApiResource(string type, string identifier);
4143
Task<List<StackEvent>> GetCloudFormationStackEvents(string stackName);

src/AWS.Deploy.Orchestration/Data/AWSResourceQueryer.cs

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,34 @@ namespace AWS.Deploy.Orchestration.Data
5151
{
5252
public class AWSResourceQueryer(IAWSClientFactory awsClientFactory) : IAWSResourceQueryer
5353
{
54+
public async Task<List<Stack>> DescribeStacks(string stackName)
55+
{
56+
var cfClient = awsClientFactory.GetAWSClient<IAmazonCloudFormation>();
57+
var request = new DescribeStacksRequest
58+
{
59+
StackName = stackName
60+
};
61+
62+
return await HandleException(async () => await cfClient.Paginators
63+
.DescribeStacks(request)
64+
.Stacks
65+
.ToListAsync(),
66+
$"Error attempting to describe available CloudFormation stacks using stack name '{stackName}'");
67+
}
68+
69+
public async Task<DeleteStackResponse> DeleteStack(string stackName)
70+
{
71+
var cfClient = awsClientFactory.GetAWSClient<IAmazonCloudFormation>();
72+
var request = new DeleteStackRequest
73+
{
74+
StackName = stackName
75+
};
76+
77+
return await HandleException(async () => await cfClient
78+
.DeleteStackAsync(request),
79+
$"Error attempting to delete the CloudFormation stack '{stackName}'.");
80+
}
81+
5482
public async Task<ResourceDescription> GetCloudControlApiResource(string type, string identifier)
5583
{
5684
var cloudControlApiClient = awsClientFactory.GetAWSClient<IAmazonCloudControlApi>();

src/AWS.Deploy.Recipes.CDK.Common/AWS.Deploy.Recipes.CDK.Common.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
<PackageIcon>icon.png</PackageIcon>
1414
<PackageProjectUrl>https://github.com/aws/aws-dotnet-deploy</PackageProjectUrl>
1515
<PackageReadmeFile>README.md</PackageReadmeFile>
16-
<Version>2.0.0</Version>
16+
<Version>2.0.1</Version>
1717
</PropertyGroup>
1818

1919
<ItemGroup>

src/AWS.Deploy.ServerMode.Client/AWS.Deploy.ServerMode.Client.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
<PackageProjectUrl>https://github.com/aws/aws-dotnet-deploy</PackageProjectUrl>
1313
<SignAssembly>true</SignAssembly>
1414
<AssemblyOriginatorKeyFile>..\..\public.snk</AssemblyOriginatorKeyFile>
15-
<Version>2.0.0</Version>
15+
<Version>2.0.1</Version>
1616
</PropertyGroup>
1717

1818
<ItemGroup>

test/AWS.Deploy.CLI.IntegrationTests/Utilities/TestToolAWSResourceQueryer.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,10 @@ public Task<PlatformSummary> GetLatestElasticBeanstalkPlatformArn(string? target
6969
public Task<List<SecurityGroup>> DescribeSecurityGroups(string? vpcID = null) => throw new NotImplementedException();
7070
public Task<string?> GetParameterStoreTextValue(string parameterName) => throw new NotImplementedException();
7171
public Task<ResourceDescription> GetCloudControlApiResource(string type, string identifier) => throw new NotImplementedException();
72+
public Task<List<Stack>> DescribeStacks(string stackName) => throw new NotImplementedException();
73+
74+
public Task<DeleteStackResponse> DeleteStack(string stackName) => throw new NotImplementedException();
75+
7276
public Task<Vpc?> GetDefaultVpc() => throw new NotImplementedException();
7377
public Task<List<ConfigurationSettingsDescription>> DescribeElasticBeanstalkConfigurationSettings(string applicationName, string environmentName) => throw new NotImplementedException();
7478
}

test/AWS.Deploy.CLI.UnitTests/Utilities/TestToolAWSResourceQueryer.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,10 @@ public Task<PlatformSummary> GetLatestElasticBeanstalkPlatformArn(string? target
9494
public Task<List<SecurityGroup>> DescribeSecurityGroups(string? vpcID = null) => throw new NotImplementedException();
9595
public Task<string?> GetParameterStoreTextValue(string parameterName) => throw new NotImplementedException();
9696
public Task<ResourceDescription> GetCloudControlApiResource(string type, string identifier) => throw new NotImplementedException();
97+
public Task<List<Stack>> DescribeStacks(string stackName) => throw new NotImplementedException();
98+
99+
public Task<DeleteStackResponse> DeleteStack(string stackName) => throw new NotImplementedException();
100+
97101
public Task<Vpc?> GetDefaultVpc() => throw new NotImplementedException();
98102
public Task<List<ConfigurationSettingsDescription>> DescribeElasticBeanstalkConfigurationSettings(string applicationName, string environmentName) => throw new NotImplementedException();
99103
}

0 commit comments

Comments
 (0)