https://pulumi.com logo
#azure
Title
a

ambitious-continent-10899

06/22/2023, 3:58 PM
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

millions-journalist-34868

06/22/2023, 4:24 PM
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

able-thailand-87943

06/22/2023, 5:09 PM
Also any reason why you are mixing providers? Azure Native for Storage Account Get, and Storage Account Network Rule with Azure Classic?
a

ambitious-continent-10899

06/22/2023, 7:37 PM
@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

dazzling-ice-76553

06/22/2023, 9:10 PM
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

able-thailand-87943

06/23/2023, 6:55 AM
@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

ambitious-continent-10899

06/23/2023, 2:17 PM
@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

melodic-tomato-39005

06/24/2023, 11:58 PM
Yes you can import in code instead of using the CLI, see here.