forked from cloud-custodian/cloud-custodian
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
azure - app service environment resource (cloud-custodian#9820)
- Loading branch information
1 parent
4a6f80f
commit 5485b53
Showing
4 changed files
with
154 additions
and
0 deletions.
There are no files selected for viewing
36 changes: 36 additions & 0 deletions
36
tools/c7n_azure/c7n_azure/resources/app_service_environment.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
from c7n_azure.provider import resources | ||
from c7n_azure.resources.arm import ArmResourceManager | ||
|
||
|
||
@resources.register("app-service-environment") | ||
class AppServiceEnvironment(ArmResourceManager): | ||
"""App Service Environment | ||
:example: | ||
This policy will find all App Service Environment that are still not ready | ||
.. code-block:: yaml | ||
policies: | ||
- name: app-service-environment-not-ready | ||
resource: azure.app-service-environment | ||
filters: | ||
- type: value | ||
key: properties.provisioningState | ||
value: InProgress | ||
""" | ||
|
||
class resource_type(ArmResourceManager.resource_type): | ||
doc_groups = ["Compute", "Web"] | ||
service = "azure.mgmt.web" | ||
client = "WebSiteManagementClient" | ||
enum_spec = ("app_service_environments", "list", None) | ||
default_report_fields = ( | ||
"name", | ||
"location", | ||
"resourceGroup", | ||
"kind", | ||
"properties.dnsSuffix" | ||
) | ||
resource_type = "Microsoft.Web/hostingEnvironments" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
88 changes: 88 additions & 0 deletions
88
...azure/tests_azure/cassettes/AppServiceEnvironmentTest.test_find_ase_in_pending_state.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
{ | ||
"version": 1, | ||
"interactions": [ | ||
{ | ||
"request": { | ||
"method": "GET", | ||
"uri": "https://management.azure.com/subscriptions/ea42f556-5106-4743-99b0-c129bfa71a47/providers/Microsoft.Web/hostingEnvironments?api-version=2018-11-01", | ||
"body": null, | ||
"headers": {} | ||
}, | ||
"response": { | ||
"status": { | ||
"code": 200, | ||
"message": "OK" | ||
}, | ||
"headers": { | ||
"cache-control": [ | ||
"no-cache" | ||
], | ||
"etag": [ | ||
"\"1D56A6327B0767F\"" | ||
], | ||
"content-type": [ | ||
"application/json" | ||
], | ||
"date": [ | ||
"Fri, 13 Sep 2019 18:43:59 GMT" | ||
], | ||
"content-length": [ | ||
"3205" | ||
] | ||
}, | ||
"body": { | ||
"data": { | ||
"value": [ | ||
{ | ||
"id": "/subscriptions/ea42f556-5106-4743-99b0-c129bfa71a47/resourceGroups/test_ase/providers/Microsoft.Web/hostingEnvironments/example-ase", | ||
"name": "example-ase", | ||
"kind": "ASEV3", | ||
"location": "East US", | ||
"type": "Microsoft.Web/hostingEnvironments", | ||
"tags": { | ||
"ComplianceStatus": "Green", | ||
"CustodianRule": "ecc-azure-433-dep_app_latest_env" | ||
}, | ||
"properties": { | ||
"provisioningState": "InProgress", | ||
"status": "Preparing", | ||
"virtualNetwork": { | ||
"id": "/subscriptions/ea42f556-5106-4743-99b0-c129bfa71a47/resourceGroups/test_ase/providers/Microsoft.Network/virtualNetworks/this-green-vnet/subnets/this-green-subnet", | ||
"name": "this-green-subnet", | ||
"type": "Microsoft.Network/virtualNetworks/subnets", | ||
"subnet": "" | ||
}, | ||
"internalLoadBalancingMode": "Web, Publishing", | ||
"multiSize": "Standard_D2d_v4", | ||
"ipsslAddressCount": 0, | ||
"dnsSuffix": "example-ase.appserviceenvironment.net", | ||
"maximumNumberOfMachines": 250, | ||
"suspended": false, | ||
"clusterSettings": [ | ||
{ | ||
"name": "DisableTls1.0", | ||
"value": "1" | ||
}, | ||
{ | ||
"name": "InternalEncryption", | ||
"value": "true" | ||
}, | ||
{ | ||
"name": "FrontEndSSLCipherSuiteOrder", | ||
"value": "TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384,TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256" | ||
} | ||
], | ||
"hasLinuxWorkers": true, | ||
"dedicatedHostCount": 0 | ||
}, | ||
"resourceGroup": "test_ase" | ||
} | ||
], | ||
"nextLink": null, | ||
"id": null | ||
} | ||
} | ||
} | ||
} | ||
] | ||
} |
29 changes: 29 additions & 0 deletions
29
tools/c7n_azure/tests_azure/tests_resources/test_app_service_environment.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# Copyright The Cloud Custodian Authors. | ||
# SPDX-License-Identifier: Apache-2.0 | ||
from ..azure_common import BaseTest | ||
|
||
|
||
class AppServiceEnvironmentTest(BaseTest): | ||
|
||
def test_validate_ase_schema(self): | ||
with self.sign_out_patch(): | ||
p = self.load_policy({ | ||
"name": "test-azure-ase", | ||
"resource": "azure.app-service-environment" | ||
}, validate=True) | ||
|
||
self.assertTrue(p) | ||
|
||
def test_find_ase_in_pending_state(self): | ||
p = self.load_policy({ | ||
"name": "test-azure-ase", | ||
"resource": "azure.app-service-environment", | ||
"filters": [ | ||
{"type": "value", | ||
"key": "properties.provisioningState", | ||
"value": "InProgress"} | ||
], | ||
}) | ||
resources = p.run() | ||
self.assertEqual(len(resources), 1) | ||
self.assertEqual(resources[0]["name"], "example-ase") |