Skip to content

Commit

Permalink
[aws][fix] Handle wrong encoded user data gracefully (#1912)
Browse files Browse the repository at this point in the history
  • Loading branch information
aquamatthias committed Feb 14, 2024
1 parent f290cca commit d5760ec
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion plugins/aws/resoto_plugin_aws/resource/ec2.py
@@ -1,5 +1,6 @@
import base64
import logging
from contextlib import suppress
from datetime import datetime
from typing import ClassVar, Dict, Optional, List, Type, Any
import copy
Expand Down Expand Up @@ -1362,7 +1363,8 @@ def fetch_user_data(instance: AwsEc2Instance) -> None:
Attribute="userData",
)
) and (data := result.get("Value")):
instance.instance_user_data = base64.b64decode(data).decode("utf-8")
with suppress(Exception): # ignore userdata with wrong encoding
instance.instance_user_data = base64.b64decode(data).decode("utf-8")

for reservation in json:
for instance_in in reservation["Instances"]:
Expand Down

0 comments on commit d5760ec

Please sign in to comment.