Skip to content

Conversation

@viren-nadkarni
Copy link
Contributor

@viren-nadkarni viren-nadkarni commented Apr 15, 2025

AWS does not allow deleting VPCs that have subnets associated with it. This PR adds this behaviour to Moto.

@viren-nadkarni viren-nadkarni changed the title EC2: Raise DependencyViolationError for VPCs with linked Subnets EC2: Raise when deleting VPCs with dependent Subnets Apr 15, 2025
"VPC": {
"Type": "AWS::EC2::VPC",
"Properties": {"CidrBlock": "10.0.0.0/16"},
},
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Moto Cfn evaluates deletion in sequence, so now, attempting to delete VPCs before subnets raises.

It's not clear to me where/if Moto figures out the right order of resource manipulation, or how much additional work is required.

This is a quick workaround to make the test pass in the interim.

Copy link
Collaborator

Choose a reason for hiding this comment

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

This is arguably a bug in Moto - we figure out the right order when updating CF resources, but not yet when deleting them. I'll raise a separate PR to fix this.

@codecov
Copy link

codecov bot commented Apr 16, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 92.82%. Comparing base (b29a9c8) to head (4f2d4f0).
Report is 29 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #8811      +/-   ##
==========================================
+ Coverage   92.80%   92.82%   +0.01%     
==========================================
  Files        1261     1266       +5     
  Lines      109888   110464     +576     
==========================================
+ Hits       101986   102536     +550     
- Misses       7902     7928      +26     
Flag Coverage Δ
servertests 28.11% <0.00%> (-0.11%) ⬇️
unittests 92.79% <100.00%> (+0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ 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.

@viren-nadkarni viren-nadkarni marked this pull request as ready for review April 16, 2025 11:29
Copy link
Collaborator

@bblommers bblommers left a comment

Choose a reason for hiding this comment

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

Thanks @viren-nadkarni!

@bblommers bblommers added this to the 5.1.4 milestone Apr 19, 2025
@bblommers bblommers merged commit 847674e into getmoto:master Apr 19, 2025
56 of 57 checks passed
@viren-nadkarni viren-nadkarni deleted the ec2-vpc-deps branch April 21, 2025 06:42
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.

2 participants