# AlternateTargetOptions

Options for AlternateTarget configuration.

- Source: [`aws-ecs/lib/alternate-target-configuration.ts`](https://github.com/aws/aws-cdk/blob/v2.278.0/packages/aws-cdk-lib/aws-ecs/lib/alternate-target-configuration.ts#L94)
- Type last changed: v2.211.0 · 13 Aug 2025

## Example

TypeScript:

```ts
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
import { aws_ecs as ecs } from 'aws-cdk-lib';
import { aws_iam as iam } from 'aws-cdk-lib';

declare const listenerRuleConfiguration: ecs.ListenerRuleConfiguration;
declare const role: iam.Role;
const alternateTargetOptions: ecs.AlternateTargetOptions = {
  role: role,
  testListener: listenerRuleConfiguration,
};
```

Python:

```python
# The code below shows an example of how to instantiate this type.
# The values are placeholders you should change.
from aws_cdk import aws_ecs as ecs
from aws_cdk import aws_iam as iam

# listener_rule_configuration: ecs.ListenerRuleConfiguration
# role: iam.Role

alternate_target_options = ecs.AlternateTargetOptions(
    role=role,
    test_listener=listener_rule_configuration
)
```

Java:

```java
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
import software.amazon.awscdk.services.ecs.*;
import software.amazon.awscdk.services.iam.*;

ListenerRuleConfiguration listenerRuleConfiguration;
Role role;

AlternateTargetOptions alternateTargetOptions = AlternateTargetOptions.builder()
        .role(role)
        .testListener(listenerRuleConfiguration)
        .build();
```

C# / .NET:

```csharp
// Install: dotnet add package Amazon.CDK.Lib
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
using Amazon.CDK.AWS.ECS;
using Amazon.CDK.AWS.IAM;

ListenerRuleConfiguration listenerRuleConfiguration;
Role role;

var alternateTargetOptions = new AlternateTargetOptions {
    Role = role,
    TestListener = listenerRuleConfiguration
};
```

Golang:

```go
// Install: go get github.com/aws/aws-cdk-go/awscdk/v2
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
import "github.com/aws/aws-cdk-go/awscdk"
import "github.com/aws/aws-cdk-go/awscdk"

var listenerRuleConfiguration ListenerRuleConfiguration
var role Role

alternateTargetOptions := &AlternateTargetOptions{
	Role: role,
	TestListener: listenerRuleConfiguration,
}
```

## Properties

- `role`: [IRole](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_iam.IRole.html) — The IAM role for the configuration.

  **Default:** a new role will be created

- `testListener`: [ListenerRuleConfiguration](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_ecs.ListenerRuleConfiguration.html) = none — The test listener configuration.
