My background is in using terraform, but now I am trying out Pulumi/typescript for the first time. In my codebase, I have two files - index.ts and blob.ts.
The create function in blob.ts is responsible for creating a storage account, resource group, blob container, and sending the storage account key to the monitor.
Unfortunately, I'm facing an issue with the last part of the blob.ts file. When I try to export the storageAccountKeys, I encounter an error saying "Modifiers cannot appear here.ts(1184)".
The goal is to keep only functions in the index.ts file, while storing all other code in separate *.ts files.
I would appreciate any guidance on where I might be making a mistake and if there's a different approach to accessing the storage account key for monitoring purposes.
// blob.ts //
import * as pulumi from "@pulumi/pulumi";
import * as resources from "@pulumi/azure-native/resources";
import * as storage from "@pulumi/azure-native/storage";
export default function CreateStorageContainer() {
// Create an Azure Resource Group
const resourceGroup = new resources.ResourceGroup("somegroup", {
location: "westeurope",
resourceGroupName: "somegroup",
});
// Create an Azure resource (Storage Account)
const storageAccount = new storage.StorageAccount("sgsomestorageaccount", {
accountName: "sgsomestorageaccount",
resourceGroupName: resourceGroup.name,
sku: {
name: storage.SkuName.Standard_LRS,
},
kind: storage.Kind.StorageV2,
});
// Create Blob container with name :
const blobContainer = new storage.BlobContainer("someblobcontainer", {
accountName: storageAccount.name,
containerName: "someblobcontainer",
resourceGroupName: resourceGroup.name,
});
// Export the primary key of the Storage Account
export const storageAccountKeys = pulumi.all([resourceGroup.name, storageAccount.name]).apply(([resourceGroupName, accountName]) =>
storage.listStorageAccountKeys({ resourceGroupName, accountName }));
const primaryStorageKey = storageAccountKeys.keys[0].value;
}
// index.ts //
import CreateStorageContainer from "./blob.ts"
CreateStorageContainer();