### Eager Loading Example Source: https://github.com/localstack-dotnet/dotnet-aspire-for-localstack/blob/master/docs/CONFIGURATION.md Example of configuring LocalStack with specific eager-loaded services. ```csharp builder.AddLocalStack(configureContainer: container => { container.EagerLoadedServices = [AwsService.Sqs, AwsService.DynamoDB, AwsService.S3]; }); ``` -------------------------------- ### Quick Demo - Start Application Source: https://github.com/localstack-dotnet/dotnet-aspire-for-localstack/blob/master/playground/lambda/README.md Command to start the .NET Aspire application using the LocalStack Lambda AppHost. ```bash # 1. Start the application (Docker must be running) dotnet run --project LocalStack.Lambda.AppHost ``` -------------------------------- ### Lazy Loading Example Source: https://github.com/localstack-dotnet/dotnet-aspire-for-localstack/blob/master/docs/CONFIGURATION.md Example of adding LocalStack with default lazy loading. ```csharp var localstack = builder.AddLocalStack(); // No eager loading - uses lazy loading ``` -------------------------------- ### Session Lifetime Example Source: https://github.com/localstack-dotnet/dotnet-aspire-for-localstack/blob/master/docs/CONFIGURATION.md Example showing the default Session container lifetime. ```csharp // Default - no need to set explicitly container.Lifetime = ContainerLifetime.Session; ``` -------------------------------- ### Manual Approach Source: https://github.com/localstack-dotnet/dotnet-aspire-for-localstack/blob/master/playground/provisioning/README.md Example demonstrating manual reference management for LocalStack and AWS resources. ```csharp // Manual LocalStack references (currently commented out in Program.cs files) var awsResources = builder.AddAWSCloudFormationTemplate("resources", "app-resources.template") .WithReference(localstack); // Manual LocalStack reference var project = builder.AddProject("Frontend") .WithReference(localstack); // Manual project reference ``` -------------------------------- ### Persistent Lifetime Example Source: https://github.com/localstack-dotnet/dotnet-aspire-for-localstack/blob/master/docs/CONFIGURATION.md Example of setting the container lifetime to Persistent. ```csharp container.Lifetime = ContainerLifetime.Persistent; ``` -------------------------------- ### Custom Registry - Artifactory Example Source: https://github.com/localstack-dotnet/dotnet-aspire-for-localstack/blob/master/docs/CONFIGURATION.md Example configuration for pulling LocalStack images from Artifactory. ```csharp container.ContainerRegistry = "artifactory.company.com"; container.ContainerImage = "docker-local/localstack/localstack"; container.ContainerImageTag = "4.10.0"; // Pulls: artifactory.company.com/docker-local/localstack/localstack:4.10.0 ``` -------------------------------- ### Auto-Configure Approach Source: https://github.com/localstack-dotnet/dotnet-aspire-for-localstack/blob/master/playground/provisioning/README.md Example demonstrating the automatic configuration of LocalStack and AWS resources using the `UseLocalStack` method. ```csharp // 1. Add LocalStack container var localstack = builder.AddLocalStack(awsConfig: awsConfig, configureContainer: container => { container.Lifetime = ContainerLifetime.Session; container.LogLevel = LocalStackLogLevel.Debug; }); // 2. Add your AWS resources normally var awsResources = builder.AddAWSCloudFormationTemplate("resources", "app-resources.template") .WithReference(awsConfig); // 3. Auto-configure everything with one call builder.UseLocalStack(localstack); // πŸͺ„ Automatically detects and configures all AWS resources ``` -------------------------------- ### Available Services for Eager Loading Source: https://github.com/localstack-dotnet/dotnet-aspire-for-localstack/blob/master/docs/CONFIGURATION.md Example demonstrating a list of common AWS services that can be eagerly loaded. ```csharp container.EagerLoadedServices = [ AwsService.Sqs, // Simple Queue Service AwsService.DynamoDB, // DynamoDB AwsService.S3, // S3 Storage AwsService.Sns, // Simple Notification Service AwsService.Lambda, // Lambda Functions AwsService.CloudFormation,// CloudFormation AwsService.SecretsManager,// Secrets Manager AwsService.Ssm, // Systems Manager (Parameter Store) // ... see LocalStack docs for full list ]; ``` -------------------------------- ### Follow the short URL Source: https://github.com/localstack-dotnet/dotnet-aspire-for-localstack/blob/master/playground/lambda/README.md Example of using curl to follow a shortened URL. ```bash curl -I {GATEWAY_BASE_URL}/abc123 # β†’ 302 Found, Location: https://aws.amazon.com ``` -------------------------------- ### List all resources Source: https://github.com/localstack-dotnet/dotnet-aspire-for-localstack/blob/master/playground/provisioning/README.md Commands to list SNS topics, SQS queues, and DynamoDB tables using the LocalStack endpoint. ```bash aws sns list-topics --endpoint-url {LOCALSTACK_ENDPOINT} --region us-west-2 aws sqs list-queues --endpoint-url {LOCALSTACK_ENDPOINT} --region us-west-2 aws dynamodb list-tables --endpoint-url {LOCALSTACK_ENDPOINT} --region us-west-2 ``` -------------------------------- ### Shorten URL with QR code Source: https://github.com/localstack-dotnet/dotnet-aspire-for-localstack/blob/master/playground/lambda/README.md Example of using curl to POST a URL for shortening and QR code generation. ```bash curl -d '{"url":"https://aws.amazon.com","format":"qr"}' \ -H "Content-Type: application/json" \ -X POST {GATEWAY_BASE_URL}/shorten # β†’ { "id":"abc123", "qrUrl":"http://localhost:4566/…/qr/abc123.png" } ``` -------------------------------- ### Custom Registry - GitHub Container Registry (GHCR) Example Source: https://github.com/localstack-dotnet/dotnet-aspire-for-localstack/blob/master/docs/CONFIGURATION.md Example configuration for pulling LocalStack images from GitHub Container Registry. ```csharp container.ContainerRegistry = "ghcr.io"; container.ContainerImage = "myorg/localstack"; container.ContainerImageTag = "custom-build-123"; // Pulls: ghcr.io/myorg/localstack:custom-build-123 ``` -------------------------------- ### Run CloudFormation AppHost Source: https://github.com/localstack-dotnet/dotnet-aspire-for-localstack/blob/master/playground/provisioning/README.md Command to run the .NET application that provisions resources using CloudFormation. ```bash dotnet run --project LocalStack.Provisioning.CloudFormation.AppHost ``` -------------------------------- ### Install development packages Source: https://github.com/localstack-dotnet/dotnet-aspire-for-localstack/blob/master/README.md Command to install development packages of LocalStack.Aspire.Hosting from GitHub Packages. ```bash # Install development packages dotnet add package LocalStack.Aspire.Hosting --prerelease --source github-localstack-for-aspire ``` -------------------------------- ### Custom Registry - Pin to Specific Version Example Source: https://github.com/localstack-dotnet/dotnet-aspire-for-localstack/blob/master/docs/CONFIGURATION.md Example of overriding only the tag to use a different LocalStack version from the default registry. ```csharp // Only override the tag to use a different LocalStack version container.ContainerImageTag = "3.8.1"; // Pulls: docker.io/localstack/localstack:3.8.1 ``` -------------------------------- ### Run CDK AppHost Source: https://github.com/localstack-dotnet/dotnet-aspire-for-localstack/blob/master/playground/provisioning/README.md Command to run the .NET application that provisions resources using AWS CDK. ```bash dotnet run --project LocalStack.Provisioning.CDK.AppHost ``` -------------------------------- ### Custom Registry - Azure Container Registry (ACR) Example Source: https://github.com/localstack-dotnet/dotnet-aspire-for-localstack/blob/master/docs/CONFIGURATION.md Example configuration for pulling LocalStack images from Azure Container Registry. ```csharp container.ContainerRegistry = "mycompany.azurecr.io"; container.ContainerImage = "localstack/localstack"; container.ContainerImageTag = "4.10.0"; // Pulls: mycompany.azurecr.io/localstack/localstack:4.10.0 ``` -------------------------------- ### Enabling Eager Loading for Health Checks Source: https://github.com/localstack-dotnet/dotnet-aspire-for-localstack/blob/master/docs/CONFIGURATION.md Example of using eager loading to potentially resolve container health check issues. ```csharp container.EagerLoadedServices = [AwsService.Sqs]; ``` -------------------------------- ### Manual Configuration of AWS Resources Source: https://github.com/localstack-dotnet/dotnet-aspire-for-localstack/blob/master/README.md Example demonstrating manual configuration of AWS resources and their references to LocalStack. ```csharp var awsResources = builder.AddAWSCloudFormationTemplate("resources", "template.yaml") .WithReference(localstack) // Manual LocalStack reference .WithReference(awsConfig); var project = builder.AddProject("api") .WithReference(localstack) // Manual project reference .WithReference(awsResources); ``` -------------------------------- ### Install LocalStack.Aspire.Hosting package Source: https://github.com/localstack-dotnet/dotnet-aspire-for-localstack/blob/master/README.md Command to add the LocalStack.Aspire.Hosting package to a .NET project. ```bash dotnet add package LocalStack.Aspire.Hosting ``` -------------------------------- ### Enabling Persistence for Data Source: https://github.com/localstack-dotnet/dotnet-aspire-for-localstack/blob/master/docs/CONFIGURATION.md Configuration to enable data persistence for the LocalStack container. ```csharp container.AdditionalEnvironmentVariables["PERSISTENCE"] = "1"; ``` -------------------------------- ### Backward Compatibility - Default Configuration Source: https://github.com/localstack-dotnet/dotnet-aspire-for-localstack/blob/master/docs/CONFIGURATION.md Demonstrates the default configuration which is equivalent to using the public Docker Hub image. ```csharp builder.AddLocalStack(); builder.AddLocalStack(configureContainer: container => { container.ContainerRegistry = "docker.io"; container.ContainerImage = "localstack/localstack"; container.ContainerImageTag = "4.10.0"; // Package version }); ``` -------------------------------- ### Default Port Behavior Source: https://github.com/localstack-dotnet/dotnet-aspire-for-localstack/blob/master/docs/CONFIGURATION.md Illustrates the default port mapping behavior based on container lifetime. ```csharp // Session lifetime (Default) - uses dynamic port assignment container.Lifetime = ContainerLifetime.Session; // Port will be: random available port // Persistent lifetime - uses default LocalStack port (4566) container.Lifetime = ContainerLifetime.Persistent; // Port will be: 4566 ``` -------------------------------- ### Custom Registry - AWS Elastic Container Registry (ECR) Example Source: https://github.com/localstack-dotnet/dotnet-aspire-for-localstack/blob/master/docs/CONFIGURATION.md Example configuration for pulling LocalStack images from AWS Elastic Container Registry. ```csharp container.ContainerRegistry = "123456789012.dkr.ecr.us-west-2.amazonaws.com"; container.ContainerImage = "localstack/localstack"; container.ContainerImageTag = "4.10.0"; // Pulls: 123456789012.dkr.ecr.us-west-2.amazonaws.com/localstack/localstack:4.10.0 ``` -------------------------------- ### Comment out auto-configure in CloudFormation AppHost Source: https://github.com/localstack-dotnet/dotnet-aspire-for-localstack/blob/master/playground/provisioning/README.md C# code snippet showing how to comment out the auto-configuration for LocalStack in the CloudFormation AppHost. ```csharp // Comment out auto-configure // builder.UseLocalStack(localstack); // Uncomment manual references // .WithReference(localstack) ``` -------------------------------- ### Test message flow Source: https://github.com/localstack-dotnet/dotnet-aspire-for-localstack/blob/master/playground/provisioning/README.md Commands to publish a message to SNS and scan a DynamoDB table, simulating a message processing flow. ```bash # Publish to SNS (replace with actual ARN from Aspire dashboard) aws sns publish --topic-arn --message "Test message from CLI" --endpoint-url {LOCALSTACK_ENDPOINT} --region us-west-2 # Check DynamoDB for processed message aws dynamodb scan --table-name ChatMessages --endpoint-url {LOCALSTACK_ENDPOINT} --region us-west-2 ``` -------------------------------- ### CLI Testing - Check SQS queue Source: https://github.com/localstack-dotnet/dotnet-aspire-for-localstack/blob/master/playground/lambda/README.md AWS CLI command to get attributes of an SQS queue using LocalStack endpoint. ```bash aws sqs get-queue-attributes --queue-url {ANALYTICS_QUEUE_URL} --attribute-names All --endpoint-url {LOCALSTACK_ENDPOINT} --region eu-central-1 ``` -------------------------------- ### Container Registry Authentication - Private Registry Source: https://github.com/localstack-dotnet/dotnet-aspire-for-localstack/blob/master/docs/CONFIGURATION.md Command to log in to a private container registry. ```bash docker login artifactory.company.com ``` -------------------------------- ### Comment out auto-configure in CDK AppHost Source: https://github.com/localstack-dotnet/dotnet-aspire-for-localstack/blob/master/playground/provisioning/README.md C# code snippet showing how to comment out the auto-configuration for LocalStack in the CDK AppHost and uncomment manual references. ```csharp // Comment out auto-configure // builder.UseLocalStack(localstack); // Uncomment manual CDK bootstrap and references // var cdkBootstrap = builder.AddAWSCDKBootstrapCloudFormationTemplate()... // .WithReference(localstack) // .WaitFor(cdkBootstrap) ``` -------------------------------- ### Debug Level Configuration Source: https://github.com/localstack-dotnet/dotnet-aspire-for-localstack/blob/master/docs/CONFIGURATION.md Setting the DebugLevel for LocalStack to enable verbose logging for troubleshooting. ```csharp container.DebugLevel = 1; // Enable verbose logging ``` -------------------------------- ### Development Configuration (Fast Iteration) Source: https://github.com/localstack-dotnet/dotnet-aspire-for-localstack/blob/master/docs/CONFIGURATION.md Configuration for development environments focusing on fast iteration, using default session lifetime and lazy loading. ```csharp builder.AddLocalStack(configureContainer: container => { // Default Session lifetime is fine for most development container.LogLevel = LocalStackLogLevel.Warn; // Use lazy loading for faster startup }); ``` -------------------------------- ### Development Configuration (Container Reuse) Source: https://github.com/localstack-dotnet/dotnet-aspire-for-localstack/blob/master/docs/CONFIGURATION.md Configuration for development environments where container reuse is desired between runs, using `ContainerLifetime.Persistent`. ```csharp builder.AddLocalStack(configureContainer: container => { // Use Persistent to reuse container between runs container.Lifetime = ContainerLifetime.Persistent; container.LogLevel = LocalStackLogLevel.Warn; }); ``` -------------------------------- ### Container Registry Authentication - Docker Hub Source: https://github.com/localstack-dotnet/dotnet-aspire-for-localstack/blob/master/docs/CONFIGURATION.md Command to log in to Docker Hub for registry authentication. ```bash docker login ``` -------------------------------- ### CI/CD Configuration Source: https://github.com/localstack-dotnet/dotnet-aspire-for-localstack/blob/master/docs/CONFIGURATION.md Configuration optimized for CI/CD pipelines, using default session lifetime and eagerly loading all services used in tests. ```csharp builder.AddLocalStack(configureContainer: container => { // Default Session lifetime is perfect for CI/CD container.LogLevel = LocalStackLogLevel.Error; // Eagerly load all services used in tests container.EagerLoadedServices = [AwsService.Sqs, AwsService.DynamoDB, AwsService.S3]; }); ``` -------------------------------- ### CLI Testing - List S3 objects Source: https://github.com/localstack-dotnet/dotnet-aspire-for-localstack/blob/master/playground/lambda/README.md AWS CLI command to list objects in an S3 bucket using LocalStack endpoint. ```bash aws s3api list-objects --bucket "qr-bucket" --endpoint-url {LOCALSTACK_ENDPOINT} --region eu-central-1 ``` -------------------------------- ### Container Registry Authentication - Azure Container Registry Source: https://github.com/localstack-dotnet/dotnet-aspire-for-localstack/blob/master/docs/CONFIGURATION.md Command to log in to Azure Container Registry. ```bash az acr login --name mycompany ``` -------------------------------- ### Environment Variable Conflicts Solution Source: https://github.com/localstack-dotnet/dotnet-aspire-for-localstack/blob/master/docs/CONFIGURATION.md Demonstrates how to resolve environment variable conflicts by correctly configuring `EagerLoadedServices` instead of manually setting `SERVICES` or `EAGER_SERVICE_LOADING`. ```csharp // ❌ DON'T DO THIS container.AdditionalEnvironmentVariables["SERVICES"] = "sqs,dynamodb"; container.EagerLoadedServices = [AwsService.S3]; // Conflict! // βœ… DO THIS container.EagerLoadedServices = [AwsService.Sqs, AwsService.DynamoDB, AwsService.S3]; ``` -------------------------------- ### Log Level Configuration Source: https://github.com/localstack-dotnet/dotnet-aspire-for-localstack/blob/master/docs/CONFIGURATION.md Sets the log level for LocalStack using the `LS_LOG` environment variable. ```csharp container.LogLevel = LocalStackLogLevel.Debug; ``` -------------------------------- ### Integration Testing Configuration Source: https://github.com/localstack-dotnet/dotnet-aspire-for-localstack/blob/master/docs/CONFIGURATION.md Configuration for integration testing, using default session lifetime, dynamic ports for parallel runs, and eager loading to avoid cold-start variance. ```csharp builder.AddLocalStack(configureContainer: container => { // Default Session lifetime - perfect for isolated test runs container.LogLevel = LocalStackLogLevel.Error; // Dynamic ports by default - allows parallel test runs without conflicts // Eagerly load services to avoid cold-start variance container.EagerLoadedServices = [AwsService.Sqs, AwsService.DynamoDB]; }); ``` -------------------------------- ### Container Registry Authentication - AWS ECR Source: https://github.com/localstack-dotnet/dotnet-aspire-for-localstack/blob/master/docs/CONFIGURATION.md Command to log in to AWS Elastic Container Registry. ```bash aws ecr get-login-password --region us-west-2 | docker login --username AWS --password-stdin 123456789012.dkr.ecr.us-west-2.amazonaws.com ``` -------------------------------- ### Architecture Diagram Source: https://github.com/localstack-dotnet/dotnet-aspire-for-localstack/blob/master/playground/lambda/README.md Visual representation of the URL Shortener service architecture, showing interactions between API Gateway, Lambda functions, DynamoDB, S3, and SQS. ```text β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” POST /shorten β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚ API Gateway β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β–Άβ”‚ ShortenFn β”‚ β”‚ Emulator β”‚ β”‚ (Lambda) β”‚ β””β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚ β”‚ write & analytics GET /{id} 302 β”‚ id β†’ URL β–Ό β–Ό β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” lookup id β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚ RedirectFn β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β–Άβ”‚ DynamoDB (Urls) β”‚ β”‚ (Lambda) β”‚ β”‚ (LocalStack) β”‚ β””β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚ 302 & analytics β–² β–² β”‚ β”‚ β”‚ presign β”‚ PNG bytes β”‚ β”‚ URL β–Ό β”‚ β”‚ User Browser ◀────── download β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ S3 bucket (LocalStack) Analytics Event Flow β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚ ShortenFn │──url_created──────▢│ β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚ SQS Queue β”‚ β”‚ (LocalStack)β”‚ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚ β”‚ β”‚ RedirectFn │──url_accessed─────▢│ β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”˜ β”‚ β”‚ SQS Event Source β–Ό β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚ AnalyzerFn β”‚ β”‚ (Lambda) β”‚ β””β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”˜ β”‚ write β–Ό β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚ DynamoDB β”‚ β”‚ (UrlAnalytics) β”‚ β”‚ (LocalStack) β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ ``` -------------------------------- ### Static Port Mapping Source: https://github.com/localstack-dotnet/dotnet-aspire-for-localstack/blob/master/docs/CONFIGURATION.md Explicitly specifying a port for the LocalStack container to ensure predictable endpoint URLs. ```csharp container.Port = 4566; // Always use port 4566 ``` -------------------------------- ### Custom Container Registry Configuration Source: https://github.com/localstack-dotnet/dotnet-aspire-for-localstack/blob/master/docs/CONFIGURATION.md Configuring the container registry, image path, and tag for pulling LocalStack images from custom locations. ```csharp builder.AddLocalStack(configureContainer: container => { container.ContainerRegistry = "artifactory.company.com"; // Where to pull from container.ContainerImage = "docker-mirrors/localstack/localstack"; // Image path container.ContainerImageTag = "4.10.0"; // Specific version }); ``` -------------------------------- ### AppHost Configuration with Auto-Configuration Source: https://github.com/localstack-dotnet/dotnet-aspire-for-localstack/blob/master/README.md Example of configuring LocalStack integration in an Aspire AppHost project using auto-configuration. ```csharp var builder = DistributedApplication.CreateBuilder(args); // 1. Set up AWS SDK configuration (optional) var awsConfig = builder.AddAWSSDKConfig() .WithProfile("default") .WithRegion(RegionEndpoint.USWest2); // 2. Add LocalStack container var localstack = builder .AddLocalStack(awsConfig: awsConfig, configureContainer: container => { container.Lifetime = ContainerLifetime.Session; container.DebugLevel = 1; container.LogLevel = LocalStackLogLevel.Debug; }); // 3. Add your AWS resources as usual var awsResources = builder.AddAWSCloudFormationTemplate("resources", "template.yaml") .WithReference(awsConfig); var project = builder.AddProject("api") .WithReference(awsResources); // 4. Auto-configure LocalStack for all AWS resources builder.UseLocalStack(localstack); builder.Build().Run(); ``` -------------------------------- ### Enterprise with Private Registry Configuration Source: https://github.com/localstack-dotnet/dotnet-aspire-for-localstack/blob/master/docs/CONFIGURATION.md Configuration for enterprise environments using a private container registry, specifying custom image, tag, and port. ```csharp builder.AddLocalStack(configureContainer: container => { // Pull from private Artifactory container.ContainerRegistry = "artifactory.company.com"; container.ContainerImage = "docker-local/localstack/localstack"; container.ContainerImageTag = "4.10.0"; container.Lifetime = ContainerLifetime.Persistent; container.LogLevel = LocalStackLogLevel.Warn; // Use static port for consistency with other tools container.Port = 4566; }); ``` -------------------------------- ### Debugging Configuration Source: https://github.com/localstack-dotnet/dotnet-aspire-for-localstack/blob/master/docs/CONFIGURATION.md Configuration tailored for debugging sessions, using default session lifetime, debug log level, and eager loading for startup issue visibility. ```csharp builder.AddLocalStack(configureContainer: container => { // Default Session lifetime - clean state for each debug session container.LogLevel = LocalStackLogLevel.Debug; container.DebugLevel = 1; // Use static port for easier debugging container.Port = 4566; // Eagerly load to see startup issues container.EagerLoadedServices = [AwsService.Sqs]; }); ``` -------------------------------- ### CLI Testing - Inspect URLs table Source: https://github.com/localstack-dotnet/dotnet-aspire-for-localstack/blob/master/playground/lambda/README.md AWS CLI command to scan the DynamoDB 'Urls' table using LocalStack endpoint. ```bash aws dynamodb scan --table-name Urls --endpoint-url {LOCALSTACK_ENDPOINT} --region eu-central-1 ``` -------------------------------- ### Port Conflict Resolution - Option 2: Switch to Session lifetime Source: https://github.com/localstack-dotnet/dotnet-aspire-for-localstack/blob/master/docs/CONFIGURATION.md Shows how to switch to Session lifetime for dynamic port assignment to avoid conflicts. ```csharp container.Lifetime = ContainerLifetime.Session; // Dynamic ports are used automatically when Lifetime = Session and Port is not set ``` -------------------------------- ### Container Configuration for LocalStack Source: https://github.com/localstack-dotnet/dotnet-aspire-for-localstack/blob/master/README.md Example of customizing LocalStack container behavior, including eager loading services and setting container lifetime. ```csharp builder.AddLocalStack(configureContainer: container => { // Eagerly load specific services for faster startup container.EagerLoadedServices = [AwsService.Sqs, AwsService.DynamoDB, AwsService.S3]; // Optional: Use Persistent lifetime for container reuse between runs // (Default is Session - container cleaned up when application stops) container.Lifetime = ContainerLifetime.Persistent; // Optional: Enable verbose logging for troubleshooting container.DebugLevel = 1; container.LogLevel = LocalStackLogLevel.Debug; // Optional: Use a specific port instead of dynamic port assignment container.Port = 4566; }); ``` -------------------------------- ### Enabling Verbose Logging for Health Checks Source: https://github.com/localstack-dotnet/dotnet-aspire-for-localstack/blob/master/docs/CONFIGURATION.md Configuration snippet to enable debug logging for troubleshooting failing container health checks. ```csharp container.DebugLevel = 1; container.LogLevel = LocalStackLogLevel.Debug; ``` -------------------------------- ### CLI Testing - Check analytics events Source: https://github.com/localstack-dotnet/dotnet-aspire-for-localstack/blob/master/playground/lambda/README.md AWS CLI command to scan the DynamoDB 'UrlAnalytics' table using LocalStack endpoint. ```bash aws dynamodb scan --table-name UrlAnalytics --endpoint-url {LOCALSTACK_ENDPOINT} --region eu-central-1 ``` -------------------------------- ### Advanced Environment Variables Source: https://github.com/localstack-dotnet/dotnet-aspire-for-localstack/blob/master/docs/CONFIGURATION.md Passes custom environment variables to the LocalStack container, useful for LocalStack Pro features or persistence configuration. ```csharp container.AdditionalEnvironmentVariables["LOCALSTACK_API_KEY"] = "your-pro-key"; container.AdditionalEnvironmentVariables["PERSISTENCE"] = "1"; ``` -------------------------------- ### Port Conflict Resolution - Option 1: Use a different static port Source: https://github.com/localstack-dotnet/dotnet-aspire-for-localstack/blob/master/docs/CONFIGURATION.md Demonstrates how to resolve port conflicts by assigning a different static port to the container. ```csharp container.Port = 4567; ``` -------------------------------- ### Enabling Docker Socket Access Source: https://github.com/localstack-dotnet/dotnet-aspire-for-localstack/blob/master/docs/CONFIGURATION.md Enables access to the host's Docker socket, which is required for LocalStack Lambda to create containers for function execution. ```csharp container.EnableDockerSocket = true; ``` -------------------------------- ### Add GitHub Packages source Source: https://github.com/localstack-dotnet/dotnet-aspire-for-localstack/blob/master/README.md Command to add the GitHub Packages source for LocalStack .NET development builds. ```bash # Add GitHub Packages source dotnet nuget add source https://nuget.pkg.github.com/localstack-dotnet/index.json \ --name github-localstack-for-aspire \ --username YOUR_GITHUB_USERNAME \ --password YOUR_GITHUB_TOKEN ``` -------------------------------- ### Client Configuration (Service Projects) Source: https://github.com/localstack-dotnet/dotnet-aspire-for-localstack/blob/master/README.md Configures AWS services in service projects using the LocalStack.NET Client. ```csharp var builder = WebApplication.CreateBuilder(args); // Add LocalStack configuration builder.Services.AddLocalStack(builder.Configuration); // Register AWS services - automatically configured for LocalStack when enabled builder.Services.AddAwsService(); builder.Services.AddAwsService(); builder.Services.AddAwsService(); var app = builder.Build(); ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.