cloudtools / troposphere

troposphere - Python library to create AWS CloudFormation descriptions
BSD 2-Clause "Simplified" License
4.93k stars 1.45k forks source link

SSM Document Property "Content" also allows plain Strings #2053

Closed pmau closed 2 years ago

pmau commented 2 years ago

Good evening everyone,

This is my first issue report. My apologies for any mistakes I make submitting this. I'm using troposphere 4.0.2 as it is tagged on GitHub.

https://github.com/cloudtools/troposphere/blob/4.0.2/troposphere/ssm.py In line 115 the propery "Content" is define as a "dict", but according to the AWS Documentation, it also accepts palin strings.

https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-ssm-document.html#cfn-ssm-document-content

I temporarely changed the code and simply used "YAML as a string" inside a JSON CloudFormation Template. Everything worked as it should and the pre-formatted YAML shows up as the contents of SSM Document.

I'm unclear about how this should be fixed correctly. I simply added the type in the one-line diff below:

--- ssm.py  2022-06-10 18:28:07.450170572 +0000
+++ ssm.py.new  2022-06-10 18:28:22.186197102 +0000
@@ -112,7 +112,7 @@

     props: PropsDictType = {
         "Attachments": ([AttachmentsSource], False),
-        "Content": (dict, True),
+        "Content": ((dict, str), True),
         "DocumentFormat": (str, False),
         "DocumentType": (str, False),
         "Name": (str, False),
markpeek commented 2 years ago

Thanks for the issue. I'll have to write a custom validator for it to handle all the cases (dict, json string, yaml string).