Exemple #1
0
        private void ConfigureS3ContentBucket()
        {
            var bucketProps = new BucketProps
            {
                // Turn on delete objects so deployed Blazor application is deleted when the stack is deleted.
                AutoDeleteObjects = true,
                RemovalPolicy     = RemovalPolicy.DESTROY
            };

            ContentS3Bucket = new Bucket(this, nameof(ContentS3Bucket), InvokeCustomizeCDKPropsEvent(nameof(ContentS3Bucket), this, bucketProps));

            new CfnOutput(this, "S3ContentBucket", new CfnOutputProps
            {
                Description = "S3 bucket where Blazor application is uploaded to",
                Value       = ContentS3Bucket.BucketName
            });
        }
Exemple #2
0
        internal AppStack(Construct scope, RecipeConfiguration <Configuration> recipeConfiguration, IStackProps props = null)
            : base(scope, recipeConfiguration.StackName, props)
        {
            var bucketProps = new BucketProps
            {
                WebsiteIndexDocument = recipeConfiguration.Settings.IndexDocument,
                PublicReadAccess     = true,

                // Turn on delete objects so deployed Blazor application is deleted when the stack is deleted.
                AutoDeleteObjects = true,
                RemovalPolicy     = RemovalPolicy.DESTROY
            };

            if (recipeConfiguration.Settings.Redirect404ToRoot)
            {
                bucketProps.WebsiteRoutingRules = new IRoutingRule[] {
                    new RoutingRule
                    {
                        Condition = new RoutingRuleCondition
                        {
                            HttpErrorCodeReturnedEquals = "404"
                        },
                        ReplaceKey = ReplaceKey.With("")
                    }
                };
            }

            if (!string.IsNullOrEmpty(recipeConfiguration.Settings.ErrorDocument))
            {
                bucketProps.WebsiteErrorDocument = recipeConfiguration.Settings.ErrorDocument;
            }

            var bucket = new Bucket(this, "BlazorHost", bucketProps);

            new BucketDeployment(this, "BlazorDeployment", new BucketDeploymentProps
            {
                Sources           = new ISource[] { Source.Asset(Path.Combine(recipeConfiguration.DotnetPublishOutputDirectory, "wwwroot")) },
                DestinationBucket = bucket
            });

            new CfnOutput(this, "EndpointURL", new CfnOutputProps
            {
                Value = $"http://{bucket.BucketWebsiteDomainName}/"
            });
        }