does anyone know how to avoid to delete database a...
# general
a
does anyone know how to avoid to delete database and bypass the error
azure-native:sql:Database (xxxx-api-sql-db):
error: Preview failed: refusing to delete protected resource 'urn:pulumi:xxxx-apixxazure-native:sql:Database::xxxx-api-sql-db'
l
You need to remove the protected flag. Put the code back, so that the resource isn't being deleted. Remove the protected flag. Run
pulumi up
. Then you can delete the resource in the normal way.
e
You can also use
pulumi state unprotect
a
removing the flag will wipes out the datbase right, which is not desired.
e
Oh you want to add the RetainOnDelete resource property
a
@little-cartoon-10569 @echoing-dinner-19531 is there a way not removing the database and the pulumi accept the change code as its const database = azure.sql.Database.get(mi`sql-db`, { databaseName: mi`sql-db`, resourceGroupName, location, serverName: server.name, sku: envDBSku, autoPauseDelay: serverless ? 60 : undefined, readScale: serverless ? 'Disabled' : 'Enabled', highAvailabilityReplicaCount: 0, });
e
If you've already removed it from the code, and don't want it actually delete you could just rm it from state (
pulumi state delete
)
a
what could be the value of it, `const database = azure.sql.Database(mi`sql-db`, {` `databaseName: mi`sql-db`,`
resourceGroupName,
location,
serverName: server.name,
sku: envDBSku,
autoPauseDelay: serverless ? 60 : undefined,
readScale: serverless ? 'Disabled' : 'Enabled',
highAvailabilityReplicaCount: 0,
}, {
retainOnDelete: true
});
or can we use something like so, rather creating database, getting the database : `const database = azure.sql.Database.get(mi`sql-db`, {` `name: mi`sql-db`,`
resourceGroupName,
serverName: server.name,
});
e
Either, sometimes you want the stack to create the database but just not delete it, sometimes something else should have created it and you just need to get it.
a
you are right, i am looking to get it rather than creatign it
what is the best option using typescript
e
Probably just using
get
as above then