Skip to content

Fix intermittent IAM permission failures in delete-deployment command#958

Closed
AlexDaines wants to merge 1 commit intomainfrom
adaines/fix-delete-deployment-iam-permissions
Closed

Fix intermittent IAM permission failures in delete-deployment command#958
AlexDaines wants to merge 1 commit intomainfrom
adaines/fix-delete-deployment-iam-permissions

Conversation

@AlexDaines
Copy link
Copy Markdown
Contributor

Issue #, if available:
Package Verifier Canary failed during SmokeTests execution (V1823703386)
Package Verifier Canary failed during SmokeTests execution (V1823700902)

Description of changes:

Fixed CloudFormation client initialization timing issue in DeleteDeploymentCommand

  • Client was being created with wrong AWS credentials during constructor execution

  • Moved client creation to ExecuteAsync after credentials are properly configured

Testing

  • Built successfully with dotnet build
  • No existing unit tests directly instantiate DeleteDeploymentCommand
  • Fix addresses the cross-account permission errors seen in smoke test logs

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@AlexDaines AlexDaines requested a review from philasmar June 24, 2025 18:15
@codecov
Copy link
Copy Markdown

codecov bot commented Jun 24, 2025

Codecov Report

Attention: Patch coverage is 0% with 3 lines in your changes missing coverage. Please review.

Project coverage is 35.11%. Comparing base (7aa80c4) to head (97b856e).
Report is 28 commits behind head on main.

Files with missing lines Patch % Lines
...AWS.Deploy.CLI/Commands/DeleteDeploymentCommand.cs 0.00% 3 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##             main     #958       +/-   ##
===========================================
- Coverage   62.14%   35.11%   -27.03%     
===========================================
  Files         294      294               
  Lines       10796    10796               
  Branches     1616     1616               
===========================================
- Hits         6709     3791     -2918     
- Misses       3487     6659     +3172     
+ Partials      600      346      -254     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

private readonly IAWSUtilities _awsUtilities;
private readonly IProjectParserUtility _projectParserUtility;
private readonly IAWSResourceQueryer _awsResourceQueryer;
private IAmazonCloudFormation? _cloudFormationClient;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why does this need to be optional now?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

when the constructor runs the object is created as null and stays null until we do the assignment in ExecuteAsync. So without the ?, C# would want us to initialize it in the constructor, which is the bug we're fixing

Copy link
Copy Markdown
Contributor

@GarrettBeatty GarrettBeatty Jun 25, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you keep the code as is but then just add the extra line you added on line 83? so the only change will be recreating the cloudformation client. im not a huge fan of the optional values

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what do you think @philasmar

@philasmar
Copy link
Copy Markdown
Contributor

You should be targeting dev not main

private readonly IAWSUtilities _awsUtilities;
private readonly IProjectParserUtility _projectParserUtility;
private readonly IAWSResourceQueryer _awsResourceQueryer;
private IAmazonCloudFormation? _cloudFormationClient;
Copy link
Copy Markdown
Contributor

@GarrettBeatty GarrettBeatty Jun 25, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you keep the code as is but then just add the extra line you added on line 83? so the only change will be recreating the cloudformation client. im not a huge fan of the optional values

@philasmar
Copy link
Copy Markdown
Contributor

Do you mind if I take a stab at it? I want to move some things around.

@AlexDaines
Copy link
Copy Markdown
Contributor Author

Do you mind if I take a stab at it? I want to move some things around.

Please do! No worries.

@AlexDaines AlexDaines closed this Jun 25, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants