Skip to content

Commit

Permalink
fix bug to delete secrets when removing edge device
Browse files Browse the repository at this point in the history
  • Loading branch information
ssgueye2 committed Jun 5, 2023
1 parent c98a70e commit 02e6dd4
Showing 1 changed file with 4 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -447,6 +447,7 @@ public async Task RemoveDeviceCredentials(IoTEdgeDevice device)
while (true);
}


private async Task RemoveGreengrassCertificateFromPrincipal(IoTEdgeDevice device, string principalId)
{
_ = await this.amazonIoTClient.DetachPolicyAsync(new DetachPolicyRequest
Expand All @@ -465,19 +466,19 @@ private async Task RemoveGreengrassCertificateFromPrincipal(IoTEdgeDevice device
_ = await this.amazonSecretsManager.DeleteSecretAsync(new DeleteSecretRequest
{
ForceDeleteWithoutRecovery = true,
SecretId = device.DeviceId + PublicKeyKey,
SecretId = device.DeviceName + PublicKeyKey,
});

_ = await this.amazonSecretsManager.DeleteSecretAsync(new DeleteSecretRequest
{
ForceDeleteWithoutRecovery = true,
SecretId = device.DeviceId + PrivateKeyKey,
SecretId = device.DeviceName + PrivateKeyKey,
});

_ = await this.amazonSecretsManager.DeleteSecretAsync(new DeleteSecretRequest
{
ForceDeleteWithoutRecovery = true,
SecretId = device.DeviceId + CertificateKey,
SecretId = device.DeviceName + CertificateKey,
});

var awsPricipalCertRegex = new Regex("/arn:aws:iot:([a-z0-9-]*):(\\d*):cert\\/([0-9a-fA-F]*)/gm");
Expand Down

0 comments on commit 02e6dd4

Please sign in to comment.