Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AllocatedStorage can't be a Ref #2176

Closed
uldall opened this issue Aug 24, 2023 · 4 comments · Fixed by #2225
Closed

AllocatedStorage can't be a Ref #2176

uldall opened this issue Aug 24, 2023 · 4 comments · Fixed by #2225

Comments

@uldall
Copy link

uldall commented Aug 24, 2023

If I try to use a Parameter for setting the AllocatedStorage of an RDS database I get the following error:

  File "/home/cup/.local/share/virtualenvs/system-oD26KLrH/lib/python3.11/site-packages/troposphere/validators/rds.py", line 402, in validate_dbinstance
    and int(allocated_storage) < 400
        ^^^^^^^^^^^^^^^^^^^^^^
TypeError: int() argument must be a string, a bytes-like object or a real number, not 'Ref'

Version: 4.4.1

@uldall
Copy link
Author

uldall commented Sep 15, 2023

Thank you!

@uldall
Copy link
Author

uldall commented Feb 12, 2024

I tested this again on 4.6.0 and get this error:

  File "/root/.local/share/virtualenvs/system-B6up595e/lib/python3.11/site-packages/troposphere/validators/rds.py", line 509, in validate_dbinstance

    f"current value is {iops / int(allocated_storage)}"

                               ^^^^^^^^^^^^^^^^^^^^^^

TypeError: int() argument must be a string, a bytes-like object or a real number, not 'Ref'

Can we re-open this issue?

@markpeek
Copy link
Member

Reopening. Could you post a minimal repro case (with fake names/data) for the error you are seeing? I want to make sure I get a test for it and ensure the fix works for your use case.

@markpeek markpeek reopened this Feb 12, 2024
@uldall
Copy link
Author

uldall commented Feb 13, 2024

Thank you! Here is an example:

#!/usr/bin/env python

from troposphere import Parameter, Template, Ref
from troposphere.rds import DBInstance

if __name__ == "__main__":
    t = Template()

    AllocatedStorage = t.add_parameter(Parameter(
        "DBAllocatedStorage",
        Type="String",
    ))

    t.add_resource(DBInstance(
        "Database",
        Engine="postgres",
        EngineVersion="15.3",
        StorageType="gp3",
        AllocatedStorage=Ref(AllocatedStorage),
        Iops=12000,
        StorageThroughput=500,
        MasterUsername="test",
        MasterUserPassword="test",
    ))

    t.to_yaml()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants