def get_firewall(context, project_id, network):
    """ Generate a firewall rule for the healthcheck. """

    # pylint: disable=line-too-long
    # See https://cloud.google.com/compute/docs/load-balancing/health-checks#health_check_source_ips_and_firewall_rules.
    name = context.env['name'] + '-healthcheck-firewall'
    resource = {
        'name': name,
        'type': 'firewall.py',
        'properties':
            {
                'project': project_id,
                'networkName': network,
                'rules':
                    [
                        {
                            'name': name,
                            'allowed': [
                                {
                                    'IPProtocol': 'tcp',
                                    'ports': ['80'],
                                }
                            ],
                            'targetTags': [context.properties['natGatewayTag']],
                            'description':
                                'rule for allowing all health check traffic',
                            'sourceRanges': ['130.211.0.0/22',
                                             '35.191.0.0/16']
                        }
                    ]
            }
    }

    return resource