cloudtools / troposphere

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

Unable to set StringValue on ObjectField in DataPipeline #283

Closed grubernaut closed 9 years ago

grubernaut commented 9 years ago

I'm unable to properly set a StringValue inside of an ObjectField resource when creating a DataPipeline.

This error gets returned from CloudFormation:

Value of property StringValue must be of type String

Snippit of troposphere code:

        schedule = PipelineObject(
            Fields=[ObjectField(
                Key='type',
                StringValue=['Schedule']
            ), ObjectField(
                Key='occurences',
                StringValue=['2']
            ), ObjectField(
                Key='startAt',
                StringValue=['FIRST_ACTIVATION_DATE_TIME']
            ), ObjectField(
                Key='period',
                StringValue=['1 day']
            )],
            Id= 'S3_Schedule',
            Name='S3Schedule'
        )

I believe this is due to @philtay's latest commit (https://github.com/cloudtools/troposphere/commit/a1957fb04118ce13f2cb37a52bc93718eed0ae41), which now expects StringValue to be an array.

If I specify the StringValue as a string and not an array, troposphere fails to build the cloudformation as well:

TypeError: StringValue is <type 'str'>, expected [<type 'basestring'>, <class 'troposphere.Ref'>]

I could, however, be declaring the ObjectField's completely wrong.

philtay commented 9 years ago

It looks like the same problem of #281. [<type 'basestring'>, <class 'troposphere.Ref'>] should allow both Refs and strings. Am I missing something @markpeek? Probably yes, but no time to check right now.

markpeek commented 9 years ago

@grubernaut thank you for filing the issue. I reverted the change.

@philtay sorry I didn't catch this issue originally. The code here handles allowing Ref() in a non-list context. Previously a list "[]" expected type was the only thing supported without any element type checking. Later on I added the ability to check list elements as well in this commit which allows for things like: [basestring, Ref] or [basestring, AWSHelperFn].