Skip to content

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

Description

@kallu

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

Activity

  1. kallu commented on Nov 1, 2020

    @kallu
    Author

    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

  2. ammokhov commented on Nov 2, 2020

    @ammokhov
    Contributor

    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

  3. kallu commented on Nov 2, 2020

    @kallu
    Author

    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?

  4. ammokhov commented on Nov 3, 2020

    @ammokhov
    Contributor

    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

  5. ammokhov commented on Nov 5, 2020

    @ammokhov
    Contributor

    @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

  6. maintux commented on Nov 5, 2020

    @maintux

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

  7. ammokhov commented on Nov 5, 2020

    @ammokhov
    Contributor

    @maintux thanks for the reply. closing the issue

  8. kallu commented on Nov 7, 2020

    @kallu
    Author

    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

  9. ammokhov commented on Nov 7, 2020

    @ammokhov
    Contributor

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions