-
Notifications
You must be signed in to change notification settings - Fork 926
Add AWS CloudFormation Provisioning and SDK Configuration #1905
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 15 commits
Commits
Show all changes
53 commits
Select commit
Hold shift + click to select a range
b79ba3f
Add CloudFormation provisioner
normj 61ea393
Combine work to AWS.Hosting.AWS project
normj c4724b9
Add ability to configure the CloudFormation service client used for p…
normj bc5cbac
Add methods to configure service clients
normj 1b3af50
Fix AWS Blazor sample app to enable InteractiveServer
normj 839a68a
Rework SDK configuration as an IAWSSDKConfigResource
normj e1fc1cb
Merge branch 'main' into normj/aws-provisioning
normj 708c32e
Rework AWS sample application to display the configuration applied fr…
normj 3a9159b
Add the AWS .NET SDK OTel provider
normj 56c12f7
Add more comments about what is going on in AppHost
normj a21c441
Add missing AddAWSService call for SNS
normj ff67ca4
Fail CloudFormation provisioning of stack is already in an "in progre…
normj 88bbe5b
Minor cleanup
normj 162b3bf
Fix whitespace
normj 7a1c8f9
Move AWS sample to playground
normj 73b6761
Address some of the PR comments.
normj 53494e5
Address PR comments
normj 12468ae
Add support for importing existing AWS resources using the AddAWSClou…
normj b8a5e7e
Merge branch 'main' into normj/aws-provisioning
normj ee17fa2
Fix after latest merge from main
normj 411d32a
Add CloudFormation to manifest
normj 46e4917
Add ability to set input parameters to CloudFormation template
normj b28f102
Lifecycle skips work if publishing manifest
normj dd93d1f
Add "aws." prefix to the AWS resources in the manifest
normj f9093ab
Rename WithParameter to AddParameter
normj f67fb5f
Merge branch 'main' into normj/aws-provisioning
normj c9f4744
Fixes after merging preview 4
normj b72ea36
Merge branch 'main' into normj/aws-provisioning
normj 21b0f89
Publish logs and state to dashboard while doing CLoudFormation provis…
normj 0b39eea
Block projects from starting till CloudFormation is done.
normj 5198bcc
Fix issue with resource state being set for the initial state.
normj 40a590d
Switch to use update state instead of replace state pattern.
normj 46ec9d1
Ran VS code cleanup to clean up the formatting
normj 106f5a1
Add logging message when project is waiting on CloudFormation stack.
normj a316cf7
Set source property for resource dashboard
normj 8f242c4
Add ability to bind a single output variable to a project.
normj 9c1756b
Fix source not being set when using AddAWSCloudFormationStack for bin…
normj 4cc515a
Delete orphaned files
normj 2ecd5ba
Merge branch 'main' into normj/aws-provisioning
normj b8dc8d3
Clean up adding manifest callbacks and rename AddParameter to WithPar…
normj e4cd5bb
Address some CR comments
normj 8e33322
Replace the CloudFormation reference resource with an Annotation
normj dae3f4a
Add SDK configuration
normj b3470f1
Merge branch 'main' into normj/aws-provisioning
normj 2ef50f1
Refactor the logic for making the provisioning calls to CloudFormation.
normj 79f6f6b
Update project description and package tags
normj dc4cf58
Add unit tests
normj e2947f8
Test cleanup
normj ba86f69
Update the AWS dependencies in the Directory.Packages.props
normj 39907b5
Remove unnecessary Prometheus dependency
eerhardt 3492fcd
Merge remote-tracking branch 'upstream/main' into normj/aws-provisioning
eerhardt 9ac29a0
Fix build for latest code.
eerhardt eaea240
Fix AWS tests
normj File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| <Project Sdk="Microsoft.NET.Sdk"> | ||
|
|
||
| <PropertyGroup> | ||
| <OutputType>Exe</OutputType> | ||
| <TargetFramework>net8.0</TargetFramework> | ||
| <ImplicitUsings>enable</ImplicitUsings> | ||
| <Nullable>enable</Nullable> | ||
| <IsAspireHost>true</IsAspireHost> | ||
| </PropertyGroup> | ||
|
|
||
| <ItemGroup> | ||
| <Compile Include="..\..\..\src\Aspire.Hosting\Utils\KnownResourceNames.cs" Link="KnownResourceNames.cs" /> | ||
| </ItemGroup> | ||
|
|
||
| <ItemGroup> | ||
| <ProjectReference Include="..\..\..\src\Aspire.Dashboard\Aspire.Dashboard.csproj" /> | ||
| <ProjectReference Include="..\..\..\src\Aspire.Hosting.AWS\Aspire.Hosting.AWS.csproj" IsAspireProjectResource="false" /> | ||
| <ProjectReference Include="..\..\..\src\Aspire.Hosting\Aspire.Hosting.csproj" IsAspireProjectResource="false" /> | ||
|
|
||
| <ProjectReference Include="..\Frontend\Frontend.csproj" /> | ||
| </ItemGroup> | ||
|
|
||
| </Project> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| <Project> | ||
|
|
||
| <Import Project="$([MSBuild]::GetPathOfFileAbove('Directory.Build.props', '$(MSBuildThisFileDirectory)../'))" /> | ||
|
|
||
| <!-- NOTE: This line is only required because we are using P2P references, not NuGet. It will not exist in real apps. --> | ||
| <Import Project="../../../src/Aspire.Hosting/build/Aspire.Hosting.props" /> | ||
|
|
||
| </Project> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| <Project> | ||
|
|
||
| <Import Project="$([MSBuild]::GetPathOfFileAbove('Directory.Build.targets', '$(MSBuildThisFileDirectory)../'))" /> | ||
|
|
||
| <!-- NOTE: These lines are only required because we are using P2P references, not NuGet. They will not exist in real apps. --> | ||
| <Import Project="..\..\..\src\Aspire.Hosting\build\Aspire.Hosting.targets" /> | ||
| <Import Project="..\..\..\src\Aspire.Hosting.Sdk\SDK\Sdk.targets" /> | ||
|
|
||
| </Project> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| // Licensed to the .NET Foundation under one or more agreements. | ||
| // The .NET Foundation licenses this file to you under the MIT license. | ||
| using Amazon; | ||
|
|
||
| var builder = DistributedApplication.CreateBuilder(args); | ||
|
|
||
| // Setup a configuration for the AWS .NET SDK. | ||
| var awsConfig = builder.AddAWSSDKConfig("frontend-aws-config") | ||
| .WithProfile("default") | ||
| .WithRegion(RegionEndpoint.USEast2); | ||
|
|
||
| // Provision application level resources like SQS queues and SNS topics defined in the CloudFormation template file app-resources.template. | ||
| var awsResources = builder.AddAWSCloudFormationProvisioning("AspireSampleDevResources", "app-resources.template") | ||
| // Add the SDK configuration so the AppHost knows what account/region to provision the resources. | ||
| .WithAWSSDKReference(awsConfig); | ||
|
|
||
| builder.AddProject<Projects.Frontend>("frontend") | ||
| // Reference the CloudFormation resource to project. The output parameters will added to the IConfiguration of the project. | ||
| .WithAWSCloudFormationReference(awsResources) | ||
| // Assign the SDK config to the project. The service clients created in the project relying on environment config | ||
| // will pick up these configuration. | ||
| .WithAWSSDKReference(awsConfig); | ||
|
|
||
| builder.Build().Run(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| { | ||
| "$schema": "http://json.schemastore.org/launchsettings.json", | ||
| "profiles": { | ||
| "http": { | ||
| "commandName": "Project", | ||
| "dotnetRunMessages": true, | ||
| "launchBrowser": true, | ||
| "applicationUrl": "http://localhost:15069", | ||
| "environmentVariables": { | ||
| "ASPNETCORE_ENVIRONMENT": "Development", | ||
| "DOTNET_ENVIRONMENT": "Development", | ||
| "DOTNET_DASHBOARD_OTLP_ENDPOINT_URL": "http://localhost:16216" | ||
| } | ||
| } | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| { | ||
| "AWSTemplateFormatVersion" : "2010-09-09", | ||
| "Resources" : { | ||
| "ChatMessagesQueue" : { | ||
| "Type" : "AWS::SQS::Queue", | ||
| "Properties" : { | ||
| } | ||
| }, | ||
| "ChatTopic" : { | ||
| "Type" : "AWS::SNS::Topic", | ||
| "Properties" : { | ||
| "Subscription" : [ | ||
| {"Protocol" : "sqs", "Endpoint" : {"Fn::GetAtt" : [ "ChatMessagesQueue", "Arn"]}} | ||
| ] | ||
| } | ||
| } | ||
| }, | ||
| "Outputs" : { | ||
| "ChatMessagesQueueUrl" : { | ||
| "Value" : { "Ref" : "ChatMessagesQueue" } | ||
| }, | ||
| "ChatTopicArn" : { | ||
| "Value" : { "Ref" : "ChatTopic" } | ||
| } | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| { | ||
| "Logging": { | ||
| "LogLevel": { | ||
| "Default": "Information", | ||
| "Microsoft.AspNetCore": "Warning", | ||
| "Aspire.Hosting.Dcp": "Warning" | ||
| } | ||
| } | ||
| } |
29 changes: 29 additions & 0 deletions
29
playground/AWS/AWS.ServiceDefaults/AWS.ServiceDefaults.csproj
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| <Project Sdk="Microsoft.NET.Sdk"> | ||
|
|
||
| <PropertyGroup> | ||
| <OutputType>Library</OutputType> | ||
| <TargetFramework>net8.0</TargetFramework> | ||
| </PropertyGroup> | ||
|
|
||
| <ItemGroup> | ||
| <FrameworkReference Include="Microsoft.AspNetCore.App" /> | ||
|
|
||
| <PackageReference Include="OpenTelemetry.Exporter.OpenTelemetryProtocol" /> | ||
| <PackageReference Include="OpenTelemetry.Exporter.Prometheus.AspNetCore" /> | ||
| <PackageReference Include="OpenTelemetry.Extensions.Hosting" /> | ||
| <PackageReference Include="OpenTelemetry.Instrumentation.AspNetCore" /> | ||
| <PackageReference Include="OpenTelemetry.Instrumentation.GrpcNetClient" /> | ||
| <PackageReference Include="OpenTelemetry.Instrumentation.Http" /> | ||
| <PackageReference Include="OpenTelemetry.Instrumentation.Runtime" /> | ||
|
|
||
| <PackageReference Include="Microsoft.Extensions.Http.Resilience" /> | ||
|
|
||
| <PackageReference Include="OpenTelemetry.Instrumentation.AWS" /> | ||
| </ItemGroup> | ||
|
|
||
| <ItemGroup> | ||
| <ProjectReference Include="..\..\..\src\Microsoft.Extensions.ServiceDiscovery.Dns\Microsoft.Extensions.ServiceDiscovery.Dns.csproj" /> | ||
| <ProjectReference Include="..\..\..\src\Microsoft.Extensions.ServiceDiscovery\Microsoft.Extensions.ServiceDiscovery.csproj" /> | ||
| </ItemGroup> | ||
|
|
||
| </Project> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,125 @@ | ||
| // Licensed to the .NET Foundation under one or more agreements. | ||
| // The .NET Foundation licenses this file to you under the MIT license. | ||
|
|
||
| using Microsoft.AspNetCore.Builder; | ||
| using Microsoft.AspNetCore.Diagnostics.HealthChecks; | ||
| using Microsoft.Extensions.DependencyInjection; | ||
| using Microsoft.Extensions.Diagnostics.HealthChecks; | ||
| using Microsoft.Extensions.Logging; | ||
| using OpenTelemetry.Logs; | ||
| using OpenTelemetry.Metrics; | ||
| using OpenTelemetry.Trace; | ||
|
|
||
| namespace Microsoft.Extensions.Hosting; | ||
|
|
||
| public static class Extensions | ||
| { | ||
| public static IHostApplicationBuilder AddServiceDefaults(this IHostApplicationBuilder builder) | ||
| { | ||
| builder.ConfigureOpenTelemetry(); | ||
|
|
||
| builder.AddDefaultHealthChecks(); | ||
|
|
||
| builder.Services.AddServiceDiscovery(); | ||
|
|
||
| builder.Services.ConfigureHttpClientDefaults(http => | ||
| { | ||
| // Turn on resilience by default | ||
| http.AddStandardResilienceHandler(); | ||
|
|
||
| // Turn on service discovery by default | ||
| http.UseServiceDiscovery(); | ||
| }); | ||
|
|
||
| return builder; | ||
| } | ||
|
|
||
| public static IHostApplicationBuilder ConfigureOpenTelemetry(this IHostApplicationBuilder builder) | ||
| { | ||
| builder.Logging.AddOpenTelemetry(logging => | ||
| { | ||
| logging.IncludeFormattedMessage = true; | ||
| logging.IncludeScopes = true; | ||
| }); | ||
|
|
||
| builder.Services.AddOpenTelemetry() | ||
| .WithMetrics(metrics => | ||
| { | ||
| metrics.AddRuntimeInstrumentation() | ||
| .AddBuiltInMeters(); | ||
| }) | ||
| .WithTracing(tracing => | ||
| { | ||
| if (builder.Environment.IsDevelopment()) | ||
| { | ||
| // We want to view all traces in development | ||
| tracing.SetSampler(new AlwaysOnSampler()); | ||
| } | ||
|
|
||
| tracing.AddAspNetCoreInstrumentation() | ||
| .AddGrpcClientInstrumentation() | ||
| .AddHttpClientInstrumentation() | ||
|
|
||
| // Add instrumentation for the AWS .NET SDK. | ||
| .AddAWSInstrumentation(); | ||
| }); | ||
|
|
||
| builder.AddOpenTelemetryExporters(); | ||
|
|
||
| return builder; | ||
| } | ||
|
|
||
| private static IHostApplicationBuilder AddOpenTelemetryExporters(this IHostApplicationBuilder builder) | ||
| { | ||
| var useOtlpExporter = !string.IsNullOrWhiteSpace(builder.Configuration["OTEL_EXPORTER_OTLP_ENDPOINT"]); | ||
|
|
||
| if (useOtlpExporter) | ||
| { | ||
| builder.Services.Configure<OpenTelemetryLoggerOptions>(logging => logging.AddOtlpExporter()); | ||
| builder.Services.ConfigureOpenTelemetryMeterProvider(metrics => metrics.AddOtlpExporter()); | ||
| builder.Services.ConfigureOpenTelemetryTracerProvider(tracing => tracing.AddOtlpExporter()); | ||
| } | ||
|
|
||
| // Uncomment the following lines to enable the Prometheus exporter (requires the OpenTelemetry.Exporter.Prometheus.AspNetCore package) | ||
| // builder.Services.AddOpenTelemetry() | ||
| // .WithMetrics(metrics => metrics.AddPrometheusExporter()); | ||
|
|
||
| // Uncomment the following lines to enable the Azure Monitor exporter (requires the Azure.Monitor.OpenTelemetry.Exporter package) | ||
| // builder.Services.AddOpenTelemetry() | ||
| // .UseAzureMonitor(); | ||
|
|
||
| return builder; | ||
| } | ||
|
|
||
| public static IHostApplicationBuilder AddDefaultHealthChecks(this IHostApplicationBuilder builder) | ||
| { | ||
| builder.Services.AddHealthChecks() | ||
| // Add a default liveness check to ensure app is responsive | ||
| .AddCheck("self", () => HealthCheckResult.Healthy(), ["live"]); | ||
|
|
||
| return builder; | ||
| } | ||
|
|
||
| public static WebApplication MapDefaultEndpoints(this WebApplication app) | ||
| { | ||
| // Uncomment the following line to enable the Prometheus endpoint (requires the OpenTelemetry.Exporter.Prometheus.AspNetCore package) | ||
| // app.MapPrometheusScrapingEndpoint(); | ||
|
|
||
| // All health checks must pass for app to be considered ready to accept traffic after starting | ||
| app.MapHealthChecks("/health"); | ||
|
|
||
| // Only health checks tagged with the "live" tag must pass for app to be considered alive | ||
| app.MapHealthChecks("/alive", new HealthCheckOptions | ||
| { | ||
| Predicate = r => r.Tags.Contains("live") | ||
| }); | ||
|
|
||
| return app; | ||
| } | ||
|
|
||
| private static MeterProviderBuilder AddBuiltInMeters(this MeterProviderBuilder meterProviderBuilder) => | ||
| meterProviderBuilder.AddMeter( | ||
| "Microsoft.AspNetCore.Hosting", | ||
| "Microsoft.AspNetCore.Server.Kestrel", | ||
| "System.Net.Http"); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| <!DOCTYPE html> | ||
| <html lang="en"> | ||
|
|
||
| <head> | ||
| <meta charset="utf-8" /> | ||
| <meta name="viewport" content="width=device-width, initial-scale=1.0" /> | ||
| <base href="/" /> | ||
| <link rel="stylesheet" href="bootstrap/bootstrap.min.css" /> | ||
| <link rel="stylesheet" href="app.css" /> | ||
| <link rel="stylesheet" href="Frontend.styles.css" /> | ||
| <link rel="icon" type="image/png" href="favicon.png" /> | ||
| <HeadOutlet /> | ||
| </head> | ||
|
|
||
| <body> | ||
| <Routes @rendermode="@InteractiveServer" /> | ||
| <script src="_framework/blazor.web.js"></script> | ||
| </body> | ||
|
|
||
| </html> |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be great to get these packages added to the Aspire NuGet feeds. Some of these are newer versions of packages that are already in there. Currently I'm testing with hacking the
NuGet.configto allow the public NuGet feed.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are these the versions you need?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would it be possible to use the "hack" while the PR was in draft, and adding more dependencies? (and possibly updating new versions that are released). Then once the PR is ready for review, we can revert the nuget.config change, and mirror the necessary packages to the trusted feed.