aws-cloudformation / cloudformation-cli-typescript-plugin

The CloudFormation Provider Development Toolkit Node.js Plugin allows you to autogenerate TypeScript code based on an input schema.
Apache License 2.0
45 stars 15 forks source link

cfn generate not creating models. #103

Open maclema opened 1 year ago

maclema commented 1 year ago

Typescript resource models are not being generated by cfn generate. A similar workflow using java generates the S3 and BucketPolicy models, but nothing with typescript.

Environment Details: Windows 10 Pro cfn 0.2.28 Python 3.10.10 Node v18.13.0

Same results with: Mac OS 12.6.3 cfn 0.2.28 Python 3.9.16 Node v18.12.1

Hook spec:

{
    "typeName": "MyCompany::Test::Hook",
    "description": "Test",
    "sourceUrl": "https://github.com/maclema/test",
    "documentationUrl": "https://github.com/maclema/test/README.md",
    "typeConfiguration": {
        "properties": {},
        "additionalProperties": false
    },
    "required": [],
    "handlers": {
        "preCreate": {
            "targetNames": [
                "AWS::S3::Bucket",
                "AWS::S3::BucketPolicy"
            ],
            "permissions": []
        },
        "preUpdate": {
            "targetNames": [
                "AWS::S3::Bucket",
                "AWS::S3::BucketPolicy"
            ],
            "permissions": []
        },
        "preDelete": {
            "targetNames": [
                "AWS::S3::Bucket",
                "AWS::S3::BucketPolicy"
            ],
            "permissions": []
        }
    },
    "additionalProperties": false
}

cfn generate output:

Generated files for **MyCompany::Test::Hook**

Resulting models.ts file:

// This is a generated file. Modifications will be overwritten.
import { BaseModel, Dict, integer, Integer, Optional, transformValue } from '@amazon-web-services-cloudformation/cloudformation-cli-typescript-lib';
import { Exclude, Expose, Type, Transform } from 'class-transformer';

export class TypeConfigurationModel extends BaseModel {
    ['constructor']: typeof TypeConfigurationModel;

}

rpdk.log

[2023-04-01T21:16:00Z] DEBUG    - Logging set up successfully
[2023-04-01T21:16:00Z] DEBUG    - Running generate: Namespace(version=False, subparser_name='generate', command=<function generate at 0x00000179DB618670>, verbose=0, endpoint_url=None, region=None, local_only=False, target_schemas=[])
[2023-04-01T21:16:00Z] DEBUG    - Root directory: C:\Users\Matt\Documents\cfn_hooks
[2023-04-01T21:16:00Z] DEBUG    - Loading project file 'C:\Users\Matt\Documents\cfn_hooks\.rpdk-config'
[2023-04-01T21:16:00Z] INFO     - Validating your hook specification...
[2023-04-01T21:16:00Z] DEBUG    - Rewriting refs in '<BASE>' (file:///C:/Users/Matt/Documents/cfn_hooks/mycompany-test-hook.json)
[2023-04-01T21:16:00Z] DEBUG    - Writing Execution Role CloudFormation template: C:\Users\Matt\Documents\cfn_hooks\hook-role.yaml
[2023-04-01T21:16:00Z] DEBUG    - Overwriting 'C:\Users\Matt\Documents\cfn_hooks\hook-role.yaml'
[2023-04-01T21:16:00Z] DEBUG    - Hook schema target names: {'AWS::S3::BucketPolicy', 'AWS::S3::Bucket'}
[2023-04-01T21:16:00Z] DEBUG    - Resolving the following type names: {'AWS::S3::BucketPolicy', 'AWS::S3::Bucket'}
[2023-04-01T21:16:00Z] DEBUG    - Retrieving info for following target names: {'AWS::S3::BucketPolicy', 'AWS::S3::Bucket'}
[2023-04-01T21:16:00Z] DEBUG    - Retrieving info for type: AWS::S3::BucketPolicy
[2023-04-01T21:16:01Z] DEBUG    - Retrieving info for type: AWS::S3::Bucket
[2023-04-01T21:16:01Z] DEBUG    - Generate started
[2023-04-01T21:16:01Z] DEBUG    - Writing file: C:\Users\Matt\Documents\cfn_hooks\src\models.ts
[2023-04-01T21:16:01Z] DEBUG    - Overwriting 'C:\Users\Matt\Documents\cfn_hooks\src\models.ts'
[2023-04-01T21:16:01Z] DEBUG    - Generate complete
[2023-04-01T21:16:01Z] DEBUG    - Removing generated docs: C:\Users\Matt\Documents\cfn_hooks\docs
[2023-04-01T21:16:01Z] DEBUG    - Writing generated docs
[2023-04-01T21:16:01Z] DEBUG    - Finished documenting nested properties
[2023-04-01T21:16:01Z] DEBUG    - Writing docs README: C:\Users\Matt\Documents\cfn_hooks\docs\README.md
[2023-04-01T21:16:01Z] WARNING  - Generated files for MyCompany::Test::Hook
[2023-04-01T21:16:01Z] DEBUG    - Finished generate
eduardomourar commented 1 year ago

I don’t believe CloudFormation Hooks are supported in the TypeScript plug-in.