# CDKExtensions Methods

- Package: [Aspire.Hosting.AWS](/reference/api/csharp/aspire.hosting.aws.md)
- Type: [CDKExtensions](/reference/api/csharp/aspire.hosting.aws/cdkextensions.md)
- Kind: `Methods`
- Members: `9`

Supports all classes in the .NET class hierarchy and provides low-level services to derived classes. This is the ultimate base class of all .NET classes; it is the root of the type hierarchy.

## AddAWSCDKStack(IDistributedApplicationBuilder, string)

- Name: `AddAWSCDKStack(IDistributedApplicationBuilder, string)`
- Modifiers: `extension`
- Returns: `IResourceBuilder<IStackResource>`

```csharp
public static class CDKExtensions
{
    public static IResourceBuilder<IStackResource> AddAWSCDKStack(
        this IDistributedApplicationBuilder builder,
        string name)
    {
        // ...
    }
}
```

## Parameters

- `builder` (`IDistributedApplicationBuilder`)
- `name` (`string`)

## AddAWSCDKStack(IDistributedApplicationBuilder, string, string)

- Name: `AddAWSCDKStack(IDistributedApplicationBuilder, string, string)`
- Modifiers: `extension`
- Returns: `IResourceBuilder<IStackResource>`

```csharp
public static class CDKExtensions
{
    public static IResourceBuilder<IStackResource> AddAWSCDKStack(
        this IDistributedApplicationBuilder builder,
        string name,
        string stackName)
    {
        // ...
    }
}
```

## Parameters

- `builder` (`IDistributedApplicationBuilder`)
- `name` (`string`)
- `stackName` (`string`)

## AddAWSCDKStack(IDistributedApplicationBuilder, string, ConstructBuilderDelegate<T>)

- Name: `AddAWSCDKStack(IDistributedApplicationBuilder, string, ConstructBuilderDelegate<T>)`
- Modifiers: `extension`
- Returns: `IResourceBuilder<IStackResource<T>>`

```csharp
public static class CDKExtensions
{
    public static IResourceBuilder<IStackResource<T>> AddAWSCDKStack<T>(
        this IDistributedApplicationBuilder builder,
        string name,
        ConstructBuilderDelegate<T> stackBuilder)
    {
        // ...
    }
}
```

## Parameters

- `builder` (`IDistributedApplicationBuilder`)
- `name` (`string`)
- `stackBuilder` ([ConstructBuilderDelegate<T>](/reference/api/csharp/aspire.hosting.aws/constructbuilderdelegate-1.md))

## AddConstruct(IResourceBuilder<IResourceWithConstruct>, string, ConstructBuilderDelegate<T>)

- Name: `AddConstruct(IResourceBuilder<IResourceWithConstruct>, string, ConstructBuilderDelegate<T>)`
- Modifiers: `extension`
- Returns: `IResourceBuilder<IConstructResource<T>>`

```csharp
public static class CDKExtensions
{
    public static IResourceBuilder<IConstructResource<T>> AddConstruct<T>(
        this IResourceBuilder<IResourceWithConstruct> builder,
        string name,
        ConstructBuilderDelegate<T> constructBuilder)
    {
        // ...
    }
}
```

## Parameters

- `builder` (`IResourceBuilder<IResourceWithConstruct>`)
- `name` (`string`)
- `constructBuilder` ([ConstructBuilderDelegate<T>](/reference/api/csharp/aspire.hosting.aws/constructbuilderdelegate-1.md))

## AddOutput(IResourceBuilder<IStackResource<TStack>>, string, ConstructOutputDelegate<TStack>)

- Name: `AddOutput(IResourceBuilder<IStackResource<TStack>>, string, ConstructOutputDelegate<TStack>)`
- Modifiers: `extension`
- Returns: `IResourceBuilder<IStackResource<TStack>>`

```csharp
public static class CDKExtensions
{
    public static IResourceBuilder<IStackResource<TStack>> AddOutput<TStack>(
        this IResourceBuilder<IStackResource<TStack>> builder,
        string name,
        ConstructOutputDelegate<TStack> output)
    {
        // ...
    }
}
```

## Parameters

- `builder` (`IResourceBuilder<IStackResource<TStack>>`)
- `name` (`string`)
- `output` (`ConstructOutputDelegate<TStack>`)

