https://pulumi.com logo
Title
a

acoustic-telephone-56263

04/14/2023, 7:48 AM
Hello, community. I have usage where each client gets their own schema in RDS DB. I managed to create all that with Pulumi (create user, create database, grant permissions). Everything is working nice with
pulumi up -s <stack_name>
. But the question is - what would be preferable way (or is it possible at all), not to tear down everything (schema, user data) when doing
pulumi down
?
s

steep-toddler-94095

04/14/2023, 4:42 PM
Do you mean “pulumi destroy”? Without knowing more, i could say that “pulumi stack rm -f” will destroy the stack without changing/deleting the resources. But to better answer your question, what’s your use case?
a

acoustic-telephone-56263

04/14/2023, 5:49 PM
Each user in my system will have own stack in Pulumi, which will translate to EC2 instance, Route 53 sub-domain setup and database schema in RDS. Once, I create user stack, user will have own database schema. And here comes the catch - user says that he is no longer willing to use my product, but after a week says -
Sorry I was wrong, I will keep use your product
. Due to cost savings I might do
pulumi down -s <user_stack>
, but would like to keep database schema and user untouched. With current usage, it removes everything from DBS as well. Example of current implementation
database = mysql.Database(
    "user_database",
    name=data.get("db_name"),
)

user = mysql.User(
    "database_user",
    user=data.get("db_user"),
    host="%",
    plaintext_password=data.get("db_password"),
)

mysql.Grant(
    "database_user_privileges",
    user=user.user,
    host=user.host,
    database=database.name,
    privileges=[
        "CREATE",
        "SELECT",
        "UPDATE",
        "REFERENCES",
        "DELETE",
        "INSERT",
    ],
)
s

steep-toddler-94095

04/14/2023, 6:15 PM
There's the `RetainOnDelete` option but keep in mind that:
If a retained resource is deleted by Pulumi and you later want to actually delete it from the backing cloud provider you will either need to use your provider’s manual interface to find and delete the resource, or import the resource back into Pulumi to unset
retainOnDelete
and delete it again fully.
Similarly, you'll also have to import the resource into Pulumi if the customer changes their mind
a

acoustic-telephone-56263

04/14/2023, 6:24 PM
Thanks for input. Will look into it 🙂