Skip to content

Commit

Permalink
Fix Delete AWS deployment issue
Browse files Browse the repository at this point in the history
  • Loading branch information
kbeaugrand committed Jun 25, 2023
1 parent 88e44d1 commit 6c87b1d
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions src/IoTHub.Portal.Infrastructure/Services/AWS/AwsConfigService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -219,11 +219,20 @@ public Task<Configuration> GetConfigItem(string id)

public async Task DeleteConfiguration(string modelId)
{
var modules = await GetConfigModuleList(modelId);

//Deprecate Deployment Thing type
// Deprecate Deployment Thing type
await DeprecateDeploymentThingType(modelId);

IEnumerable<IoTEdgeModule> modules = Array.Empty<IoTEdgeModule>();

try
{
modules = await GetConfigModuleList(modelId);
}
catch (InternalServerErrorException e)
{
this.logger.LogError($"Failed to get model modules when deleting. Some resources might persist in AWS for model {modelId}.");
}

foreach (var module in modules.Where(c => string.IsNullOrEmpty(c.Id)))
{
try
Expand Down Expand Up @@ -261,9 +270,7 @@ public async Task DeleteConfiguration(string modelId)
catch (AmazonGreengrassV2Exception e)
{
throw new InternalServerErrorException("The deletion of the deployment failed due to an error in the Amazon IoT API.", e);

}

}

private async Task DeprecateDeploymentThingType(string modelId)
Expand Down Expand Up @@ -387,7 +394,6 @@ public async Task<List<IoTEdgeModule>> GetConfigModuleList(string modelId)
catch (Amazon.GreengrassV2.Model.ResourceNotFoundException)
{
throw new InternalServerErrorException("Unable to find the deployment due to an error in the Amazon IoT API. ");

}
}

Expand Down

0 comments on commit 6c87b1d

Please sign in to comment.