CDKExtensions.WithReference<TDestination,TConstruct> Method

Definition

Adds a reference of an AWS CDK construct to a project.The output parameters of the construct are added to the project IConfiguration.

public static Aspire.Hosting.ApplicationModel.IResourceBuilder<TDestination> WithReference<TDestination,TConstruct> (this Aspire.Hosting.ApplicationModel.IResourceBuilder<TDestination> builder, Aspire.Hosting.ApplicationModel.IResourceBuilder<Aspire.Hosting.AWS.CDK.IResourceWithConstruct<TConstruct>> construct, Aspire.Hosting.AWS.CDK.ConstructOutputDelegate<TConstruct> outputDelegate, string outputName, string? configSection = default) where TDestination : Aspire.Hosting.ApplicationModel.IResourceWithEnvironment where TConstruct : Constructs.IConstruct;
static member WithReference : Aspire.Hosting.ApplicationModel.IResourceBuilder<'Destination (requires 'Destination :> Aspire.Hosting.ApplicationModel.IResourceWithEnvironment)> * Aspire.Hosting.ApplicationModel.IResourceBuilder<Aspire.Hosting.AWS.CDK.IResourceWithConstruct<'Construct>> * Aspire.Hosting.AWS.CDK.ConstructOutputDelegate<'Construct (requires 'Construct :> Constructs.IConstruct)> * string * string -> Aspire.Hosting.ApplicationModel.IResourceBuilder<'Destination (requires 'Destination :> Aspire.Hosting.ApplicationModel.IResourceWithEnvironment)> (requires 'Destination :> Aspire.Hosting.ApplicationModel.IResourceWithEnvironment and 'Construct :> Constructs.IConstruct)
<Extension()>
Public Function WithReference(Of TDestination As IResourceWithEnvironment, TConstruct As IResourceWithEnvironment) (builder As IResourceBuilder(Of TDestination), construct As IResourceBuilder(Of IResourceWithConstruct(Of TConstruct)), outputDelegate As ConstructOutputDelegate(Of TConstruct), outputName As String, Optional configSection As String = Nothing) As IResourceBuilder(Of TDestination)

Type Parameters

TDestination
TConstruct

Parameters

builder
IResourceBuilder<TDestination>

The builder for the resource.

construct
IResourceBuilder<IResourceWithConstruct<TConstruct>>

The construct resource.

outputDelegate
ConstructOutputDelegate<TConstruct>

The construct output delegate.

outputName
String

The name of the construct output

configSection
String

The optional config section in IConfiguration to add the output parameters.

Returns

IResourceBuilder<TDestination>

Examples

The following example shows creating a custom stack and reference the exposed ServiceUrl property in a project as configuration reference.

var stack = builder.AddAWSCDKStack("stack", scope => new Stack(scope, "Stack");
var api = builder.AddProject<Projects.Api>("api")
    .WithReference(stack, s => s.ServiceUrl, "ServiceUrl");

Applies to