## AddOutput(IResourceBuilder<IConstructResource<T>>, string, ConstructOutputDelegate<T>)

- Name: `AddOutput(IResourceBuilder<IConstructResource<T>>, string, ConstructOutputDelegate<T>)`
- Modifiers: `extension`
- Returns: `IResourceBuilder<IConstructResource<T>>`

```csharp
public static class CDKExtensions
{
    public static IResourceBuilder<IConstructResource<T>> AddOutput<T>(
        this IResourceBuilder<IConstructResource<T>> builder,
        string name,
        ConstructOutputDelegate<T> output)
    {
        // ...
    }
}
```

## Parameters

- `builder` (`IResourceBuilder<IConstructResource<T>>`)
- `name` (`string`)
- `output` ([ConstructOutputDelegate<T>](/reference/api/csharp/aspire.hosting.aws/constructoutputdelegate-1.md))

## GetOutput(IResourceBuilder<IConstructResource<T>>, string, ConstructOutputDelegate<T>)

- Name: `GetOutput(IResourceBuilder<IConstructResource<T>>, string, ConstructOutputDelegate<T>)`
- Modifiers: `extension`
- Returns: [StackOutputReference](/reference/api/csharp/aspire.hosting.aws/stackoutputreference.md)

```csharp
public static class CDKExtensions
{
    public static StackOutputReference GetOutput<T>(
        this IResourceBuilder<IConstructResource<T>> builder,
        string name,
        ConstructOutputDelegate<T> output)
    {
        // ...
    }
}
```

## Parameters

- `builder` (`IResourceBuilder<IConstructResource<T>>`)
- `name` (`string`)
- `output` ([ConstructOutputDelegate<T>](/reference/api/csharp/aspire.hosting.aws/constructoutputdelegate-1.md))

## WithEnvironment(IResourceBuilder<TDestination>, string, IResourceBuilder<IResourceWithConstruct<TConstruct>>, ConstructOutputDelegate<TConstruct>, string?)

- Name: `WithEnvironment(IResourceBuilder<TDestination>, string, IResourceBuilder<IResourceWithConstruct<TConstruct>>, ConstructOutputDelegate<TConstruct>, string?)`
- Modifiers: `extension`
- Returns: `IResourceBuilder<TDestination>`

```csharp
public static class CDKExtensions
{
    public static IResourceBuilder<TDestination> WithEnvironment<TDestination, TConstruct>(
        this IResourceBuilder<TDestination> builder,
        string name,
        IResourceBuilder<IResourceWithConstruct<TConstruct>> construct,
        ConstructOutputDelegate<TConstruct> outputDelegate,
        string? outputName = null)
    {
        // ...
    }
}
```

## Parameters

- `builder` (`IResourceBuilder<TDestination>`)
- `name` (`string`)
- `construct` (`IResourceBuilder<IResourceWithConstruct<TConstruct>>`)
- `outputDelegate` (`ConstructOutputDelegate<TConstruct>`)
- `outputName` (`string?`) `optional`

## WithReference(IResourceBuilder<TDestination>, IResourceBuilder<IResourceWithConstruct<TConstruct>>, ConstructOutputDelegate<TConstruct>, string, string?)

- Name: `WithReference(IResourceBuilder<TDestination>, IResourceBuilder<IResourceWithConstruct<TConstruct>>, ConstructOutputDelegate<TConstruct>, string, string?)`
- Modifiers: `extension`
- Returns: `IResourceBuilder<TDestination>`

```csharp
public static class CDKExtensions
{
    public static IResourceBuilder<TDestination> WithReference<TDestination, TConstruct>(
        this IResourceBuilder<TDestination> builder,
        IResourceBuilder<IResourceWithConstruct<TConstruct>> construct,
        ConstructOutputDelegate<TConstruct> outputDelegate,
        string outputName,
        string? configSection = null)
    {
        // ...
    }
}
```

## Parameters

- `builder` (`IResourceBuilder<TDestination>`)
- `construct` (`IResourceBuilder<IResourceWithConstruct<TConstruct>>`)
- `outputDelegate` (`ConstructOutputDelegate<TConstruct>`)
- `outputName` (`string`)
- `configSection` (`string?`) `optional`
