public async Task <bool> UpdateTagsAsync(EC2Helper ec2, string instanceId, Dictionary <string, string> tags, CancellationToken cancellationToken = default(CancellationToken)) { var instance = await ec2.GetInstanceById(instanceId); var deleteTags = await ec2.DeleteAllInstanceTags(instanceId); if (tags.IsNullOrEmpty()) { instance = await ec2.GetInstanceById(instanceId); return(instance.Tags.IsNullOrEmpty()); } var createTags = await ec2.CreateTagsAsync( resourceIds : new List <string>() { instanceId }, tags : tags); instance = await ec2.GetInstanceById(instanceId); return(instance.Tags.ToDictionary(x => x.Key, y => y.Value).CollectionEquals(tags, trim: true)); }