Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added resources for cdn customdomain and cdn endpoint #8554

Merged
merged 5 commits into from May 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
60 changes: 60 additions & 0 deletions tools/c7n_azure/c7n_azure/resources/cdn_custom_domain.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
# Copyright The Cloud Custodian Authors.
# SPDX-License-Identifier: Apache-2.0

from c7n_azure.provider import resources
from c7n_azure.resources.arm import ChildArmResourceManager
from c7n_azure.utils import ResourceIdParser


@resources.register('cdn-custom-domain')
class CdnCustomDomain(ChildArmResourceManager):
"""CDN Endpoint Resource

:example:

Returns all CDN endpoints without Https provisioning

.. code-block:: yaml

policies:
- name: standard-verizon
resource: azure.cdn-custom-domain
filters:
- type: value
key: properties.customHttpsProvisioningState
op: ne
value: Enabled

"""

class resource_type(ChildArmResourceManager.resource_type):
doc_groups = ['Media']

service = 'azure.mgmt.cdn'
client = 'CdnManagementClient'
enum_spec = ('custom_domains', 'list_by_endpoint', None)
parent_manager_name = 'cdn-endpoint'
default_report_fields = (
'name',
'location',
'resourceGroup',
'properties.customDomainName',
'properties.customHttpsProvisioningState',
'properties.customHttpaProvisioningSubstate',
'properties.customDomainHttpsParameters',
'"c7n:parent-id"'
)
resource_type = 'Microsoft.Cdn/profiles/endpoints/customDomains'

@classmethod
def extra_args(cls, parent_resource):
endpoint_name = parent_resource['name']
resource_group_name = parent_resource['resourceGroup']
profile_id = parent_resource['c7n:parent-id']
profile_name = ResourceIdParser.get_resource_name(profile_id)

return {
'resource_group_name': resource_group_name,
'endpoint_name': endpoint_name,
'profile_name': profile_name
}
47 changes: 47 additions & 0 deletions tools/c7n_azure/c7n_azure/resources/cdn_endpoint.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# Copyright The Cloud Custodian Authors.
# SPDX-License-Identifier: Apache-2.0

from c7n_azure.provider import resources
from c7n_azure.resources.arm import ChildArmResourceManager

@resources.register('cdn-endpoint')
class CdnEndpoint(ChildArmResourceManager):
"""CDN Endpoint Resource

:example:

Returns all CDN endpoints with Standard_Verizon sku

.. code-block:: yaml

policies:
- name: standard-verizon
resource: azure.cdn-endpoint
filters:
- type: value
key: sku
op: in
value_type: normalize
value: standard_verizon

"""

class resource_type(ChildArmResourceManager.resource_type):
doc_groups = ['Media']

service = 'azure.mgmt.cdn'
client = 'CdnManagementClient'
enum_spec = ('endpoints', 'list_by_profile', None)
default_report_fields = (
'name',
'location',
'resourceGroup',
'"c7n:parent-id"'
)
resource_type = 'Microsoft.Cdn/profiles/endpoints'
parent_manager_name = 'cdnprofile'

@classmethod
def extra_args(cls, parent_resource):
return {'resource_group_name': parent_resource['resourceGroup'],
'profile_name': parent_resource['name']}
2 changes: 2 additions & 0 deletions tools/c7n_azure/c7n_azure/resources/resource_map.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
"azure.application-gateway": "c7n_azure.resources.app_gateway.ApplicationGateway",
"azure.armresource": "c7n_azure.resources.generic_arm_resource.GenericArmResource",
"azure.batch": "c7n_azure.resources.batch.Batch",
"azure.cdn-custom-domain": "c7n_azure.resources.cdn_custom_domain.CdnCustomDomain",
"azure.cdn-endpoint": "c7n_azure.resources.cdn_endpoint.CdnEndpoint",
"azure.cdnprofile": "c7n_azure.resources.cdn.CdnProfile",
"azure.cognitiveservice": "c7n_azure.resources.cognitive_service.CognitiveService",
"azure.container-group": "c7n_azure.resources.aci.ContainerGroup",
Expand Down