Modify attributes of a block by its containing region
When you need to modify attributes for a block per its assigned region, here's how to handle this in a pre-process function. An example use case is to add a Bootstrap 'col-' class to a block only if it's located in a footer region. In Drupal 8, blocks can be re-used for multiple regions, so you may want to style the block according to a particular region, e.g. sidebar_second, or in this example, the footer_first region.
This can also be accomplished in a twig template, where the region name can be passed as a twig variable, but here I'll insert the class into the attributes array in