@@ -32,6 +32,7 @@ import (
3232 "github.com/pkg/errors"
3333 apimanagement "github.com/pulumi/pulumi-azure-native-sdk/apimanagement/v2"
3434 "github.com/pulumi/pulumi-azure-native-sdk/authorization"
35+ cdn "github.com/pulumi/pulumi-azure-native-sdk/cdn/v2"
3536 "github.com/pulumi/pulumi-azure-native-sdk/containerinstance/v2"
3637 "github.com/pulumi/pulumi-azure-native-sdk/dbforpostgresql/v2"
3738 "github.com/pulumi/pulumi-azure-native-sdk/eventgrid"
@@ -42,6 +43,7 @@ import (
4243 "github.com/pulumi/pulumi-random/sdk/v4/go/random"
4344 "github.com/pulumi/pulumi/sdk/v3/go/auto"
4445 "github.com/pulumi/pulumi/sdk/v3/go/pulumi"
46+ "github.com/samber/lo"
4547 "google.golang.org/grpc/codes"
4648 "google.golang.org/grpc/status"
4749)
@@ -57,6 +59,10 @@ type NitricAzurePulumiProvider struct {
5759 StackId string
5860 resources []* pulumix.NitricPulumiResource [any ]
5961
62+ website * storage.StorageAccountStaticWebsite
63+ websiteEndpoint * cdn.Endpoint
64+ websiteChangedFileOutputs pulumi.StringArray
65+
6066 AzureConfig * AzureConfig
6167
6268 ClientConfig * authorization.GetClientConfigResult
@@ -376,10 +382,16 @@ func (a *NitricAzurePulumiProvider) Pre(ctx *pulumi.Context, nitricResources []*
376382 hasKvStores := hasResourceType (nitricResources , resourcespb .ResourceType_KeyValueStore )
377383 hasQueues := hasResourceType (nitricResources , resourcespb .ResourceType_Queue )
378384
385+ websites := lo .Filter (nitricResources , func (item * pulumix.NitricPulumiResource [any ], idx int ) bool {
386+ return item .Id .Type == resourcespb .ResourceType_Website
387+ })
388+
389+ hasWebsites := len (websites ) > 0
390+
379391 // Create a storage account if buckets, kv stores or queues are required.
380392 // Unlike AWS and GCP which have centralized storage management, Azure allows for multiple storage accounts.
381393 // This means we need to create a storage account for each stack, before buckets can be created.
382- if hasBuckets || hasKvStores || hasQueues {
394+ if hasBuckets || hasKvStores || hasQueues || hasWebsites {
383395 logger .Info ("Stack declares bucket(s), key/value store(s) or queue(s), creating stack level Azure Storage Account" )
384396 a .StorageAccount , err = createStorageAccount (ctx , a .ResourceGroup , tags .Tags (a .StackId , ctx .Stack (), commonresources .Stack ))
385397 if err != nil {
@@ -398,10 +410,24 @@ func (a *NitricAzurePulumiProvider) Pre(ctx *pulumi.Context, nitricResources []*
398410 return err
399411 }
400412
413+ if hasWebsites {
414+ err = a .createStaticWebsite (ctx , websites )
415+ if err != nil {
416+ return err
417+ }
418+ }
419+
401420 return nil
402421}
403422
404423func (a * NitricAzurePulumiProvider ) Post (ctx * pulumi.Context ) error {
424+ if a .website != nil {
425+ err := a .deployCDN (ctx )
426+ if err != nil {
427+ return err
428+ }
429+ }
430+
405431 return nil
406432}
407433
@@ -419,6 +445,14 @@ func (a *NitricAzurePulumiProvider) Result(ctx *pulumi.Context) (pulumi.StringOu
419445 }
420446 }
421447
448+ if a .websiteEndpoint != nil {
449+ if len (outputs ) > 0 {
450+ outputs = append (outputs , "\n " )
451+ }
452+ outputs = append (outputs , pulumi .Sprintf ("CDN:\n ──────────────" ))
453+ outputs = append (outputs , pulumi .Sprintf ("https://%s" , a .websiteEndpoint .HostName ))
454+ }
455+
422456 // Add HTTP Proxy outputs
423457 if len (a .HttpProxies ) > 0 {
424458 if len (outputs ) > 0 {
0 commit comments