Skip to content

add error handling logic to ignore if rule no longer exists #1285

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -56,27 +56,39 @@ async function onCreate(event: CloudFormationCustomResourceEvent) {

if (groupId) {
if (securityGroupIngress && securityGroupIngress.length > 0) {
// Deleting VPC default security group inbound rule
await throttlingBackOff(() => ec2.revokeSecurityGroupIngress(buildDeleteIngressRequest({ groupId })).promise());
try {
// Deleting VPC default security group inbound rule
await throttlingBackOff(() => ec2.revokeSecurityGroupIngress(buildDeleteIngressRequest({ groupId })).promise());
} catch (error: any) {
console.log('Error trying to remove default security group Ingress rule');
}
}

if (securityGroupEgress && securityGroupEgress.length > 0) {
// Deleting VPC default security group outbound rule
await throttlingBackOff(() => ec2.revokeSecurityGroupEgress(buildDeleteEgressRequest({ groupId })).promise());
try {
// Deleting VPC default security group outbound rule
await throttlingBackOff(() => ec2.revokeSecurityGroupEgress(buildDeleteEgressRequest({ groupId })).promise());
} catch (error: any) {
console.log('Error trying to remove default security group Egress rule');
}
}

if (tags && tags.length === 0) {
// Attaching tags to the VPC default security group
await throttlingBackOff(() =>
ec2
.createTags(
buildCreateTagsRequest({
groupId,
acceleratorName: event.ResourceProperties.acceleratorName,
}),
)
.promise(),
);
try {
// Attaching tags to the VPC default security group
await throttlingBackOff(() =>
ec2
.createTags(
buildCreateTagsRequest({
groupId,
acceleratorName: event.ResourceProperties.acceleratorName,
}),
)
.promise(),
);
} catch (error: any) {
console.log('Error trying to add tags to default security group');
}
}
}

Expand Down