Skip to content

Commit

Permalink
Add removal of "dangling" ENIs from MSK event integration
Browse files Browse the repository at this point in the history
  • Loading branch information
pgrzesik committed Sep 18, 2020
1 parent 7380ec0 commit 29d7c02
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
4 changes: 4 additions & 0 deletions test/integration/msk/cloudformation.yml
Expand Up @@ -138,6 +138,10 @@ Resources:
Revision: !Ref ClusterConfigurationRevision

Outputs:
VPC:
Description: VPC ID
Value: !Ref VPC

PrivateSubnetA:
Description: Private Subnet A ID
Value: !Ref PrivateSubnetA
Expand Down
23 changes: 22 additions & 1 deletion test/integration/msk/index.test.js
Expand Up @@ -16,6 +16,7 @@ describe('AWS - MSK Integration Test', function() {
let stackName;
let servicePath;
let clusterConfigurationArn;
let outputMap;
const stage = 'dev';

const suffix = crypto.randomBytes(8).toString('hex');
Expand Down Expand Up @@ -56,7 +57,7 @@ describe('AWS - MSK Integration Test', function() {
StackName: resourcesStackName,
});

const outputMap = waitForResult.Stacks[0].Outputs.reduce((map, output) => {
outputMap = waitForResult.Stacks[0].Outputs.reduce((map, output) => {
map[output.OutputKey] = output.OutputValue;
return map;
}, {});
Expand Down Expand Up @@ -105,6 +106,26 @@ describe('AWS - MSK Integration Test', function() {
after(async () => {
log.notice('Removing service...');
await removeService(servicePath);
log.notice('Removing leftover ENI...');
const describeResponse = await awsRequest('EC2', 'describeNetworkInterfaces', {
Filters: [
{
Name: 'vpc-id',
Values: [outputMap.VPC],
},
{
Name: 'status',
Values: ['available'],
},
],
});
await Promise.all(
describeResponse.NetworkInterfaces.map(networkInterface =>
awsRequest('EC2', 'deleteNetworkInterface', {
NetworkInterfaceId: networkInterface.NetworkInterfaceId,
})
)
);
log.notice('Removing CloudFormation stack with required resources...');
await awsRequest('CloudFormation', 'deleteStack', { StackName: resourcesStackName });
await awsRequest('CloudFormation', 'waitFor', 'stackDeleteComplete', {
Expand Down

0 comments on commit 29d7c02

Please sign in to comment.