{"action":"created","issue":{"url":"https://api.github.com/repos/martysweet/cfn-lint/issues/167","repository_url":"https://api.github.com/repos/martysweet/cfn-lint","labels_url":"https://api.github.com/repos/martysweet/cfn-lint/issues/167/labels{/name}","comments_url":"https://api.github.com/repos/martysweet/cfn-lint/issues/167/comments","events_url":"https://api.github.com/repos/martysweet/cfn-lint/issues/167/events","html_url":"https://github.com/martysweet/cfn-lint/pull/167","id":325682776,"node_id":"MDExOlB1bGxSZXF1ZXN0MTg5OTU3NTc0","number":167,"title":"WIP - Support for SAM template validation.","user":{"login":"RazzM13","id":34776591,"node_id":"MDQ6VXNlcjM0Nzc2NTkx","avatar_url":"https://avatars2.githubusercontent.com/u/34776591?v=4","gravatar_id":"","url":"https://api.github.com/users/RazzM13","html_url":"https://github.com/RazzM13","followers_url":"https://api.github.com/users/RazzM13/followers","following_url":"https://api.github.com/users/RazzM13/following{/other_user}","gists_url":"https://api.github.com/users/RazzM13/gists{/gist_id}","starred_url":"https://api.github.com/users/RazzM13/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/RazzM13/subscriptions","organizations_url":"https://api.github.com/users/RazzM13/orgs","repos_url":"https://api.github.com/users/RazzM13/repos","events_url":"https://api.github.com/users/RazzM13/events{/privacy}","received_events_url":"https://api.github.com/users/RazzM13/received_events","type":"User","site_admin":false},"labels":[{"id":924439991,"node_id":"MDU6TGFiZWw5MjQ0Mzk5OTE=","url":"https://api.github.com/repos/martysweet/cfn-lint/labels/WIP","name":"WIP","color":"b7c942","default":false}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":{"url":"https://api.github.com/repos/martysweet/cfn-lint/milestones/13","html_url":"https://github.com/martysweet/cfn-lint/milestone/13","labels_url":"https://api.github.com/repos/martysweet/cfn-lint/milestones/13/labels","id":3542574,"node_id":"MDk6TWlsZXN0b25lMzU0MjU3NA==","number":13,"title":"v1.9.0","description":"","creator":{"login":"martysweet","id":20517404,"node_id":"MDQ6VXNlcjIwNTE3NDA0","avatar_url":"https://avatars2.githubusercontent.com/u/20517404?v=4","gravatar_id":"","url":"https://api.github.com/users/martysweet","html_url":"https://github.com/martysweet","followers_url":"https://api.github.com/users/martysweet/followers","following_url":"https://api.github.com/users/martysweet/following{/other_user}","gists_url":"https://api.github.com/users/martysweet/gists{/gist_id}","starred_url":"https://api.github.com/users/martysweet/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/martysweet/subscriptions","organizations_url":"https://api.github.com/users/martysweet/orgs","repos_url":"https://api.github.com/users/martysweet/repos","events_url":"https://api.github.com/users/martysweet/events{/privacy}","received_events_url":"https://api.github.com/users/martysweet/received_events","type":"User","site_admin":false},"open_issues":5,"closed_issues":0,"state":"open","created_at":"2018-08-02T17:35:17Z","updated_at":"2018-08-02T17:35:30Z","due_on":null,"closed_at":null},"comments":14,"created_at":"2018-05-23T12:28:30Z","updated_at":"2018-09-26T14:31:39Z","closed_at":null,"author_association":"CONTRIBUTOR","pull_request":{"url":"https://api.github.com/repos/martysweet/cfn-lint/pulls/167","html_url":"https://github.com/martysweet/cfn-lint/pull/167","diff_url":"https://github.com/martysweet/cfn-lint/pull/167.diff","patch_url":"https://github.com/martysweet/cfn-lint/pull/167.patch"},"body":"A basic attempt at enabling SAM support with a reduced footprint on the current validation codebase.\r\n\r\nCurrently, the [*SAM* resource and property types specifications](https://github.com/awslabs/serverless-application-model/blob/develop/samtranslator/validator/sam_schema/schema.json) are in the *JSON-Schema* format and are incompatible with the CFN version that `cfn-lint` makes use of, which are in the *AWS Resources Specification* format.\r\n\r\nUnfortunatelly, the above mentioned *SAM specification* is rather incomplete and therefore requires patching using the manually generated `data/sam_20161031_custom_specification.json` file, that is applied at runtime.\r\n\r\nCompatibility with the *AWS Resources Specification* format is attained by translating the *SAM Schema* entities into corresponding *ResourcesTypes* and *PropertyTypes* via a type parameterization approach that allows *cfn-lint* to perform dynamic type and property resolution at runtime, based on the related template markup, and register logical name overrides in order to disambiguate the conflicting types during validation. \r\n\r\nBecause the translation process requires the template markup for type resolution to take place, all intrinsic functions that alter the template must take place before the translation process can begin however, in some cases the types need to be resolved prior to intrinsic evaluation; in order to resolve the aforementioned conflict, the translation process needs to run in two phases, before the output assignment phase and before the resource property validation phase.\r\n\r\nIn addition to the resource and property types translation phase, in order to be able to validate SAM templates, *cfn-lint* must be able to reference logical resource names and related attribute values that are generated as part of the SAM transformation process threfore, based on the [SAM internals documentation](https://awslabs.github.io/serverless-application-model/internals/generated_resources.html), the aforementioned output is generated and assigned to the `SAMOutput` key of the `workingInput` variable based on the `data/sam_20161031_implicit_resources.json` file, which contains mappings of resources and their corresponding logical names that need to be generated for the specific resources that might be present in a given template.\r\n\r\nKnown limitations / considerations:\r\n- [x] Required properties are not being validated as such (easy fix);\r\n- [ ] [SAM policy templates](https://github.com/awslabs/serverless-application-model/blob/develop/docs/policy_templates.rst#policy-templates) are not implemented;\r\n- [ ] Primitive types Integer, Long and Double are indistinguishable;\r\n- [ ] Primitive types String and Timestamp are indistinguishable;\r\n- [ ] A warning is no longer generated for when a template uses an unquoted `AWSTemplateFormatVersion`;\r\n- [x] Logical name for generated SAM implicit types may not be correct;\r\n- [x] Should nested parameterized types be supported? (e.g. `Map<Map<String>`);\r\n\r\nWhat does work?\r\nSample SAM templates validate succesfully and hopefully all the old stuff still works :) \r\n"},"comment":{"url":"https://api.github.com/repos/martysweet/cfn-lint/issues/comments/424737745","html_url":"https://github.com/martysweet/cfn-lint/pull/167#issuecomment-424737745","issue_url":"https://api.github.com/repos/martysweet/cfn-lint/issues/167","id":424737745,"node_id":"MDEyOklzc3VlQ29tbWVudDQyNDczNzc0NQ==","user":{"login":"RazzM13","id":34776591,"node_id":"MDQ6VXNlcjM0Nzc2NTkx","avatar_url":"https://avatars2.githubusercontent.com/u/34776591?v=4","gravatar_id":"","url":"https://api.github.com/users/RazzM13","html_url":"https://github.com/RazzM13","followers_url":"https://api.github.com/users/RazzM13/followers","following_url":"https://api.github.com/users/RazzM13/following{/other_user}","gists_url":"https://api.github.com/users/RazzM13/gists{/gist_id}","starred_url":"https://api.github.com/users/RazzM13/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/RazzM13/subscriptions","organizations_url":"https://api.github.com/users/RazzM13/orgs","repos_url":"https://api.github.com/users/RazzM13/repos","events_url":"https://api.github.com/users/RazzM13/events{/privacy}","received_events_url":"https://api.github.com/users/RazzM13/received_events","type":"User","site_admin":false},"created_at":"2018-09-26T14:31:39Z","updated_at":"2018-09-26T14:31:39Z","author_association":"CONTRIBUTOR","body":"Your welcome and thank you for providing all of us with such as nice project.\r\nPlease have a look at it all and if you need any clarifications or would like to do things differently don't hesitate to ask :)\r\nLast but not least, yes, `sam2CFN` will generate the final `data/sam_20161031_cfn.json` that will be used by `cfn-lint`. It does so by firstly converting the SAM schema (i.e. `data/sam_20161031_schema.json`) to CFN and then does a merge of the generated schema with the contents of the `data/sam_20161031_custom_specification.json` file where, conflicting definitions will be overridden in the former by the latter."}}
{"actor":{"display_login":"RazzM13"}}