in gcpdiag/lint/lb/bp_2023_001_cloudcdn_for_lb_backend_services.py [0:0]
def run_rule(context: models.Context, report: lint.LintReportRuleInterface):
bs_list = lb.get_backend_services(context.project_id)
# return if there are no BackendServices found in the project
if not bs_list:
report.add_skipped(None, 'no backend services found')
return
for bs in bs_list:
# fail for backend services for Global HTTP(S) LB which have CloudCDN enabled
if (bs.load_balancing_scheme == EXTERNAL_MANAGED and not bs.region and
not bs.is_enable_cdn and not bs.region):
report.add_failed(bs)
# pass for backend services for Global HTTP(S) LB which have CloudCDN enabled
elif (bs.load_balancing_scheme == EXTERNAL_MANAGED and not bs.region and
bs.is_enable_cdn and not bs.region):
report.add_ok(bs)
else:
# skip for non-global HTTP(S) LB backend services
report.add_skipped(bs, 'Non Global HTTP(S) Load balancer backend service')