@@ -71,6 +71,7 @@ def get_compute_launch_template_ids(lt_config_file_name):
7171 """
7272 lt_config = None
7373 try :
74+ logger .info ("Getting LaunchTemplate ID and versions from %s" , lt_config_file_name )
7475 with open (lt_config_file_name , "r" , encoding = "utf-8" ) as file :
7576 lt_config = json .loads (file .read ())
7677 except Exception as err :
@@ -117,6 +118,7 @@ def get_user_data(lt_id, lt_version, region_name):
117118 proxy_config = parse_proxy_config ()
118119
119120 ec2_client = boto3 .client ("ec2" , region_name = region_name , config = proxy_config )
121+ logger .info ("Running EC2 DescribeLaunchTemplateVersions API for %s version %s" , lt_id , lt_version )
120122 response = ec2_client .describe_launch_template_versions (
121123 LaunchTemplateId = lt_id ,
122124 Versions = [
@@ -139,6 +141,7 @@ def get_write_directives_section(user_data):
139141 write_directives_section = None
140142 try :
141143 data = message_from_string (user_data )
144+ logger .info ("Parsing UserData to get write_files section" )
142145 for cloud_config_section in data .walk ():
143146 if cloud_config_section .get_content_type () == "text/cloud-config" :
144147 write_directives_section = yaml .safe_load (cloud_config_section ._payload ).get ("write_files" )
@@ -160,6 +163,7 @@ def write_dna_files(write_files_section, shared_storage_loc):
160163 for data in write_files_section :
161164 if data ["path" ] in ["/tmp/dna.json" ]: # nosec B108
162165 with open (file_path , "w" , encoding = "utf-8" ) as file :
166+ logger .info ("Writing %s" , file_path )
163167 file .write (json .dumps (json .loads (data ["content" ]), indent = 4 ))
164168 except Exception as err :
165169 if hasattr (err , "message" ):
@@ -190,6 +194,7 @@ def cleanup(directory_loc):
190194 f_path = os .path .join (directory_loc , f )
191195 try :
192196 if os .path .isfile (f_path ):
197+ logger .info ("Cleaning up %s" , f_path )
193198 os .remove (f_path )
194199 except Exception as err :
195200 logger .warning ("Unable to delete %s due to %s" , f_path , err )
@@ -238,6 +243,8 @@ def main():
238243 )
239244 raise SystemExit (0 )
240245
246+ logger .info ("All dna.json files have been shared!" )
247+
241248
242249if __name__ == "__main__" :
243250 main ()
0 commit comments