Skip to content

Commit

Permalink
EC2CommonState: guard against a None _conn
Browse files Browse the repository at this point in the history
  • Loading branch information
grahamc committed Sep 4, 2020
1 parent 492d9ae commit e8f0dd7
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion nixops_aws/resources/ec2_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class EC2CommonState:
_client: Optional["mypy_boto3_ec2.EC2Client"]

# Not always available
_conn: EC2Connection
_conn: Optional[EC2Connection]
access_key_id: Optional[str]

COMMON_EC2_RESERVED = ["accessKeyId", "ec2.tags"]
Expand Down Expand Up @@ -60,6 +60,10 @@ def update_tags_using(self, updater, user_tags={}, check=False):
def update_tags(self, id, user_tags={}, check=False):
def updater(tags):
# FIXME: handle removing tags.
if self._conn is None:
raise Exception(
"bug: self._conn is None"
)
self._retry(lambda: self._conn.create_tags([id], tags))

self.update_tags_using(updater, user_tags=user_tags, check=check)
Expand Down

0 comments on commit e8f0dd7

Please sign in to comment.