I'm confused about how to use @resource_manager ef...
# ask-community
t
I'm confused about how to use @resource_manager effectively. I am using it to create an RDS instance in AWS. I can create it fine in setup and destroy it in cleanup but I don't understand how to get the endpoint out of it. It seems to wrap it in a ResourceManager so I can't access any attributes of my class from the flow. How can I use the client as instantiated here
with OracleRDS() as client
?
k
HI @Trevor Kramer! Did you try passing the
client
into Tasks inside the
with OracleRDS() as client
?
t
I did and it seems to be passed as a string so I can't access any attributes of the class
Unexpected error: AttributeError("'str' object has no attribute 'connection_string'")
k
Can you show me how you’re using it?
t
Copy code
with OracleRDS() as client:
    result = SomeImportTask()(input_url, xer['job_queue'], xer['job_definition'], client)
and
Copy code
class SomeImportTask(BatchExecuteTask):
    def run(self, input_url: str, job_queue_arn: str, job_definition_arn: str, rds) -> str:
        super().run('SomeImportTask', job_queue_arn, job_definition_arn,
                    {'input_url': input_url, 'connection_string': rds.connection_string})
        <http://self.logger.info|self.logger.info>(f'Finished importing {input_url}')
        return rds.connection_string
Copy code
@resource_manager
class OracleRDS:
    def __init__(self, username_arn, password_arn, rds_integration_role, rds_option_group, subnet_group, port, sg) -> None:
        self._rds = boto3.client('rds')
        self._username_arn = username_arn
        self._password_arn = password_arn
        self._rds_integration_role = rds_integration_role
        self._rds_option_group = rds_option_group
        self._subnet_group = subnet_group
        self._port = port
        self._sg = sg
        self._connection_string = None

    @property
    def connection_string(self):
        return self._connection_string

    def setup(self):...
k
Got it will take a look at it
t
do I need to return self from setup?
currently I am returning an id needed to destroy the instance in cleanup
I figured it out
k
Oh could you tell me what it was? Been looking at it myself. Would like to know.
t
if you return self from setup then you have access to the object
k
Ah ok thanks for letting me know!