Skip to content
v2.278.0

CloudMapOptions Struct ​

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

Example ​

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
# 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
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();
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
    }
});
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 ​

cloudMapNamespaceoptionalINamespacecloud_map_namespaceoptionalINamespacecloudMapNamespaceoptionalINamespaceCloudMapNamespaceoptionalINamespaceCloudMapNamespaceoptionalINamespace #
The service discovery namespace for the Cloud Map service to attach to the ECS service.

Default: the defaultCloudMapNamespace associated to the cluster

containeroptionalContainerDefinitioncontaineroptionalContainerDefinitioncontaineroptionalContainerDefinitionContaineroptionalContainerDefinitionContaineroptionalContainerDefinition #
The container to point to for a SRV record.

Default: the task definition's default container

containerPortoptionalnumbercontainer_portoptionalint | floatcontainerPortoptionalNumberContainerPortoptionaldoubleContainerPortoptional*float64 #
The port to point to for a SRV record.

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

dnsRecordTypeoptionalDnsRecordTypedns_record_typeoptionalDnsRecordTypednsRecordTypeoptionalDnsRecordTypeDnsRecordTypeoptionalDnsRecordTypeDnsRecordTypeoptionalDnsRecordType #
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.

dnsTtloptionalDurationdns_ttloptionalDurationdnsTtloptionalDurationDnsTtloptionalDurationDnsTtloptionalDuration = Duration.minutes(1) #
The amount of time that you want DNS resolvers to cache the settings for this record.
failureThresholdoptionalnumberfailure_thresholdoptionalint | floatfailureThresholdoptionalNumberFailureThresholdoptionaldoubleFailureThresholdoptional*float64 #
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

nameoptionalstringnameoptionalstrnameoptionalStringNameoptionalstringNameoptional*string #
The name of the Cloud Map service to attach to the ECS service.

Default: CloudFormation-generated name