@@ -56,27 +56,39 @@ async function onCreate(event: CloudFormationCustomResourceEvent) {
56
56
57
57
if ( groupId ) {
58
58
if ( securityGroupIngress && securityGroupIngress . length > 0 ) {
59
- // Deleting VPC default security group inbound rule
60
- await throttlingBackOff ( ( ) => ec2 . revokeSecurityGroupIngress ( buildDeleteIngressRequest ( { groupId } ) ) . promise ( ) ) ;
59
+ try {
60
+ // Deleting VPC default security group inbound rule
61
+ await throttlingBackOff ( ( ) => ec2 . revokeSecurityGroupIngress ( buildDeleteIngressRequest ( { groupId } ) ) . promise ( ) ) ;
62
+ } catch ( error : any ) {
63
+ console . log ( 'Error trying to remove default security group Ingress rule' ) ;
64
+ }
61
65
}
62
66
63
67
if ( securityGroupEgress && securityGroupEgress . length > 0 ) {
64
- // Deleting VPC default security group outbound rule
65
- await throttlingBackOff ( ( ) => ec2 . revokeSecurityGroupEgress ( buildDeleteEgressRequest ( { groupId } ) ) . promise ( ) ) ;
68
+ try {
69
+ // Deleting VPC default security group outbound rule
70
+ await throttlingBackOff ( ( ) => ec2 . revokeSecurityGroupEgress ( buildDeleteEgressRequest ( { groupId } ) ) . promise ( ) ) ;
71
+ } catch ( error : any ) {
72
+ console . log ( 'Error trying to remove default security group Egress rule' ) ;
73
+ }
66
74
}
67
75
68
76
if ( tags && tags . length === 0 ) {
69
- // Attaching tags to the VPC default security group
70
- await throttlingBackOff ( ( ) =>
71
- ec2
72
- . createTags (
73
- buildCreateTagsRequest ( {
74
- groupId,
75
- acceleratorName : event . ResourceProperties . acceleratorName ,
76
- } ) ,
77
- )
78
- . promise ( ) ,
79
- ) ;
77
+ try {
78
+ // Attaching tags to the VPC default security group
79
+ await throttlingBackOff ( ( ) =>
80
+ ec2
81
+ . createTags (
82
+ buildCreateTagsRequest ( {
83
+ groupId,
84
+ acceleratorName : event . ResourceProperties . acceleratorName ,
85
+ } ) ,
86
+ )
87
+ . promise ( ) ,
88
+ ) ;
89
+ } catch ( error : any ) {
90
+ console . log ( 'Error trying to add tags to default security group' ) ;
91
+ }
80
92
}
81
93
}
82
94
0 commit comments