NetworkLoadBalancedServiceBaseProps Struct
The properties for the base NetworkLoadBalancedEc2Service or NetworkLoadBalancedFargateService service.
Example
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
import * as cdk from 'aws-cdk-lib';
import { aws_ec2 as ec2 } from 'aws-cdk-lib';
import { aws_ecs as ecs } from 'aws-cdk-lib';
import { aws_ecs_patterns as ecs_patterns } from 'aws-cdk-lib';
import { aws_elasticloadbalancingv2 as elbv2 } from 'aws-cdk-lib';
import { aws_iam as iam } from 'aws-cdk-lib';
import { aws_route53 as route53 } from 'aws-cdk-lib';
import { aws_servicediscovery as servicediscovery } from 'aws-cdk-lib';
declare const cluster: ecs.Cluster;
declare const containerDefinition: ecs.ContainerDefinition;
declare const containerImage: ecs.ContainerImage;
declare const hostedZone: route53.HostedZone;
declare const listenerCertificate: elbv2.ListenerCertificate;
declare const logDriver: ecs.LogDriver;
declare const namespace: servicediscovery.INamespace;
declare const networkLoadBalancer: elbv2.NetworkLoadBalancer;
declare const role: iam.Role;
declare const secret: ecs.Secret;
declare const vpc: ec2.Vpc;
const networkLoadBalancedServiceBaseProps: ecs_patterns.NetworkLoadBalancedServiceBaseProps = {
capacityProviderStrategies: [{
capacityProvider: 'capacityProvider',
// the properties below are optional
base: 123,
weight: 123,
}],
circuitBreaker: {
enable: false,
rollback: false,
},
cloudMapOptions: {
cloudMapNamespace: namespace,
container: containerDefinition,
containerPort: 123,
dnsRecordType: servicediscovery.DnsRecordType.A,
dnsTtl: cdk.Duration.minutes(30),
failureThreshold: 123,
name: 'name',
},
cluster: cluster,
deploymentController: {
type: ecs.DeploymentControllerType.ECS,
},
desiredCount: 123,
domainName: 'domainName',
domainZone: hostedZone,
enableECSManagedTags: false,
enableExecuteCommand: false,
healthCheckGracePeriod: cdk.Duration.minutes(30),
ipAddressType: elbv2.IpAddressType.IPV4,
listenerCertificate: listenerCertificate,
listenerPort: 123,
loadBalancer: networkLoadBalancer,
maxHealthyPercent: 123,
minHealthyPercent: 123,
propagateTags: ecs.PropagatedTagSource.SERVICE,
publicLoadBalancer: false,
recordType: ecs_patterns.NetworkLoadBalancedServiceRecordType.ALIAS,
serviceName: 'serviceName',
taskImageOptions: {
image: containerImage,
// the properties below are optional
containerName: 'containerName',
containerPort: 123,
dockerLabels: {
dockerLabelsKey: 'dockerLabels',
},
enableLogging: false,
environment: {
environmentKey: 'environment',
},
executionRole: role,
family: 'family',
logDriver: logDriver,
secrets: {
secretsKey: secret,
},
taskRole: role,
},
vpc: vpc,
};
# The code below shows an example of how to instantiate this type.
# The values are placeholders you should change.
import aws_cdk as cdk
from aws_cdk import aws_ec2 as ec2
from aws_cdk import aws_ecs as ecs
from aws_cdk import aws_ecs_patterns as ecs_patterns
from aws_cdk import aws_elasticloadbalancingv2 as elbv2
from aws_cdk import aws_iam as iam
from aws_cdk import aws_route53 as route53
from aws_cdk import aws_servicediscovery as servicediscovery
# cluster: ecs.Cluster
# container_definition: ecs.ContainerDefinition
# container_image: ecs.ContainerImage
# hosted_zone: route53.HostedZone
# listener_certificate: elbv2.ListenerCertificate
# log_driver: ecs.LogDriver
# namespace: servicediscovery.INamespace
# network_load_balancer: elbv2.NetworkLoadBalancer
# role: iam.Role
# secret: ecs.Secret
# vpc: ec2.Vpc
network_load_balanced_service_base_props = ecs_patterns.NetworkLoadBalancedServiceBaseProps(
capacity_provider_strategies=[ecs.CapacityProviderStrategy(
capacity_provider="capacityProvider",
# the properties below are optional
base=123,
weight=123
)],
circuit_breaker=ecs.DeploymentCircuitBreaker(
enable=False,
rollback=False
),
cloud_map_options=ecs.CloudMapOptions(
cloud_map_namespace=namespace,
container=container_definition,
container_port=123,
dns_record_type=servicediscovery.DnsRecordType.A,
dns_ttl=cdk.Duration.minutes(30),
failure_threshold=123,
name="name"
),
cluster=cluster,
deployment_controller=ecs.DeploymentController(
type=ecs.DeploymentControllerType.ECS
),
desired_count=123,
domain_name="domainName",
domain_zone=hosted_zone,
enable_ecs_managed_tags=False,
enable_execute_command=False,
health_check_grace_period=cdk.Duration.minutes(30),
ip_address_type=elbv2.IpAddressType.IPV4,
listener_certificate=listener_certificate,
listener_port=123,
load_balancer=network_load_balancer,
max_healthy_percent=123,
min_healthy_percent=123,
propagate_tags=ecs.PropagatedTagSource.SERVICE,
public_load_balancer=False,
record_type=ecs_patterns.NetworkLoadBalancedServiceRecordType.ALIAS,
service_name="serviceName",
task_image_options=ecs_patterns.NetworkLoadBalancedTaskImageOptions(
image=container_image,
# the properties below are optional
container_name="containerName",
container_port=123,
docker_labels={
"docker_labels_key": "dockerLabels"
},
enable_logging=False,
environment={
"environment_key": "environment"
},
execution_role=role,
family="family",
log_driver=log_driver,
secrets={
"secrets_key": secret
},
task_role=role
),
vpc=vpc
)
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
import software.amazon.awscdk.*;
import software.amazon.awscdk.services.ec2.*;
import software.amazon.awscdk.services.ecs.*;
import software.amazon.awscdk.services.ecs.patterns.*;
import software.amazon.awscdk.services.elasticloadbalancingv2.*;
import software.amazon.awscdk.services.iam.*;
import software.amazon.awscdk.services.route53.*;
import software.amazon.awscdk.services.servicediscovery.*;
Cluster cluster;
ContainerDefinition containerDefinition;
ContainerImage containerImage;
HostedZone hostedZone;
ListenerCertificate listenerCertificate;
LogDriver logDriver;
INamespace namespace;
NetworkLoadBalancer networkLoadBalancer;
Role role;
Secret secret;
Vpc vpc;
NetworkLoadBalancedServiceBaseProps networkLoadBalancedServiceBaseProps = NetworkLoadBalancedServiceBaseProps.builder()
.capacityProviderStrategies(List.of(CapacityProviderStrategy.builder()
.capacityProvider("capacityProvider")
// the properties below are optional
.base(123)
.weight(123)
.build()))
.circuitBreaker(DeploymentCircuitBreaker.builder()
.enable(false)
.rollback(false)
.build())
.cloudMapOptions(CloudMapOptions.builder()
.cloudMapNamespace(namespace)
.container(containerDefinition)
.containerPort(123)
.dnsRecordType(DnsRecordType.A)
.dnsTtl(Duration.minutes(30))
.failureThreshold(123)
.name("name")
.build())
.cluster(cluster)
.deploymentController(DeploymentController.builder()
.type(DeploymentControllerType.ECS)
.build())
.desiredCount(123)
.domainName("domainName")
.domainZone(hostedZone)
.enableECSManagedTags(false)
.enableExecuteCommand(false)
.healthCheckGracePeriod(Duration.minutes(30))
.ipAddressType(IpAddressType.IPV4)
.listenerCertificate(listenerCertificate)
.listenerPort(123)
.loadBalancer(networkLoadBalancer)
.maxHealthyPercent(123)
.minHealthyPercent(123)
.propagateTags(PropagatedTagSource.SERVICE)
.publicLoadBalancer(false)
.recordType(NetworkLoadBalancedServiceRecordType.ALIAS)
.serviceName("serviceName")
.taskImageOptions(NetworkLoadBalancedTaskImageOptions.builder()
.image(containerImage)
// the properties below are optional
.containerName("containerName")
.containerPort(123)
.dockerLabels(Map.of(
"dockerLabelsKey", "dockerLabels"))
.enableLogging(false)
.environment(Map.of(
"environmentKey", "environment"))
.executionRole(role)
.family("family")
.logDriver(logDriver)
.secrets(Map.of(
"secretsKey", secret))
.taskRole(role)
.build())
.vpc(vpc)
.build();
// 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;
using Amazon.CDK.AWS.EC2;
using Amazon.CDK.AWS.ECS;
using Amazon.CDK.AWS.ECS.Patterns;
using Amazon.CDK.AWS.ElasticLoadBalancingV2;
using Amazon.CDK.AWS.IAM;
using Amazon.CDK.AWS.Route53;
using Amazon.CDK.AWS.ServiceDiscovery;
Cluster cluster;
ContainerDefinition containerDefinition;
ContainerImage containerImage;
HostedZone hostedZone;
ListenerCertificate listenerCertificate;
LogDriver logDriver;
INamespace namespace;
NetworkLoadBalancer networkLoadBalancer;
Role role;
Secret secret;
Vpc vpc;
var networkLoadBalancedServiceBaseProps = new NetworkLoadBalancedServiceBaseProps {
CapacityProviderStrategies = new [] { new CapacityProviderStrategy {
CapacityProvider = "capacityProvider",
// the properties below are optional
Base = 123,
Weight = 123
} },
CircuitBreaker = new DeploymentCircuitBreaker {
Enable = false,
Rollback = false
},
CloudMapOptions = new CloudMapOptions {
CloudMapNamespace = namespace,
Container = containerDefinition,
ContainerPort = 123,
DnsRecordType = DnsRecordType.A,
DnsTtl = Duration.Minutes(30),
FailureThreshold = 123,
Name = "name"
},
Cluster = cluster,
DeploymentController = new DeploymentController {
Type = DeploymentControllerType.ECS
},
DesiredCount = 123,
DomainName = "domainName",
DomainZone = hostedZone,
EnableECSManagedTags = false,
EnableExecuteCommand = false,
HealthCheckGracePeriod = Duration.Minutes(30),
IpAddressType = IpAddressType.IPV4,
ListenerCertificate = listenerCertificate,
ListenerPort = 123,
LoadBalancer = networkLoadBalancer,
MaxHealthyPercent = 123,
MinHealthyPercent = 123,
PropagateTags = PropagatedTagSource.SERVICE,
PublicLoadBalancer = false,
RecordType = NetworkLoadBalancedServiceRecordType.ALIAS,
ServiceName = "serviceName",
TaskImageOptions = new NetworkLoadBalancedTaskImageOptions {
Image = containerImage,
// the properties below are optional
ContainerName = "containerName",
ContainerPort = 123,
DockerLabels = new Dictionary<string, string> {
{ "dockerLabelsKey", "dockerLabels" }
},
EnableLogging = false,
Environment = new Dictionary<string, string> {
{ "environmentKey", "environment" }
},
ExecutionRole = role,
Family = "family",
LogDriver = logDriver,
Secrets = new Dictionary<string, Secret> {
{ "secretsKey", secret }
},
TaskRole = role
},
Vpc = vpc
};
// 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"
import "github.com/aws/aws-cdk-go/awscdk"
import "github.com/aws/aws-cdk-go/awscdk"
import "github.com/aws/aws-cdk-go/awscdk"
import "github.com/aws/aws-cdk-go/awscdk"
import "github.com/aws/aws-cdk-go/awscdk"
import "github.com/aws/aws-cdk-go/awscdk"
var cluster Cluster
var containerDefinition ContainerDefinition
var containerImage ContainerImage
var hostedZone HostedZone
var listenerCertificate ListenerCertificate
var logDriver LogDriver
var namespace INamespace
var networkLoadBalancer NetworkLoadBalancer
var role Role
var secret Secret
var vpc Vpc
networkLoadBalancedServiceBaseProps := &NetworkLoadBalancedServiceBaseProps{
CapacityProviderStrategies: []CapacityProviderStrategy{
&CapacityProviderStrategy{
CapacityProvider: jsii.String("capacityProvider"),
// the properties below are optional
Base: jsii.Number(123),
Weight: jsii.Number(123),
},
},
CircuitBreaker: &DeploymentCircuitBreaker{
Enable: jsii.Boolean(false),
Rollback: jsii.Boolean(false),
},
CloudMapOptions: &CloudMapOptions{
CloudMapNamespace: namespace,
Container: containerDefinition,
ContainerPort: jsii.Number(123),
DnsRecordType: awscdk.Aws_servicediscovery.DnsRecordType_A,
DnsTtl: cdk.Duration_Minutes(jsii.Number(30)),
FailureThreshold: jsii.Number(123),
Name: jsii.String("name"),
},
Cluster: cluster,
DeploymentController: &DeploymentController{
Type: awscdk.Aws_ecs.DeploymentControllerType_ECS,
},
DesiredCount: jsii.Number(123),
DomainName: jsii.String("domainName"),
DomainZone: hostedZone,
EnableECSManagedTags: jsii.Boolean(false),
EnableExecuteCommand: jsii.Boolean(false),
HealthCheckGracePeriod: cdk.Duration_*Minutes(jsii.Number(30)),
IpAddressType: awscdk.Aws_elasticloadbalancingv2.IpAddressType_IPV4,
ListenerCertificate: listenerCertificate,
ListenerPort: jsii.Number(123),
LoadBalancer: networkLoadBalancer,
MaxHealthyPercent: jsii.Number(123),
MinHealthyPercent: jsii.Number(123),
PropagateTags: awscdk.*Aws_ecs.PropagatedTagSource_SERVICE,
PublicLoadBalancer: jsii.Boolean(false),
RecordType: awscdk.Aws_ecs_patterns.NetworkLoadBalancedServiceRecordType_ALIAS,
ServiceName: jsii.String("serviceName"),
TaskImageOptions: &NetworkLoadBalancedTaskImageOptions{
Image: containerImage,
// the properties below are optional
ContainerName: jsii.String("containerName"),
ContainerPort: jsii.Number(123),
DockerLabels: map[string]*string{
"dockerLabelsKey": jsii.String("dockerLabels"),
},
EnableLogging: jsii.Boolean(false),
Environment: map[string]*string{
"environmentKey": jsii.String("environment"),
},
ExecutionRole: role,
Family: jsii.String("family"),
LogDriver: logDriver,
Secrets: map[string]Secret{
"secretsKey": secret,
},
TaskRole: role,
},
Vpc: vpc,
}
Properties
capacityProviderStrategiesoptionalCapacityProviderStrategy[]capacity_provider_strategiesoptionaltyping.List[CapacityProviderStrategy]capacityProviderStrategiesoptionalList<CapacityProviderStrategy>CapacityProviderStrategiesoptionalCapacityProviderStrategy[]CapacityProviderStrategiesoptional*[]CapacityProviderStrategy= undefined#circuitBreakeroptionalDeploymentCircuitBreakercircuit_breakeroptionalDeploymentCircuitBreakercircuitBreakeroptionalDeploymentCircuitBreakerCircuitBreakeroptionalDeploymentCircuitBreakerCircuitBreakeroptionalDeploymentCircuitBreaker= disabled#If this property is defined, circuit breaker will be implicitly enabled.
cloudMapOptionsoptionalCloudMapOptionscloud_map_optionsoptionalCloudMapOptionscloudMapOptionsoptionalCloudMapOptionsCloudMapOptionsoptionalCloudMapOptionsCloudMapOptionsoptionalCloudMapOptions#Default: AWS Cloud Map service discovery is not enabled.
clusteroptionalIClusterclusteroptionalIClusterclusteroptionalIClusterClusteroptionalIClusterClusteroptionalICluster#Default: create a new cluster; if both cluster and vpc are omitted, a new VPC will be created for you.
If a cluster is specified, the vpc construct should be omitted. Alternatively, you can omit both cluster and vpc.
deploymentControlleroptionalDeploymentControllerdeployment_controlleroptionalDeploymentControllerdeploymentControlleroptionalDeploymentControllerDeploymentControlleroptionalDeploymentControllerDeploymentControlleroptionalDeploymentController#Default: Rolling update (ECS)
For more information, see Amazon ECS Deployment Types
desiredCountoptionalnumberdesired_countoptionalint | floatdesiredCountoptionalNumberDesiredCountoptionaldoubleDesiredCountoptional*float64#Default: The default is 1 for all new services and uses the existing service's desired count when updating an existing service.
The minimum value is 1
domainNameoptionalstringdomain_nameoptionalstrdomainNameoptionalStringDomainNameoptionalstringDomainNameoptional*string#Default: No domain name.
domainZoneoptionalIHostedZonedomain_zoneoptionalIHostedZonedomainZoneoptionalIHostedZoneDomainZoneoptionalIHostedZoneDomainZoneoptionalIHostedZone#Default: No Route53 hosted domain zone.
enableECSManagedTagsoptionalbooleanenable_ecs_managed_tagsoptionalboolenableECSManagedTagsoptionalBooleanEnableECSManagedTagsoptionalboolEnableECSManagedTagsoptional*bool= false#For more information, see Tagging Your Amazon ECS Resources
enableExecuteCommandoptionalbooleanenable_execute_commandoptionalboolenableExecuteCommandoptionalBooleanEnableExecuteCommandoptionalboolEnableExecuteCommandoptional*bool= false#healthCheckGracePeriodoptionalDurationhealth_check_grace_periodoptionalDurationhealthCheckGracePeriodoptionalDurationHealthCheckGracePeriodoptionalDurationHealthCheckGracePeriodoptionalDuration#Default: defaults to 60 seconds if at least one load balancer is in-use and it is not already set
ipAddressTypeoptionalIpAddressTypeip_address_typeoptionalIpAddressTypeipAddressTypeoptionalIpAddressTypeIpAddressTypeoptionalIpAddressTypeIpAddressTypeoptionalIpAddressType= IpAddressType.IPV4#If you want to add a UDP or TCP_UDP listener to the load balancer, you must choose IPv4.
listenerCertificateoptionalIListenerCertificatelistener_certificateoptionalIListenerCertificatelistenerCertificateoptionalIListenerCertificateListenerCertificateoptionalIListenerCertificateListenerCertificateoptionalIListenerCertificate= none#If you provide a certificate, the listener's protocol will be TLS. If not, the listener's protocol will be TCP.
listenerPortoptionalnumberlistener_portoptionalint | floatlistenerPortoptionalNumberListenerPortoptionaldoubleListenerPortoptional*float64#Default: 80 or 443 with listenerCertificate provided
loadBalanceroptionalINetworkLoadBalancerload_balanceroptionalINetworkLoadBalancerloadBalanceroptionalINetworkLoadBalancerLoadBalanceroptionalINetworkLoadBalancerLoadBalanceroptionalINetworkLoadBalancer#Default: a new load balancer will be created.
If the load balancer has been imported, the vpc attribute must be specified in the call to fromNetworkLoadBalancerAttributes().
[disable-awslint:ref-via-interface]
maxHealthyPercentoptionalnumbermax_healthy_percentoptionalint | floatmaxHealthyPercentoptionalNumberMaxHealthyPercentoptionaldoubleMaxHealthyPercentoptional*float64#Default: 100 if daemon, otherwise 200
minHealthyPercentoptionalnumbermin_healthy_percentoptionalint | floatminHealthyPercentoptionalNumberMinHealthyPercentoptionaldoubleMinHealthyPercentoptional*float64#Default: 0 if daemon, otherwise 50
propagateTagsoptionalPropagatedTagSourcepropagate_tagsoptionalPropagatedTagSourcepropagateTagsoptionalPropagatedTagSourcePropagateTagsoptionalPropagatedTagSourcePropagateTagsoptionalPropagatedTagSource= none#Tags can only be propagated to the tasks within the service during service creation.
publicLoadBalanceroptionalbooleanpublic_load_balanceroptionalboolpublicLoadBalanceroptionalBooleanPublicLoadBalanceroptionalboolPublicLoadBalanceroptional*bool= true#recordTypeoptionalNetworkLoadBalancedServiceRecordTyperecord_typeoptionalNetworkLoadBalancedServiceRecordTyperecordTypeoptionalNetworkLoadBalancedServiceRecordTypeRecordTypeoptionalNetworkLoadBalancedServiceRecordTypeRecordTypeoptionalNetworkLoadBalancedServiceRecordType#Default: NetworkLoadBalancedServiceRecordType.ALIAS
This is useful if you need to work with DNS systems that do not support alias records.
serviceNameoptionalstringservice_nameoptionalstrserviceNameoptionalStringServiceNameoptionalstringServiceNameoptional*string#Default: CloudFormation-generated name.
taskImageOptionsoptionalNetworkLoadBalancedTaskImageOptionstask_image_optionsoptionalNetworkLoadBalancedTaskImageOptionstaskImageOptionsoptionalNetworkLoadBalancedTaskImageOptionsTaskImageOptionsoptionalNetworkLoadBalancedTaskImageOptionsTaskImageOptionsoptionalNetworkLoadBalancedTaskImageOptions= none#One of taskImageOptions or taskDefinition must be specified.
Default: uses the VPC defined in the cluster or creates a new VPC.
If a vpc is specified, the cluster construct should be omitted. Alternatively, you can omit both vpc and cluster.