Skip to content

Commit 27c8991

Browse files
committed
🐛 Delete VPC endpoints only if s3 bucket is enabled
Signed-off-by: Vince Prignano <[email protected]>
1 parent 2a030a7 commit 27c8991

File tree

2 files changed

+9
-18
lines changed

2 files changed

+9
-18
lines changed

controllers/awscluster_controller_test.go

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -827,24 +827,6 @@ func mockedDeleteVPCCallsForNonExistentVPC(m *mocks.MockEC2APIMockRecorder) {
827827
}
828828

829829
func mockedDeleteVPCCalls(m *mocks.MockEC2APIMockRecorder) {
830-
m.DescribeVpcEndpointsPages(gomock.Eq(&ec2.DescribeVpcEndpointsInput{
831-
Filters: []*ec2.Filter{
832-
{
833-
Name: aws.String("vpc-id"),
834-
Values: aws.StringSlice([]string{"vpc-exists"}),
835-
},
836-
}}),
837-
gomock.Any()).Do(func(_, y interface{}) {
838-
funct := y.(func(page *ec2.DescribeVpcEndpointsOutput, lastPage bool) bool)
839-
funct(&ec2.DescribeVpcEndpointsOutput{VpcEndpoints: []*ec2.VpcEndpoint{{
840-
VpcEndpointId: aws.String("vpce-12345"),
841-
}}}, true)
842-
}).Return(nil).AnyTimes()
843-
844-
m.DeleteVpcEndpoints(gomock.Eq(&ec2.DeleteVpcEndpointsInput{
845-
VpcEndpointIds: aws.StringSlice([]string{"vpce-12345"}),
846-
})).Return(&ec2.DeleteVpcEndpointsOutput{}, nil).AnyTimes()
847-
848830
m.DescribeSubnetsWithContext(context.TODO(), gomock.Eq(&ec2.DescribeSubnetsInput{
849831
Filters: []*ec2.Filter{
850832
{

pkg/cloud/services/network/vpc.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -276,6 +276,15 @@ func (s *Service) deleteVPCEndpoints() error {
276276
return nil
277277
}
278278

279+
// Gather all services that might have been enabled.
280+
services := sets.New[string]()
281+
if s.scope.Bucket() != nil {
282+
services.Insert(fmt.Sprintf("com.amazonaws.%s.s3", s.scope.Region()))
283+
}
284+
if services.Len() == 0 {
285+
return nil
286+
}
287+
279288
// Get all existing endpoints.
280289
endpoints, err := s.describeVPCEndpoints()
281290
if err != nil {

0 commit comments

Comments
 (0)