0

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.

e.g.

# 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!

1 Answer 1

0

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.