@@ -67,49 +67,54 @@ def enable_flowlogs(VpcId,client,args,region):
67
67
}
68
68
]
69
69
):
70
-
71
- for FlowLog in page ['FlowLogs' ]:
72
- if FlowLog ['LogDestination' ] == bucket :
73
- accept_destructive_update = False
74
-
75
- logger .debug (" Flow Log ({}) already exist, region:{}, VPC:{}" .format (FlowLog ['FlowLogId' ],region ,VpcId ))
76
- if FlowLog ['DeliverLogsStatus' ] == 'FAILED' :
77
- logger .error ("Flow Log ({}) failed, region:{}, VPC:{}, please check it" .format (FlowLog ['FlowLogId' ],region ,VpcId ))
78
- return
79
-
80
- logger .debug ("Flow Log ({}) is {} on {}\n traffic type: {}\n destination type: {}\n destination: {}\n log format: \n {}" .format (
81
- FlowLog ['FlowLogId' ],
82
- FlowLog ['FlowLogStatus' ],
83
- FlowLog ['ResourceId' ],
84
- FlowLog ['TrafficType' ],
85
- FlowLog ['LogDestinationType' ],
86
- FlowLog ['LogDestination' ],
87
- FlowLog ['LogFormat' ]
88
- ))
89
-
90
- difflist = []
91
- if FlowLog ['TrafficType' ] != args .traffic_type :
92
- difflist .append ("Traffic type will change from {} to {}." .format (FlowLog ['TrafficType' ],args .traffic_type ))
93
- if FlowLog ['LogDestination' ] != bucket :
94
- difflist .append ("Log Destination will change from {} to {}." .format (FlowLog ['LogDestination' ],bucket ))
95
-
96
- if difflist == []:
97
- # No actions to perform here
98
- continue
99
-
100
- logger .info ("Existing flow log will be terminated and new flow log created with these changes:\n \t {}\n " .format (difflist ))
101
-
102
- if args .force :
103
- accept_destructive_update = 'y'
70
+
71
+ if page ['FlowLogs' ]:
72
+
73
+ for FlowLog in page ['FlowLogs' ]:
74
+ if FlowLog ['LogDestination' ] == bucket :
75
+
76
+ accept_destructive_update = False
77
+
78
+ logger .debug (" Flow Log ({}) already exist, region:{}, VPC:{}" .format (FlowLog ['FlowLogId' ],region ,VpcId ))
79
+ if FlowLog ['DeliverLogsStatus' ] == 'FAILED' :
80
+ logger .error ("Flow Log ({}) failed, region:{}, VPC:{}, please check it" .format (FlowLog ['FlowLogId' ],region ,VpcId ))
81
+ return
82
+
83
+ logger .debug ("Flow Log ({}) is {} on {}\n traffic type: {}\n destination type: {}\n destination: {}\n log format: \n {}" .format (
84
+ FlowLog ['FlowLogId' ],
85
+ FlowLog ['FlowLogStatus' ],
86
+ FlowLog ['ResourceId' ],
87
+ FlowLog ['TrafficType' ],
88
+ FlowLog ['LogDestinationType' ],
89
+ FlowLog ['LogDestination' ],
90
+ FlowLog ['LogFormat' ]
91
+ ))
92
+
93
+ difflist = []
94
+ if FlowLog ['TrafficType' ] != args .traffic_type :
95
+ difflist .append ("Traffic type will change from {} to {}." .format (FlowLog ['TrafficType' ],args .traffic_type ))
96
+ if FlowLog ['LogDestination' ] != bucket :
97
+ difflist .append ("Log Destination will change from {} to {}." .format (FlowLog ['LogDestination' ],bucket ))
98
+
99
+ if difflist == []:
100
+ # No actions to perform here
101
+ continue
102
+
103
+ logger .info ("Existing flow log will be terminated and new flow log created with these changes:\n \t {}\n " .format (difflist ))
104
+
105
+ if args .force :
106
+ accept_destructive_update = 'y'
107
+ else :
108
+ accept_destructive_update = input (f'Do you wish to continue? [y/N] ' ).lower ()
109
+ if accept_destructive_update [:1 ] == 'y' :
110
+ delete_flowlog (VpcId ,FlowLog ['FlowLogId' ],True ,client ,args ,region )
111
+ create_flowlog (VpcId ,bucket ,client ,args ,region )
112
+ else :
113
+ logger .info ("User declined replacement of flow log {}" .format (FlowLog ['FlowLogId' ]))
104
114
else :
105
- accept_destructive_update = input (f'Do you wish to continue? [y/N] ' ).lower ()
106
- if accept_destructive_update [:1 ] == 'y' :
107
- delete_flowlog (VpcId ,FlowLog ['FlowLogId' ],True ,client ,args ,region )
108
115
create_flowlog (VpcId ,bucket ,client ,args ,region )
109
- else :
110
- logger .info ("User declined replacement of flow log {}" .format (FlowLog ['FlowLogId' ]))
111
- else :
112
- create_flowlog (VpcId ,bucket ,client ,args ,region )
116
+ else :
117
+ create_flowlog (VpcId ,bucket ,client ,args ,region )
113
118
114
119
return
115
120
0 commit comments