aws-cloudformation/cloudformation-cli-python-plugin

Create of custom resource fails with "__init__() got an unexpected keyword argument 'snapshotRequested' (TypeError)"

kallu opened this issue ยท 9 comments

kallu commented

Creating a custom resource type fails with the error __init__() got an unexpected keyword argument 'snapshotRequested' (TypeError)

Here is how my python versions look and how the custom resource type is created.

% python -V
Python 3.6.12

% pip list | grep cloudformation
cloudformation-cli               0.1.12
cloudformation-cli-go-plugin     2.0.2
cloudformation-cli-java-plugin   2.0.2
cloudformation-cli-python-lib    2.1.2
cloudformation-cli-python-plugin 2.1.1

Then deploying a custom resource as cfn init configures it

% cfn init 
Initializing new project
What's the name of your resource type?
(Organization::Service::Resource)
>> MyOrg::Dataprovider::Variable
Select a language for code generation:
[1] go
[2] java
[3] python36
[4] python37
(enter an integer): 
>> 3
Use docker for platform-independent packaging (Y/n)?
This is highly recommended unless you are experienced 
with cross-platform Python packaging.
>> Y
Initialized a new project in /Users/.../cfn-resource

% cfn generate
Generated files for MyOrg::Dataprovider::Variable

% cfn submit --set-default
Starting Docker build. This may take several minutes if the image 'lambci/lambda:build-python3.6' needs to be pulled first.
Successfully submitted type. Waiting for registration with token '7c37bc66-65a7-41db-b4c6-444c9758c3ce' to complete.
Registration complete.
{'ProgressStatus': 'COMPLETE', 'Description': 'Deployment is currently in DEPLOY_STAGE of status COMPLETED; ', 'TypeArn': 'arn:aws:cloudformation:eu-central-1:112233445566:type/resource/MyOrg-Dataprovider-Variable', 'TypeVersionArn': 'arn:aws:cloudformation:eu-central-1:112233445566:type/resource/MyOrg-Dataprovider-Variable/00000006', 'ResponseMetadata': {'RequestId': '1171feb8-fc07-421b-ac6d-ed8ee361d15c', 'HTTPStatusCode': 200, 'HTTPHeaders': {'x-amzn-requestid': '1171feb8-fc07-421b-ac6d-ed8ee361d15c', 'content-type': 'text/xml', 'content-length': '707', 'date': 'Sun, 01 Nov 2020 13:33:04 GMT'}, 'RetryAttempts': 0}}
Set default version to 'arn:aws:cloudformation:eu-central-1:112233445566:type/resource/MyOrg-Dataprovider-Variable/00000006

So far all worked. but when trying to use the resource type in template

AWSTemplateFormatVersion: 2010-09-09
Description: Sample template for MyOrg::Dataprovider::Variable usage
  
Resources:

  SampleVariable:
    Type: MyOrg::Dataprovider::Variable
    Properties:
      Title: "Hello12345678901234567890"
      TestCode: "NOT_STARTED"

Outputs:

  Variable:
    Description: Variable ID
    Value: !Ref SampleVariable

Create of SampleVariable fails with the error

__init__() got an unexpected keyword argument 'snapshotRequested' (TypeError)

Did I forget something?
Am I missing something from my requirements.txt ? Now it has only

cloudformation-cli-python-lib==2.1.2

kallu commented

There was a recent update for cfn java plugin, that looks like something that could be related to this issue?
aws-cloudformation/cloudformation-cli-java-plugin#316

this should be resolved by #127

snapshotRequested translates if resource level attribute deletion policy has been set to Snapshot - https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-attribute-deletionpolicy.html

kallu commented

Thanks, #127 looks good, but until it is published it is not possible to build new resource types with python. Do think the fixed release could be out soon?

Thanks, #127 looks good, but until it is published it is not possible to build new resource types with python. Do think the fixed release could be out soon?

Barring any late regression test failures, we plan to release it tomorrow (best case) or a few days after (worst case). But the problem/bug has been fixed

@kallu we recently released 2.1.3 version available at https://pypi.org/project/cloudformation-cli-python-lib/2.1.3/

please, confirm that issues is resolved

Hi, I had the same error. With the new version, all worked fine. Thanks

@maintux thanks for the reply. closing the issue

kallu commented

Sorry for the late reply, but cloudformation-cli-python-lib 2.1.3 fixes the issue for me as well.
One thing to note is cfn init is still generating requirements.txt with cloudformation-cli-python-lib==2.1.1

@kallu we recently released plugin library but not the codegen package. We should release it early next week