Exemple #1
0
def update_physical_resource_id(resource):
    phys_res_id = getattr(resource, 'physical_resource_id', None)
    if not phys_res_id:
        if isinstance(resource, lambda_models.LambdaFunction):
            func_arn = aws_stack.lambda_function_arn(resource.function_name)
            resource.function_arn = resource.physical_resource_id = func_arn

        elif isinstance(resource, sfn_models.StateMachine):
            sm_arn = aws_stack.state_machine_arn(resource.name)
            resource.physical_resource_id = sm_arn

        elif isinstance(resource, service_models.StepFunctionsActivity):
            act_arn = aws_stack.stepfunctions_activity_arn(resource.params.get('Name'))
            resource.physical_resource_id = act_arn

        elif isinstance(resource, kinesis_models.Stream):
            resource.physical_resource_id = resource.stream_name

        elif isinstance(resource, service_models.LogsLogGroup):
            resource.physical_resource_id = resource.params.get('LogGroupName')

        elif isinstance(resource, service_models.FirehoseDeliveryStream):
            resource.physical_resource_id = resource.params.get('DeliveryStreamName')

        elif isinstance(resource, service_models.SecretsManagerSecret):
            resource.physical_resource_id = resource.params.get('Name')

        elif isinstance(resource, service_models.EventsRule):
            resource.physical_resource_id = resource.params.get('Name')

        elif isinstance(resource, service_models.ElasticsearchDomain):
            resource.physical_resource_id = resource.params.get('DomainName')

        else:
            LOG.warning('Unable to determine physical_resource_id for resource %s' % type(resource))
def update_physical_resource_id(resource):
    phys_res_id = getattr(resource, "physical_resource_id", None)
    if phys_res_id:
        return

    if isinstance(resource, lambda_models.LambdaFunction):
        func_arn = aws_stack.lambda_function_arn(resource.function_name)
        resource.function_arn = resource.physical_resource_id = func_arn

    elif isinstance(resource, service_models.StepFunctionsActivity):
        act_arn = aws_stack.stepfunctions_activity_arn(
            resource.params.get("Name"))
        resource.physical_resource_id = act_arn

    elif isinstance(resource, kinesis_models.Stream):
        resource.physical_resource_id = resource.stream_name

    elif isinstance(resource, logs.LogsLogGroup):
        resource.physical_resource_id = resource.params.get("LogGroupName")

    elif isinstance(resource, kinesisfirehose.FirehoseDeliveryStream):
        resource.physical_resource_id = resource.params.get(
            "DeliveryStreamName")

    elif isinstance(resource, secretsmanager.SecretsManagerSecret):
        resource.physical_resource_id = resource.params.get("Name")

    elif isinstance(resource, events.EventsRule):
        resource.physical_resource_id = resource.params.get("Name")

    elif isinstance(resource, elasticsearch.ElasticsearchDomain):
        resource.physical_resource_id = resource.params.get("DomainName")

    elif isinstance(resource, secretsmanager.SecretsManagerSecret):
        secret = secretsmanager.SecretsManagerSecret.fetch_details(
            resource.props["Name"])
        if secret:
            resource.props["ARN"] = resource.physical_resource_id = secret[
                "ARN"]

    elif isinstance(resource, dynamodb_models.Table):
        resource.physical_resource_id = resource.name

    elif isinstance(resource, dynamodb2_models.Table):
        resource.physical_resource_id = resource.name

    elif isinstance(resource, apigw_models.RestAPI):
        resource.physical_resource_id = resource.id

    elif isinstance(resource, apigw_models.Stage):
        resource.physical_resource_id = resource.get("stageName")

    elif isinstance(resource, apigw_models.Resource):
        resource.physical_resource_id = resource.id

    else:
        LOG.warning(
            "Unable to determine physical_resource_id for resource %s" %
            type(resource))
def update_physical_resource_id(resource):
    phys_res_id = getattr(resource, 'physical_resource_id', None)
    if not phys_res_id:
        if isinstance(resource, lambda_models.LambdaFunction):
            func_arn = aws_stack.lambda_function_arn(resource.function_name)
            resource.function_arn = resource.physical_resource_id = func_arn
        elif isinstance(resource, sfn_models.StateMachine):
            sm_arn = aws_stack.state_machine_arn(resource.name)
            resource.physical_resource_id = sm_arn
        elif isinstance(resource, service_models.StepFunctionsActivity):
            act_arn = aws_stack.stepfunctions_activity_arn(resource.params.get('Name'))
            resource.physical_resource_id = act_arn
        else:
            LOG.warning('Unable to determine physical_resource_id for resource %s' % type(resource))