`const existingStorageAccount = azure_native.stora...
# azure
a
const existingStorageAccount = azure_native.storage.getStorageAccount({
accountName: storageAccountName,
resourceGroupName: resourceGroupName
})
const sc: any = existingStorageAccount.then((storageAccount) =>
{
new azure.storage.AccountNetworkRules("sc-network-rule", {
defaultAction: "Allow",
storageAccountId: storageAccount.id,
virtualNetworkSubnetIds: [
"myId"
]
});
});
m
I think the problem is that you are trying to modify an existing resource that is not in your state, you first have to import it in your pulumi state: https://www.pulumi.com/docs/using-pulumi/adopting-pulumi/import/
a
Also any reason why you are mixing providers? Azure Native for Storage Account Get, and Storage Account Network Rule with Azure Classic?
a
@millions-journalist-34868 I am trying to not import it, since I would like a different storage for each stack. Is there a way to import in the code instead of using the terminal?
@able-thailand-87943 Good catch! I tried using all classic and native with classic. I got the same result/error.
d
Not sure I am following here. Do you have one storage account that you are trying to add rules to based upon the stack, or do you need to create a separate storage account for each stack?
a
@ambitious-continent-10899 If you have a resource in one stack, and want to reference it another, just use stack references. https://www.pulumi.com/learn/building-with-pulumi/stack-references/ Moreover, the error you provided is coming from the terraform bridge provider for Azure Classic. Do you have the same problem if you use Azure Native for both the Storage Account and the NetworkRule? (Are they not the same as Firewall Rules?)
a
@dazzling-ice-76553 We have existing storage accounts for each stack. Unfortunately, that's how we have to do it for now. We will eventually create them with Pulumi.
m
Yes you can import in code instead of using the CLI, see here.