# CloudMapOptions

The options to enabling AWS Cloud Map for an Amazon ECS service.

Used as argument in: [BaseService.enableCloudMap](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_ecs.BaseService.html#enablecloudmap)

- Source: [`aws-ecs/lib/base/base-service.ts`](https://github.com/aws/aws-cdk/blob/v2.278.0/packages/aws-cdk-lib/aws-ecs/lib/base/base-service.ts#L2044)

## Example

TypeScript:

```ts
declare const taskDefinition: ecs.TaskDefinition;
declare const cluster: ecs.Cluster;

const service = new ecs.Ec2Service(this, 'Service', {
  cluster,
  taskDefinition,
  cloudMapOptions: {
    // Create A records - useful for AWSVPC network mode.
    dnsRecordType: cloudmap.DnsRecordType.A,
  },
});
```

Python:

```python
# task_definition: ecs.TaskDefinition
# cluster: ecs.Cluster

service = ecs.Ec2Service(self, "Service",
    cluster=cluster,
    task_definition=task_definition,
    cloud_map_options=ecs.CloudMapOptions(
        # Create A records - useful for AWSVPC network mode.
        dns_record_type=cloudmap.DnsRecordType.A
    )
)
```

Java:

```java
TaskDefinition taskDefinition;
Cluster cluster;

Ec2Service service = Ec2Service.Builder.create(this, "Service")
        .cluster(cluster)
        .taskDefinition(taskDefinition)
        .cloudMapOptions(CloudMapOptions.builder()
                // Create A records - useful for AWSVPC network mode.
                .dnsRecordType(DnsRecordType.A)
                .build())
        .build();
```

C# / .NET:

```csharp
// Install: dotnet add package Amazon.CDK.Lib
TaskDefinition taskDefinition;
Cluster cluster;

var service = new Ec2Service(this, "Service", new Ec2ServiceProps {
    Cluster = cluster,
    TaskDefinition = taskDefinition,
    CloudMapOptions = new CloudMapOptions {
        // Create A records - useful for AWSVPC network mode.
        DnsRecordType = DnsRecordType.A
    }
});
```

Golang:

```go
// Install: go get github.com/aws/aws-cdk-go/awscdk/v2
var taskDefinition TaskDefinition
var cluster Cluster

service := ecs.NewEc2Service(this, jsii.String("Service"), &Ec2ServiceProps{
	Cluster: Cluster,
	TaskDefinition: TaskDefinition,
	CloudMapOptions: &CloudMapOptions{
		// Create A records - useful for AWSVPC network mode.
		DnsRecordType: cloudmap.DnsRecordType_A,
	},
})
```

## Properties

- `cloudMapNamespace`: [INamespace](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_servicediscovery.INamespace.html) — The service discovery namespace for the Cloud Map service to attach to the ECS service.

  **Default:** the defaultCloudMapNamespace associated to the cluster

- `container`: [ContainerDefinition](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_ecs.ContainerDefinition.html) — The container to point to for a SRV record.

  **Default:** the task definition's default container

- `containerPort`: number — The port to point to for a SRV record.

  **Default:** the default port of the task definition's default container

- `dnsRecordType`: [DnsRecordType](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_servicediscovery.DnsRecordType.html) — The DNS record type that you want AWS Cloud Map to create.

  **Default:** DnsRecordType.A if TaskDefinition.networkMode = AWS_VPC, otherwise DnsRecordType.SRV

  The supported record types are A or SRV.

- `dnsTtl`: [Duration](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.Duration.html) = Duration.minutes(1) — The amount of time that you want DNS resolvers to cache the settings for this record.

- `failureThreshold`: number — The number of 30-second intervals that you want Cloud Map to wait after receiving an UpdateInstanceCustomHealthStatus request before it changes the health status of a service instance.

  NOTE: This is used for HealthCheckCustomConfig

- `name`: string — The name of the Cloud Map service to attach to the ECS service.

  **Default:** CloudFormation-generated name
