HandlerErrorCode, OperationStatus, ProgressEvent, Resource, SessionProxy, exceptions, ) import mypy_boto3_organizations as Organizations from .models import ResourceHandlerRequest, ResourceModel from .provisioner import OrganizationsServiceControlPolicyProvisioner LOG = logging.getLogger(__name__) resource = Resource(OrganizationsServiceControlPolicyProvisioner.TYPE, ResourceModel) test_entrypoint = resource.test_entrypoint @resource.handler(Action.CREATE) def create_handler( session: Optional[SessionProxy], request: ResourceHandlerRequest, callback_context: MutableMapping[str, Any], ) -> ProgressEvent: LOG.info(request) if not session: raise exceptions.InternalFailure(f"boto3 session unavailable")
ProgressEvent, Resource, SessionProxy, exceptions, ) from . import handler_workers from .models import ResourceHandlerRequest, ResourceModel # Use this logger to forward log messages to CloudWatch Logs. LOG = logging.getLogger(__name__) LOG.setLevel(logging.DEBUG) TYPE_NAME = "AWS::FraudDetector::Outcome" resource = Resource(TYPE_NAME, ResourceModel) test_entrypoint = resource.test_entrypoint @resource.handler(Action.CREATE) def create_handler( session: Optional[SessionProxy], request: ResourceHandlerRequest, callback_context: MutableMapping[str, Any], ) -> ProgressEvent: model = request.desiredResourceState progress: ProgressEvent = ProgressEvent( status=OperationStatus.IN_PROGRESS, resourceModel=model, ) LOG.info(f"calling create with the following request: {request}")
SessionProxy, ) from datadog_api_client.v1 import ApiException from datadog_api_client.v1.api.dashboards_api import DashboardsApi from datadog_cloudformation_common.api_clients import v1_client from datadog_cloudformation_common.utils import http_to_handler_error_code from .models import ResourceHandlerRequest, ResourceModel, TypeConfigurationModel from .version import __version__ # Use this logger to forward log messages to CloudWatch Logs. LOG = logging.getLogger(__name__) TYPE_NAME = "Datadog::Dashboards::Dashboard" TELEMETRY_TYPE_NAME = "dashboards-dashboard" resource = Resource(TYPE_NAME, ResourceModel, TypeConfigurationModel) test_entrypoint = resource.test_entrypoint @resource.handler(Action.CREATE) def create_handler( session: Optional[SessionProxy], request: ResourceHandlerRequest, callback_context: MutableMapping[str, Any], ) -> ProgressEvent: LOG.info("Starting %s Create Handler", TYPE_NAME) model = request.desiredResourceState type_configuration = request.typeConfiguration try: json_payload = json.loads(model.DashboardDefinition)
OperationStatus, ProgressEvent, Resource, SessionProxy, exceptions, ) import mypy_boto3_organizations as Organizations from .models import BaseModel, ResourceHandlerRequest, ResourceModel from .provisioner import OrganizationsOrganizationProvisioner # Use this logger to forward log messages to CloudWatch Logs. LOG = logging.getLogger(__name__) resource = Resource(OrganizationsOrganizationProvisioner.TYPE, ResourceModel) test_entrypoint = resource.test_entrypoint @resource.handler(Action.CREATE) def create_handler( session: Optional[SessionProxy], request: ResourceHandlerRequest, callback_context: MutableMapping[str, Any], ) -> ProgressEvent: LOG.info(request) if not session: raise exceptions.InternalFailure(f"boto3 session unavailable")
Action, HandlerErrorCode, OperationStatus, ProgressEvent, Resource, SessionProxy, exceptions, ) from .models import ResourceHandlerRequest, ResourceModel from .provisioner import OrganizationsAccountProvisioner # Use this logger to forward log messages to CloudWatch Logs. LOG = logging.getLogger(__name__) resource = Resource(OrganizationsAccountProvisioner.TYPE, ResourceModel) test_entrypoint = resource.test_entrypoint @resource.handler(Action.CREATE) def create_handler( session: Optional[SessionProxy], request: ResourceHandlerRequest, callback_context: MutableMapping[str, Any], ) -> ProgressEvent: LOG.info(request) if not session: raise exceptions.InternalFailure(f"boto3 session unavailable")
import traceback from typing import Any, MutableMapping, Optional import botocore.exceptions from cloudformation_cli_python_lib import ( # pylint: disable=W0611,E0401 Action, HandlerErrorCode, OperationStatus, ProgressEvent, Resource, SessionProxy, exceptions, ) from .models import ResourceHandlerRequest, ResourceModel # Use this logger to forward log messages to CloudWatch Logs. LOG = logging.getLogger(__name__) TYPE_NAME = "SLF::APIGateway::Private" resource = Resource(TYPE_NAME, ResourceModel) # pylint: disable=C0103 test_entrypoint = resource.test_entrypoint # pylint: disable=C0103 class APIGateway(): """Wrapper for calls to our API Gateway""" def __init__(self, session): self.client = session.client('apigateway') self.apis = [] paginator = self.client.get_paginator('get_rest_apis') page_iterator = paginator.paginate() for page in page_iterator: for item in page['items']: self.apis.append(item['name']) logging.warning('APIGateway found these APIs: %s', str(self.apis))
HandlerErrorCode, OperationStatus, ProgressEvent, Resource, SessionProxy, exceptions, ) from .models import ResourceHandlerRequest, ResourceModel # Use this logger to forward log messages to CloudWatch Logs. LOG = logging.getLogger(__name__) LOG.setLevel("INFO") TYPE_NAME = "JB::EMR::StepConcurrencyLevel" resource = Resource(TYPE_NAME, ResourceModel) # pylint: disable=invalid-name test_entrypoint = resource.test_entrypoint # pylint: disable=invalid-name def get_cluster_info(session: Optional[SessionProxy], cluster_id: str) -> dict: """This function will gather all information from a describe cluster call to the given cluster ID Attributes: session (Optional[SessionProxy]): The session proxy for connecting to the needed AWS API client cluster_id (str): The unique ID of the cluster to get details from Returns: dict: A dictionary of the cluster attributes """