2020-10-06 05:57:52 +00:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
2021-09-29 18:33:57 +00:00
|
|
|
"github.com/pulumi/pulumi-azure/sdk/v4/go/azure/core"
|
|
|
|
"github.com/pulumi/pulumi-azure/sdk/v4/go/azure/storage"
|
2021-03-17 13:20:05 +00:00
|
|
|
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
|
|
|
|
"github.com/pulumi/pulumi/sdk/v3/go/pulumi/config"
|
2020-10-06 05:57:52 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
func main() {
|
|
|
|
pulumi.Run(func(ctx *pulumi.Context) error {
|
2020-10-06 18:09:52 +00:00
|
|
|
cfg := config.New(ctx, "")
|
2023-03-21 14:01:16 +00:00
|
|
|
// The name of the storage account
|
2020-10-07 19:29:33 +00:00
|
|
|
storageAccountNameParam := cfg.Require("storageAccountNameParam")
|
2023-03-21 14:01:16 +00:00
|
|
|
// The name of the resource group
|
2020-10-06 18:09:52 +00:00
|
|
|
resourceGroupNameParam := cfg.Require("resourceGroupNameParam")
|
2020-10-06 05:57:52 +00:00
|
|
|
resourceGroupVar, err := core.LookupResourceGroup(ctx, &core.LookupResourceGroupArgs{
|
|
|
|
Name: resourceGroupNameParam,
|
|
|
|
}, nil)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
locationParam := resourceGroupVar.Location
|
2020-10-06 18:09:52 +00:00
|
|
|
if param := cfg.Get("locationParam"); param != "" {
|
2020-10-06 05:57:52 +00:00
|
|
|
locationParam = param
|
|
|
|
}
|
2020-10-07 19:29:33 +00:00
|
|
|
storageAccountTierParam := "Standard"
|
|
|
|
if param := cfg.Get("storageAccountTierParam"); param != "" {
|
|
|
|
storageAccountTierParam = param
|
|
|
|
}
|
|
|
|
storageAccountTypeReplicationParam := "LRS"
|
|
|
|
if param := cfg.Get("storageAccountTypeReplicationParam"); param != "" {
|
|
|
|
storageAccountTypeReplicationParam = param
|
|
|
|
}
|
|
|
|
storageAccountResource, err := storage.NewAccount(ctx, "storageAccountResource", &storage.AccountArgs{
|
|
|
|
Name: pulumi.String(storageAccountNameParam),
|
|
|
|
AccountKind: pulumi.String("StorageV2"),
|
|
|
|
Location: pulumi.String(locationParam),
|
|
|
|
ResourceGroupName: pulumi.String(resourceGroupNameParam),
|
|
|
|
AccountTier: pulumi.String(storageAccountTierParam),
|
|
|
|
AccountReplicationType: pulumi.String(storageAccountTypeReplicationParam),
|
|
|
|
})
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
ctx.Export("storageAccountNameOut", storageAccountResource.Name)
|
2020-10-06 05:57:52 +00:00
|
|
|
return nil
|
|
|
|
})
|
|
|
|
}
|