简体   繁体   中英

Cloudformation Registry not creating log groups when submitting private resource type

I am developing a private resource type for AWS Cloudformation Registry . I have designed my model schema and developed my handler code, submitted it, and even successfully deployed a stack with my very own private resource type. Yay.

What i need to do now is inspect the logging thereof. As I had generated the scaffolding using the cfn init command, i merely added logging entries to the existing logger object.

eg

# Use this logger to forward log messages to CloudWatch Logs.
LOG = logging.getLogger(__name__)
TYPE_NAME = "Myself::Test::Resourceful"

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,
    )
    # TODO: put code here

    LOG.info('Creating....')

According to the literature ,

When you register a resource type using cfn submit, CloudFormation creates a CloudWatch log group for the resource type in your account. This enables you to access the logs for your resource to help you diagnose any faults. The log group is named according to the following pattern:

/my-resource-type-stack-ResourceHandler-string

Now, when you initiate stack operations for stacks that contain the resource type, CloudFormation delivers log events emitted by the resource type to this log group.

When submitting my resource type however (and even deploying it), a cannot see any LogGroup created in CloudWatch whatsoever. There is clearly something i am missing here.

Please help me understand how to find the logging for my private Cloudformation registry resource types.

Of course, i will be happy to provide any additional info needed. Thank you!

Got it.

Thanks to @maslick , all i had to do was explicitly set an appropriate logging level .

# Use this logger to forward log messages to CloudWatch Logs.

LOG = logging.getLogger(__name__)
LOG.setLevel(logging.INFO)            # <- this line was missing

When deploying stack, log groups appears. Yay.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM