-
Notifications
You must be signed in to change notification settings - Fork 941
Add AWS CDK support #2225
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
Add AWS CDK support #2225
Changes from 49 commits
Commits
Show all changes
57 commits
Select commit
Hold shift + click to select a range
b97fd81
Initial AWS CDK Support
a3ecee3
Add documentation and additional resources
6164785
Make properties optional
77d56cb
Add Amazon Kinesis streams
306e022
Merge branch 'main' into vlesierse/aws-cdk
756fea0
Add bucket notifications and topic subscriptions
be9136a
Adding this for extension methods
925b358
Fix await stack resource
vlesierse 6120522
Allow multiple reference to same construct resource
vlesierse 953c11e
Merge branch 'main' into vlesierse/aws-cdk
vlesierse e74cbf0
Refactoring after code review
f54ee37
Cleanup
4063577
Changes after code review
c606bb3
Provide guidance for missing CDK bootstrap
4cf0b37
Merge AWSCDK in AWS playground
4b6ae98
Merge branch 'main' into vlesierse/aws-cdk
98feb7e
Merge branch 'main' into vlesierse/aws-cdk
6ff3a61
Changes after code review
9668b80
Remove support restrictions
38433e6
Simplified construct/stack outputs
e691101
Include output changes
2b25719
Introduce new provisioners
9f71622
CloudFormation provisioners
vlesierse 2a4d1e9
Refactor CloudFormation executor
77ef4ec
Add AWS CDK Provisioning
vlesierse e7e50d5
Change manifest to include the right stack name
vlesierse bc5daa1
Fix manifest values
vlesierse 6850b46
Support dev environments with spaces
vlesierse 29cebe5
Add tests for CDK resources
95f55af
Add CDK documentation to README.md
9329a9c
Changes after code review
821a6cf
Changes after code review
910e762
Additional changes after code review
dd45fb9
Refactor and simplify CDK stack provisioning
98e94ba
Merge branch 'main' into vlesierse/aws-cdk
6ce231a
Remove AWSSDK SSO
4e9338a
Fix build
04f0571
Merge branch 'main' into vlesierse/aws-cdk
1dadf75
Changes after code review
8c961ec
Merge branch 'main' into vlesierse/aws-cdk
vlesierse 2667b19
Add missing merge changes
vlesierse a92f4fb
Fix AWSCloudFormationResourceTests
vlesierse 04b1b3c
Remove Aspire- prefix from AddAWSCloudFormationStack
vlesierse 3d6a837
Fix packages due to merge
vlesierse bb12ea2
Bump AWS CDK
vlesierse 54117f3
Temp solution to verify build
14dbaa6
Remove namespace for doc reference
vlesierse 2c91248
Ignore construct resource in manifest
vlesierse a2f2b55
Merge branch 'main' into vlesierse/aws-cdk
ddaaf90
Bump AWS CDK version & rename annotation
vlesierse 9255fba
Merge branch 'main' into vlesierse/aws-cdk
vlesierse a62a0bb
Remove nuget.org from config
vlesierse 2ab7de8
Merge branch 'main' into vlesierse/aws-cdk
f5fee89
Merge branch 'main' into vlesierse/aws-cdk
a125889
Bump AWS CDK to 2.158.0
1bbd536
Add RequiresTools to AWSCDK tests
5caa3a3
Mark active issue 4508
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
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,2 @@ | ||
| # AWS CDK | ||
| cdk.out |
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> | ||
| <NoWarn>$(NoWarn);CS8002</NoWarn> <!-- AWS CDK packages are not signed --> | ||
| </PropertyGroup> | ||
|
|
||
| <ItemGroup> | ||
| <Compile Include="..\..\KnownResourceNames.cs" Link="KnownResourceNames.cs" /> | ||
| </ItemGroup> | ||
|
|
||
| <ItemGroup> | ||
| <AspireProjectOrPackageReference Include="Aspire.Hosting.AWS" /> | ||
| <AspireProjectOrPackageReference Include="Aspire.Hosting.AppHost" /> | ||
|
|
||
| <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,21 @@ | ||
| // Licensed to the .NET Foundation under one or more agreements. | ||
| // The .NET Foundation licenses this file to you under the MIT license. | ||
|
|
||
| using Amazon.CDK; | ||
| using Amazon.CDK.AWS.S3; | ||
| using Constructs; | ||
|
|
||
| namespace AWSCDK.AppHost; | ||
|
|
||
| public class CustomStack : Stack | ||
| { | ||
|
|
||
| public IBucket Bucket { get; } | ||
|
|
||
| public CustomStack(Construct scope, string id) | ||
| : base(scope, id) | ||
| { | ||
| Bucket = new Bucket(this, "Bucket"); | ||
| } | ||
|
|
||
| } |
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 @@ | ||
| using Amazon; | ||
| using AWSCDK.AppHost; | ||
|
|
||
| var builder = DistributedApplication.CreateBuilder(args); | ||
|
|
||
| // Setup a configuration for the AWS .NET SDK. | ||
| var awsConfig = builder.AddAWSSDKConfig() | ||
| .WithProfile("default") | ||
| .WithRegion(RegionEndpoint.EUWest1); | ||
|
|
||
| var stack = builder.AddAWSCDKStack("stack", "Aspire-stack").WithReference(awsConfig); | ||
| var customStack = builder.AddAWSCDKStack("custom", scope => new CustomStack(scope, "Aspire-custom")); | ||
| customStack.AddOutput("BucketName", stack => stack.Bucket.BucketName).WithReference(awsConfig); | ||
|
|
||
| var topic = stack.AddSNSTopic("topic"); | ||
| var queue = stack.AddSQSQueue("queue"); | ||
| topic.AddSubscription(queue); | ||
|
|
||
| builder.AddProject<Projects.Frontend>("frontend") | ||
| //.WithReference(stack) // Reference all outputs of a construct | ||
| .WithEnvironment("AWS__Resources__BucketName", customStack.GetOutput("BucketName")) // Reference a construct/stack output | ||
| .WithEnvironment("AWS__Resources__ChatTopicArn", topic, t => t.TopicArn); | ||
|
|
||
| builder.Build().Run(); |
41 changes: 41 additions & 0 deletions
41
playground/AWS/AWSCDK.AppHost/Properties/launchSettings.json
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,41 @@ | ||
| { | ||
| "$schema": "http://json.schemastore.org/launchsettings.json", | ||
| "profiles": { | ||
| "https": { | ||
| "commandName": "Project", | ||
| "dotnetRunMessages": true, | ||
| "launchBrowser": true, | ||
| "applicationUrl": "https://localhost:15887;http://localhost:15888", | ||
| "environmentVariables": { | ||
| "ASPNETCORE_ENVIRONMENT": "Development", | ||
| "DOTNET_ENVIRONMENT": "Development", | ||
| "DOTNET_DASHBOARD_OTLP_ENDPOINT_URL": "http://localhost:16175", | ||
| "DOTNET_RESOURCE_SERVICE_ENDPOINT_URL": "https://localhost:17037" | ||
| } | ||
| }, | ||
| "http": { | ||
| "commandName": "Project", | ||
| "dotnetRunMessages": true, | ||
| "launchBrowser": true, | ||
| "applicationUrl": "http://localhost:15888", | ||
| "environmentVariables": { | ||
| "ASPNETCORE_ENVIRONMENT": "Development", | ||
| "DOTNET_ENVIRONMENT": "Development", | ||
| "DOTNET_DASHBOARD_OTLP_ENDPOINT_URL": "http://localhost:16175", | ||
| "DOTNET_RESOURCE_SERVICE_ENDPOINT_URL": "http://localhost:17038", | ||
| "ASPIRE_ALLOW_UNSECURED_TRANSPORT": "true" | ||
| } | ||
| }, | ||
| "generate-manifest": { | ||
| "commandName": "Project", | ||
| "commandLineArgs": "--publisher manifest --output-path ./aspire-manifest.json", | ||
| "dotnetRunMessages": true, | ||
| "applicationUrl": "http://localhost:15888", | ||
| "environmentVariables": { | ||
| "ASPNETCORE_ENVIRONMENT": "Development", | ||
| "DOTNET_ENVIRONMENT": "Development", | ||
| "DOTNET_DASHBOARD_OTLP_ENDPOINT_URL": "http://localhost:16175" | ||
| } | ||
| } | ||
| } | ||
| } |
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 @@ | ||
| // Licensed to the .NET Foundation under one or more agreements. | ||
| // The .NET Foundation licenses this file to you under the MIT license. | ||
|
|
||
| using Amazon.CDK; | ||
| using Amazon.CDK.AWS.DynamoDB; | ||
| using Constructs; | ||
| using Attribute = Amazon.CDK.AWS.DynamoDB.Attribute; | ||
|
|
||
| namespace AWSCDK.AppHost; | ||
|
|
||
| public class WebAppStackProps : StackProps; | ||
|
|
||
| public class WebAppStack : Stack | ||
| { | ||
| public ITable Table { get; } | ||
|
|
||
| public WebAppStack(Construct scope, string id, WebAppStackProps props) | ||
| : base(scope, id, props) | ||
| { | ||
| Table = new Table(this, "Table", new TableProps | ||
| { | ||
| PartitionKey = new Attribute { Name = "id", Type = AttributeType.STRING }, | ||
| BillingMode = BillingMode.PAY_PER_REQUEST | ||
| }); | ||
| } | ||
| } |
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,50 @@ | ||
| { | ||
| "$schema": "https://json.schemastore.org/aspire-8.0.json", | ||
| "resources": { | ||
| "stack": { | ||
| "type": "aws.cloudformation.template.v0", | ||
| "stack-name": "Aspire-stack", | ||
| "template-path": "cdk.out/Aspire-stack.template.json", | ||
| "references": [ | ||
| { | ||
| "target-resource": "frontend" | ||
| } | ||
| ] | ||
| }, | ||
| "custom": { | ||
| "type": "aws.cloudformation.template.v0", | ||
| "stack-name": "Aspire-custom", | ||
| "template-path": "cdk.out/Aspire-custom.template.json", | ||
| "references": [ | ||
| { | ||
| "target-resource": "frontend" | ||
| } | ||
| ] | ||
| }, | ||
| "frontend": { | ||
| "type": "project.v0", | ||
| "path": "../Frontend/Frontend.csproj", | ||
| "env": { | ||
| "OTEL_DOTNET_EXPERIMENTAL_OTLP_EMIT_EXCEPTION_LOG_ATTRIBUTES": "true", | ||
| "OTEL_DOTNET_EXPERIMENTAL_OTLP_EMIT_EVENT_LOG_ATTRIBUTES": "true", | ||
| "OTEL_DOTNET_EXPERIMENTAL_OTLP_RETRY": "in_memory", | ||
| "ASPNETCORE_FORWARDEDHEADERS_ENABLED": "true", | ||
| "HTTP_PORTS": "{frontend.bindings.http.targetPort}", | ||
| "AWS__Resources__BucketName": "{custom.output.BucketName}", | ||
| "AWS__Resources__ChatTopicArn": "{stack.output.topic8C050C71AWSResourcesChatTopicArn}" | ||
| }, | ||
| "bindings": { | ||
| "http": { | ||
| "scheme": "http", | ||
| "protocol": "tcp", | ||
| "transport": "http" | ||
| }, | ||
| "https": { | ||
| "scheme": "https", | ||
| "protocol": "tcp", | ||
| "transport": "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,63 @@ | ||
| { | ||
| "app": "dotnet run -- --publisher manifest --output-path ./aspire-manifest.json", | ||
| "watch": { | ||
| "include": [ | ||
| "**" | ||
| ], | ||
| "exclude": [ | ||
| "README.md", | ||
| "cdk*.json", | ||
| "src/*/obj", | ||
| "src/*/bin", | ||
| "src/*.sln", | ||
| "src/*/GlobalSuppressions.cs", | ||
| "src/*/*.csproj" | ||
| ] | ||
| }, | ||
| "context": { | ||
| "@aws-cdk/aws-lambda:recognizeLayerVersion": true, | ||
| "@aws-cdk/core:checkSecretUsage": true, | ||
| "@aws-cdk/core:target-partitions": [ | ||
| "aws", | ||
| "aws-cn" | ||
| ], | ||
| "@aws-cdk-containers/ecs-service-extensions:enableDefaultLogDriver": true, | ||
| "@aws-cdk/aws-ec2:uniqueImdsv2TemplateName": true, | ||
| "@aws-cdk/aws-ecs:arnFormatIncludesClusterName": true, | ||
| "@aws-cdk/aws-iam:minimizePolicies": true, | ||
| "@aws-cdk/core:validateSnapshotRemovalPolicy": true, | ||
| "@aws-cdk/aws-codepipeline:crossAccountKeyAliasStackSafeResourceName": true, | ||
| "@aws-cdk/aws-s3:createDefaultLoggingPolicy": true, | ||
| "@aws-cdk/aws-sns-subscriptions:restrictSqsDescryption": true, | ||
| "@aws-cdk/aws-apigateway:disableCloudWatchRole": true, | ||
| "@aws-cdk/core:enablePartitionLiterals": true, | ||
| "@aws-cdk/aws-events:eventsTargetQueueSameAccount": true, | ||
| "@aws-cdk/aws-iam:standardizedServicePrincipals": true, | ||
| "@aws-cdk/aws-ecs:disableExplicitDeploymentControllerForCircuitBreaker": true, | ||
| "@aws-cdk/aws-iam:importedRoleStackSafeDefaultPolicyName": true, | ||
| "@aws-cdk/aws-s3:serverAccessLogsUseBucketPolicy": true, | ||
| "@aws-cdk/aws-route53-patters:useCertificate": true, | ||
| "@aws-cdk/customresources:installLatestAwsSdkDefault": false, | ||
| "@aws-cdk/aws-rds:databaseProxyUniqueResourceName": true, | ||
| "@aws-cdk/aws-codedeploy:removeAlarmsFromDeploymentGroup": true, | ||
| "@aws-cdk/aws-apigateway:authorizerChangeDeploymentLogicalId": true, | ||
| "@aws-cdk/aws-ec2:launchTemplateDefaultUserData": true, | ||
| "@aws-cdk/aws-secretsmanager:useAttachedSecretResourcePolicyForSecretTargetAttachments": true, | ||
| "@aws-cdk/aws-redshift:columnId": true, | ||
| "@aws-cdk/aws-stepfunctions-tasks:enableEmrServicePolicyV2": true, | ||
| "@aws-cdk/aws-ec2:restrictDefaultSecurityGroup": true, | ||
| "@aws-cdk/aws-apigateway:requestValidatorUniqueId": true, | ||
| "@aws-cdk/aws-kms:aliasNameRef": true, | ||
| "@aws-cdk/aws-autoscaling:generateLaunchTemplateInsteadOfLaunchConfig": true, | ||
| "@aws-cdk/core:includePrefixInUniqueNameGeneration": true, | ||
| "@aws-cdk/aws-efs:denyAnonymousAccess": true, | ||
| "@aws-cdk/aws-opensearchservice:enableOpensearchMultiAzWithStandby": true, | ||
| "@aws-cdk/aws-lambda-nodejs:useLatestRuntimeVersion": true, | ||
| "@aws-cdk/aws-efs:mountTargetOrderInsensitiveLogicalId": true, | ||
| "@aws-cdk/aws-rds:auroraClusterChangeScopeOfInstanceParameterGroupWithEachParameters": true, | ||
| "@aws-cdk/aws-appsync:useArnForSourceApiAssociationIdentifier": true, | ||
| "@aws-cdk/aws-rds:preventRenderingDeprecatedCredentials": true, | ||
| "@aws-cdk/aws-codepipeline-actions:useNewDefaultBranchForCodeCommitSource": true, | ||
| "@aws-cdk/aws-cloudwatch-actions:changeLambdaPermissionLogicalIdForLambdaAction": true | ||
| } | ||
| } |
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.
❗ We can't pull packages from nuget.org.
This will have to be removed before this PR can get merged.