Skip to content

Commit

Permalink
releng - 0.9.18.0 - prep for release (cloud-custodian#7602)
Browse files Browse the repository at this point in the history
  • Loading branch information
darrendao authored Aug 10, 2022
1 parent 0608738 commit 34fed8a
Show file tree
Hide file tree
Showing 46 changed files with 1,259 additions and 2,194 deletions.
4 changes: 2 additions & 2 deletions c7n/resources/batch.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class resource_type(TypeInfo):
arn_type = "compute-environment"
enum_spec = (
'describe_compute_environments', 'computeEnvironments', None)
cfn_type = 'AWS::Batch::ComputeEnvironment'
cfn_type = config_type = 'AWS::Batch::ComputeEnvironment'


@ComputeEnvironment.filter_registry.register('security-group')
Expand Down Expand Up @@ -180,4 +180,4 @@ class resource_type(TypeInfo):
arn_type = 'job-queue'
enum_spec = (
'describe_job_queues', 'jobQueues', None)
cfn_type = 'AWS::Batch::JobQueue'
cfn_type = config_type = 'AWS::Batch::JobQueue'
2 changes: 2 additions & 0 deletions c7n/resources/cloudsearch.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,9 @@ class EnableHttps(Action):
"""Enable HTTPs to cloudsearch
:example:
.. code-block:: yaml
policies:
- name: enable-https
resource: cloudsearch
Expand Down
30 changes: 19 additions & 11 deletions c7n/resources/kafka.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,25 @@
from c7n.filters.vpc import SecurityGroupFilter, SubnetFilter
from c7n.manager import resources
from c7n.filters.kms import KmsRelatedFilter
from c7n.query import QueryResourceManager, TypeInfo
from c7n.query import QueryResourceManager, TypeInfo, DescribeSource, ConfigSource
from c7n.utils import local_session, type_schema

from .aws import shape_validate


class DescribeKafka(DescribeSource):

def augment(self, resources):
for r in resources:
if 'Tags' not in r:
continue
tags = []
for k, v in r['Tags'].items():
tags.append({'Key': k, 'Value': v})
r['Tags'] = tags
return resources


@resources.register('kafka')
class Kafka(QueryResourceManager):

Expand All @@ -22,17 +35,12 @@ class resource_type(TypeInfo):
filter_name = 'ClusterNameFilter'
filter_type = 'scalar'
universal_taggable = object()
cfn_type = 'AWS::MSK::Cluster'
cfn_type = config_type = 'AWS::MSK::Cluster'

def augment(self, resources):
for r in resources:
if 'Tags' not in r:
continue
tags = []
for k, v in r['Tags'].items():
tags.append({'Key': k, 'Value': v})
r['Tags'] = tags
return resources
source_mapping = {
'describe': DescribeKafka,
'config': ConfigSource
}


@Kafka.filter_registry.register('security-group')
Expand Down
36 changes: 22 additions & 14 deletions c7n/resources/sagemaker.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from c7n.actions import BaseAction
from c7n.exceptions import PolicyValidationError
from c7n.manager import resources
from c7n.query import QueryResourceManager, TypeInfo
from c7n.query import QueryResourceManager, TypeInfo, DescribeSource, ConfigSource
from c7n.utils import local_session, type_schema
from c7n.tags import RemoveTag, Tag, TagActionFilter, TagDelayedAction
from c7n.filters.vpc import SubnetFilter, SecurityGroupFilter
Expand Down Expand Up @@ -259,6 +259,21 @@ def _augment(e):
SagemakerEndpointConfig.filter_registry.register('marked-for-op', TagActionFilter)


class DescribeModel(DescribeSource):

def augment(self, resources):
client = local_session(self.manager.session_factory).client('sagemaker')

def _augment(r):
tags = self.manager.retry(client.list_tags,
ResourceArn=r['ModelArn'])['Tags']
r.setdefault('Tags', []).extend(tags)
return r

resources = super(DescribeModel, self).augment(resources)
return list(map(_augment, resources))


@resources.register('sagemaker-model')
class Model(QueryResourceManager):

Expand All @@ -271,21 +286,14 @@ class resource_type(TypeInfo):
arn = id = 'ModelArn'
name = 'ModelName'
date = 'CreationTime'
cfn_type = 'AWS::SageMaker::Model'
cfn_type = config_type = 'AWS::SageMaker::Model'

permissions = ('sagemaker:ListTags',)

def augment(self, resources):
client = local_session(self.session_factory).client('sagemaker')

def _augment(r):
tags = self.retry(client.list_tags,
ResourceArn=r['ModelArn'])['Tags']
r.setdefault('Tags', []).extend(tags)
return r
source_mapping = {
'describe': DescribeModel,
'config': ConfigSource
}

resources = super(Model, self).augment(resources)
return list(map(_augment, resources))
permissions = ('sagemaker:ListTags',)


Model.filter_registry.register('marked-for-op', TagActionFilter)
Expand Down
18 changes: 13 additions & 5 deletions c7n/resources/sfn.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,18 @@

from c7n.actions import Action
from c7n.manager import resources
from c7n.query import QueryResourceManager, TypeInfo
from c7n.query import QueryResourceManager, TypeInfo, DescribeSource, ConfigSource
from c7n.tags import Tag, RemoveTag, universal_augment
from c7n.utils import type_schema, local_session, dumps, chunks


class DescribeStepFunction(DescribeSource):

def augment(self, resources):
resources = super().augment(resources)
return universal_augment(self.manager, resources)


@resources.register('step-machine')
class StepFunction(QueryResourceManager):
"""AWS Step Functions State Machine"""
Expand All @@ -19,16 +26,17 @@ class resource_type(TypeInfo):
arn = id = 'stateMachineArn'
arn_service = 'states'
arn_type = 'stateMachine'
cfn_type = 'AWS::StepFunctions::StateMachine'
cfn_type = config_type = 'AWS::StepFunctions::StateMachine'
name = 'name'
date = 'creationDate'
detail_spec = (
"describe_state_machine", "stateMachineArn",
'stateMachineArn', None)

def augment(self, resources):
resources = super().augment(resources)
return universal_augment(self, resources)
source_mapping = {
'describe': DescribeStepFunction,
'config': ConfigSource
}


class InvokeStepFunction(Action):
Expand Down
16 changes: 12 additions & 4 deletions c7n/resources/workspaces.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from c7n.filters import ValueFilter
from c7n.filters.kms import KmsRelatedFilter
from c7n.manager import resources
from c7n.query import QueryResourceManager, TypeInfo
from c7n.query import QueryResourceManager, TypeInfo, DescribeSource, ConfigSource
from c7n.tags import universal_augment
from c7n.exceptions import PolicyValidationError, PolicyExecutionError
from c7n.utils import get_retry, local_session, type_schema, chunks
Expand All @@ -17,6 +17,12 @@
import c7n.filters.vpc as net_filters


class DescribeWorkspace(DescribeSource):

def augment(self, resources):
return universal_augment(self.manager, resources)


@resources.register('workspaces')
class Workspace(QueryResourceManager):

Expand All @@ -26,10 +32,12 @@ class resource_type(TypeInfo):
arn_type = 'workspace'
name = id = dimension = 'WorkspaceId'
universal_taggable = True
cfn_type = 'AWS::WorkSpaces::Workspace'
cfn_type = config_type = 'AWS::WorkSpaces::Workspace'

def augment(self, resources):
return universal_augment(self, resources)
source_mapping = {
'describe': DescribeWorkspace,
'config': ConfigSource
}


@Workspace.filter_registry.register('connection-status')
Expand Down
Loading

0 comments on commit 34fed8a

Please sign in to comment.