def update_vpc_tags(module, vpc, vpc_id, tags, name): tags.update({'Name': name}) try: vpc.create_tags(vpc_id, tags) updated_tags = dict( (t.name, t.value) for t in vpc.get_all_tags(filters={'resource-id': vpc_id})) except Exception, e: e_msg = boto_exception(e) module.fail_json(msg=e_msg)
def update_vpc_tags(vpc, module, vpc_obj, tags, name): if tags is None: tags = dict() tags.update({'Name': name}) try: current_tags = dict((t.name, t.value) for t in vpc.get_all_tags(filters={'resource-id': vpc_obj.id})) if cmp(tags, current_tags): vpc.create_tags(vpc_obj.id, tags) return True else: return False except Exception, e: e_msg=boto_exception(e) module.fail_json(msg=e_msg)
def update_vpc_tags(vpc, module, vpc_obj, tags, name): if tags is None: tags = dict() tags.update({'Name': name}) try: current_tags = dict((t.name, t.value) for t in vpc.get_all_tags(filters={'resource-id': vpc_obj.id})) if cmp(tags, current_tags): vpc.create_tags(vpc_obj.id, tags) return True else: return False except Exception as e: e_msg=boto_exception(e) module.fail_json(msg=e_msg)
# Note: Boto currently doesn't currently provide an interface to ec2-describe-vpc-attribute # which is needed in order to detect the current status of DNS options. For now we just update # the attribute each time and is not used as a changed-factor. try: vpc.modify_vpc_attribute(vpc_id, enable_dns_support=dns_support) vpc.modify_vpc_attribute(vpc_id, enable_dns_hostnames=dns_hostnames) except Exception, e: e_msg = boto_exception(e) module.fail_json(msg=e_msg) if tags: try: current_tags = dict( (t.name, t.value) for t in vpc.get_all_tags(filters={'resource-id': vpc_id})) if not set(tags.items()).issubset(set(current_tags.items())): update_tags = True except Exception, e: e_msg = boto_exception(e) module.fail_json(msg=e_msg) return update_dhcp, update_tags def update_vpc_tags(module, vpc, vpc_id, tags, name): tags.update({'Name': name}) try: vpc.create_tags(vpc_id, tags) updated_tags = dict( (t.name, t.value)