aws-cloudformation / cloudformation-cli

The CloudFormation Provider Development Toolkit allows you to author your own resource providers and modules that can be used by CloudFormation.
Apache License 2.0
318 stars 161 forks source link

ZERO support for building cloudformation resources and incomplete documentation #837

Open danieljarrett74 opened 2 years ago

danieljarrett74 commented 2 years ago

I am building my project with cfn submit --set-default . It deploys it successfully, but when i go to create a stack using that new resource i get the following error:

Lambda function handler threw an uncaught exception: Unable to import module 'my_resource_name.handlers': No module named 'my_resource_name'

Nothing else, nothing in the logs. Just a bit of a mystery.

ammokhov commented 2 years ago

that seems to be more of a python plugin specific error. From the first sight it looks that handlers module did not get added to the zip artifact. Would you mind list the steps that you did before running cfn submit command? Are you using plugin directly (do you use docker to create an artifact) or from the pypi (if so then what version)?

danieljarrett74 commented 2 years ago

Thanks for the response @ammokhov , apologies for the alarmist title, I got a bit frustrated that I hadn't received a response on my last 3 issues.

To answer your questions:

I'm using docker to create the artifact and python version 3.7

I've checked the zip artifact that gets uploaded to the s3://cloudformationmanageduploadinfrast-artifactbucket

Here's what's in it.

├── ResourceProvider.zip
├── schema.json
└── src
    └── my_notifications_api
        ├── NotificationsApiFunction.zip
        ├── __init__.py
        ├── config.ini
        ├── create_handler.py
        ├── delete_handler.py
        ├── handlers.py
        ├── models.py
        └── update_handler.py

The ResourceProvider.zip contains everything in the src folder as well as all the dependant modules.

The error message I get when I try to deploy a stack is:

Lambda function handler threw an uncaught exception: Unable to import module 'my_notifications_api.handlers': No module named 'my_notifications_api'

Interestingly I was able to run the CREATE and DELETE commands locally successfully. Using:

sam local invoke TestEntrypoint --event example_inputs/create.json  
sam local invoke TestEntrypoint --event example_inputs/delete.json  

After I successfully created and deleted my resources locally I submitted using:

cfn submit --set-default
danieljarrett74 commented 2 years ago

@ammokhov Surely I could get a response within 11 days.