using System; using System.IO; using System.Collections.Generic; using Amazon.CDK; using Amazon.CDK.AWS.CloudFront; using AWS.Deploy.Recipes.CDK.Common; using BlazorWasm.Configurations; using Constructs; namespace BlazorWasm { public class AppStack : Stack { private readonly Configuration _configuration; internal AppStack(Construct scope, IDeployToolStackProps props) : base(scope, props.StackName, props) { _configuration = props.RecipeProps.Settings; // Setup callback for generated construct to provide access to customize CDK properties before creating constructs. CDKRecipeCustomizer.CustomizeCDKProps += CustomizeCDKProps; // Create custom CDK constructs here that might need to be referenced in the CustomizeCDKProps. For example if // creating a DynamoDB table construct and then later using the CDK construct reference in CustomizeCDKProps to // pass the table name as an environment variable to the container image. // Create the recipe defined CDK construct with all of its sub constructs. var generatedRecipe = new Recipe(this, props.RecipeProps); // Create additional CDK constructs here. The recipe's constructs can be accessed as properties on // the generatedRecipe variable. } /// /// This method can be used to customize the properties for CDK constructs before creating the constructs. /// /// The pattern used in this method is to check to evnt.ResourceLogicalName to see if the CDK construct about to be created is one /// you want to customize. If so cast the evnt.Props object to the CDK properties object and make the appropriate settings. /// /// private void CustomizeCDKProps(CustomizePropsEventArgs evnt) { // Example of how to customize the container image definition to include environment variables to the running applications. // //if (string.Equals(evnt.ResourceLogicalName, nameof(evnt.Construct.CloudFrontDistribution))) //{ // if (evnt.Props is DistributionProps props) // { // Console.WriteLine("Customizing CloudFront Distribution"); // } //} } } }