Class CfnService
The AWS::ECS::Service
resource creates an Amazon Elastic Container Service (Amazon ECS) service that runs and maintains the requested number of tasks and associated load balancers.
Inherited Members
Namespace: Amazon.CDK.AWS.ECS
Assembly: Amazon.CDK.Lib.dll
Syntax (csharp)
public class CfnService : CfnResource, IInspectable, ITaggable
Syntax (vb)
Public Class CfnService
Inherits CfnResource
Implements IInspectable, ITaggable
Remarks
The stack update fails if you change any properties that require replacement and at least one Amazon ECS Service Connect ServiceConnectConfiguration
property the is configured. This is because AWS CloudFormation creates the replacement service first, but each ServiceConnectService
must have a name that is unique in the namespace. > Starting April 15, 2023, AWS ; will not onboard new customers to Amazon Elastic Inference (EI), and will help current customers migrate their workloads to options that offer better price and performance. After April 15, 2023, new customers will not be able to launch instances with Amazon EI accelerators in Amazon SageMaker, Amazon ECS , or Amazon EC2 . However, customers who have used Amazon EI at least once during the past 30-day period are considered current customers and will be able to continue using the service.
See: http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-ecs-service.html
CloudformationResource: AWS::ECS::Service
ExampleMetadata: fixture=_generated
Examples
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
using Amazon.CDK.AWS.ECS;
var cfnService = new CfnService(this, "MyCfnService", new CfnServiceProps {
AvailabilityZoneRebalancing = "availabilityZoneRebalancing",
CapacityProviderStrategy = new [] { new CapacityProviderStrategyItemProperty {
Base = 123,
CapacityProvider = "capacityProvider",
Weight = 123
} },
Cluster = "cluster",
DeploymentConfiguration = new DeploymentConfigurationProperty {
Alarms = new DeploymentAlarmsProperty {
AlarmNames = new [] { "alarmNames" },
Enable = false,
Rollback = false
},
DeploymentCircuitBreaker = new DeploymentCircuitBreakerProperty {
Enable = false,
Rollback = false
},
MaximumPercent = 123,
MinimumHealthyPercent = 123
},
DeploymentController = new DeploymentControllerProperty {
Type = "type"
},
DesiredCount = 123,
EnableEcsManagedTags = false,
EnableExecuteCommand = false,
HealthCheckGracePeriodSeconds = 123,
LaunchType = "launchType",
LoadBalancers = new [] { new LoadBalancerProperty {
ContainerName = "containerName",
ContainerPort = 123,
LoadBalancerName = "loadBalancerName",
TargetGroupArn = "targetGroupArn"
} },
NetworkConfiguration = new NetworkConfigurationProperty {
AwsvpcConfiguration = new AwsVpcConfigurationProperty {
AssignPublicIp = "assignPublicIp",
SecurityGroups = new [] { "securityGroups" },
Subnets = new [] { "subnets" }
}
},
PlacementConstraints = new [] { new PlacementConstraintProperty {
Type = "type",
// the properties below are optional
Expression = "expression"
} },
PlacementStrategies = new [] { new PlacementStrategyProperty {
Type = "type",
// the properties below are optional
Field = "field"
} },
PlatformVersion = "platformVersion",
PropagateTags = "propagateTags",
Role = "role",
SchedulingStrategy = "schedulingStrategy",
ServiceConnectConfiguration = new ServiceConnectConfigurationProperty {
Enabled = false,
// the properties below are optional
LogConfiguration = new LogConfigurationProperty {
LogDriver = "logDriver",
Options = new Dictionary<string, string> {
{ "optionsKey", "options" }
},
SecretOptions = new [] { new SecretProperty {
Name = "name",
ValueFrom = "valueFrom"
} }
},
Namespace = "namespace",
Services = new [] { new ServiceConnectServiceProperty {
PortName = "portName",
// the properties below are optional
ClientAliases = new [] { new ServiceConnectClientAliasProperty {
Port = 123,
// the properties below are optional
DnsName = "dnsName"
} },
DiscoveryName = "discoveryName",
IngressPortOverride = 123,
Timeout = new TimeoutConfigurationProperty {
IdleTimeoutSeconds = 123,
PerRequestTimeoutSeconds = 123
},
Tls = new ServiceConnectTlsConfigurationProperty {
IssuerCertificateAuthority = new ServiceConnectTlsCertificateAuthorityProperty {
AwsPcaAuthorityArn = "awsPcaAuthorityArn"
},
// the properties below are optional
KmsKey = "kmsKey",
RoleArn = "roleArn"
}
} }
},
ServiceName = "serviceName",
ServiceRegistries = new [] { new ServiceRegistryProperty {
ContainerName = "containerName",
ContainerPort = 123,
Port = 123,
RegistryArn = "registryArn"
} },
Tags = new [] { new CfnTag {
Key = "key",
Value = "value"
} },
TaskDefinition = "taskDefinition",
VolumeConfigurations = new [] { new ServiceVolumeConfigurationProperty {
Name = "name",
// the properties below are optional
ManagedEbsVolume = new ServiceManagedEBSVolumeConfigurationProperty {
RoleArn = "roleArn",
// the properties below are optional
Encrypted = false,
FilesystemType = "filesystemType",
Iops = 123,
KmsKeyId = "kmsKeyId",
SizeInGiB = 123,
SnapshotId = "snapshotId",
TagSpecifications = new [] { new EBSTagSpecificationProperty {
ResourceType = "resourceType",
// the properties below are optional
PropagateTags = "propagateTags",
Tags = new [] { new CfnTag {
Key = "key",
Value = "value"
} }
} },
Throughput = 123,
VolumeType = "volumeType"
}
} },
VpcLatticeConfigurations = new [] { new VpcLatticeConfigurationProperty {
PortName = "portName",
RoleArn = "roleArn",
TargetGroupArn = "targetGroupArn"
} }
});
Synopsis
Constructors
CfnService(ByRefValue) | Used by jsii to construct an instance of this class from a Javascript-owned object reference |
CfnService(DeputyBase.DeputyProps) | Used by jsii to construct an instance of this class from DeputyProps |
CfnService(Construct, String, ICfnServiceProps) |
Properties
AttrName | The name of the Amazon ECS service, such as |
AttrServiceArn | Not currently supported in AWS CloudFormation . |
AvailabilityZoneRebalancing | Indicates whether to use Availability Zone rebalancing for the service. |
CapacityProviderStrategy | The capacity provider strategy to use for the service. |
CFN_RESOURCE_TYPE_NAME | The CloudFormation resource type name for this resource class. |
CfnProperties | |
Cluster | The short name or full Amazon Resource Name (ARN) of the cluster that you run your service on. |
DeploymentConfiguration | Optional deployment parameters that control how many tasks run during the deployment and the ordering of stopping and starting tasks. |
DeploymentController | The deployment controller to use for the service. |
DesiredCount | The number of instantiations of the specified task definition to place and keep running in your service. |
EnableEcsManagedTags | Specifies whether to turn on Amazon ECS managed tags for the tasks within the service. |
EnableExecuteCommand | Determines whether the execute command functionality is turned on for the service. |
HealthCheckGracePeriodSeconds | The period of time, in seconds, that the Amazon ECS service scheduler ignores unhealthy Elastic Load Balancing, VPC Lattice, and container health checks after a task has first started. |
LaunchType | The launch type on which to run your service. |
LoadBalancers | A list of load balancer objects to associate with the service. |
NetworkConfiguration | The network configuration for the service. |
PlacementConstraints | An array of placement constraint objects to use for tasks in your service. |
PlacementStrategies | The placement strategy objects to use for tasks in your service. |
PlatformVersion | The platform version that your tasks in the service are running on. |
PropagateTags | Specifies whether to propagate the tags from the task definition to the task. |
Role | The name or full Amazon Resource Name (ARN) of the IAM role that allows Amazon ECS to make calls to your load balancer on your behalf. |
SchedulingStrategy | The scheduling strategy to use for the service. |
ServiceConnectConfiguration | The configuration for this service to discover and connect to services, and be discovered by, and connected from, other services within a namespace. |
ServiceName | The name of your service. |
ServiceRegistries | The details of the service discovery registry to associate with this service. |
Tags | Tag Manager which manages the tags for this resource. |
TagsRaw | The metadata that you apply to the service to help you categorize and organize them. |
TaskDefinition | The |
VolumeConfigurations | The configuration for a volume specified in the task definition as a volume that is configured at launch time. |
VpcLatticeConfigurations | The VPC Lattice configuration for the service being created. |
Methods
Inspect(TreeInspector) | Examines the CloudFormation resource and discloses attributes. |
RenderProperties(IDictionary<String, Object>) |
Constructors
CfnService(ByRefValue)
Used by jsii to construct an instance of this class from a Javascript-owned object reference
protected CfnService(ByRefValue reference)
Parameters
- reference Amazon.JSII.Runtime.Deputy.ByRefValue
The Javascript-owned object reference
CfnService(DeputyBase.DeputyProps)
Used by jsii to construct an instance of this class from DeputyProps
protected CfnService(DeputyBase.DeputyProps props)
Parameters
- props Amazon.JSII.Runtime.Deputy.DeputyBase.DeputyProps
The deputy props
CfnService(Construct, String, ICfnServiceProps)
public CfnService(Construct scope, string id, ICfnServiceProps props = null)
Parameters
- scope Constructs.Construct
Scope in which this resource is defined.
- id System.String
Construct identifier for this resource (unique in its scope).
- props ICfnServiceProps
Resource properties.
Properties
AttrName
The name of the Amazon ECS service, such as sample-webapp
.
public virtual string AttrName { get; }
Property Value
System.String
Remarks
CloudformationAttribute: Name
AttrServiceArn
Not currently supported in AWS CloudFormation .
public virtual string AttrServiceArn { get; }
Property Value
System.String
Remarks
CloudformationAttribute: ServiceArn
AvailabilityZoneRebalancing
Indicates whether to use Availability Zone rebalancing for the service.
public virtual string AvailabilityZoneRebalancing { get; set; }
Property Value
System.String
CapacityProviderStrategy
The capacity provider strategy to use for the service.
public virtual object CapacityProviderStrategy { get; set; }
Property Value
System.Object
CFN_RESOURCE_TYPE_NAME
The CloudFormation resource type name for this resource class.
public static string CFN_RESOURCE_TYPE_NAME { get; }
Property Value
System.String
CfnProperties
protected override IDictionary<string, object> CfnProperties { get; }
Property Value
System.Collections.Generic.IDictionary<System.String, System.Object>
Overrides
Cluster
The short name or full Amazon Resource Name (ARN) of the cluster that you run your service on.
public virtual string Cluster { get; set; }
Property Value
System.String
DeploymentConfiguration
Optional deployment parameters that control how many tasks run during the deployment and the ordering of stopping and starting tasks.
public virtual object DeploymentConfiguration { get; set; }
Property Value
System.Object
DeploymentController
The deployment controller to use for the service.
public virtual object DeploymentController { get; set; }
Property Value
System.Object
DesiredCount
The number of instantiations of the specified task definition to place and keep running in your service.
public virtual Nullable<double> DesiredCount { get; set; }
Property Value
System.Nullable<System.Double>
EnableEcsManagedTags
Specifies whether to turn on Amazon ECS managed tags for the tasks within the service.
public virtual object EnableEcsManagedTags { get; set; }
Property Value
System.Object
EnableExecuteCommand
Determines whether the execute command functionality is turned on for the service.
public virtual object EnableExecuteCommand { get; set; }
Property Value
System.Object
HealthCheckGracePeriodSeconds
The period of time, in seconds, that the Amazon ECS service scheduler ignores unhealthy Elastic Load Balancing, VPC Lattice, and container health checks after a task has first started.
public virtual Nullable<double> HealthCheckGracePeriodSeconds { get; set; }
Property Value
System.Nullable<System.Double>
LaunchType
The launch type on which to run your service.
public virtual string LaunchType { get; set; }
Property Value
System.String
LoadBalancers
A list of load balancer objects to associate with the service.
public virtual object LoadBalancers { get; set; }
Property Value
System.Object
NetworkConfiguration
The network configuration for the service.
public virtual object NetworkConfiguration { get; set; }
Property Value
System.Object
PlacementConstraints
An array of placement constraint objects to use for tasks in your service.
public virtual object PlacementConstraints { get; set; }
Property Value
System.Object
PlacementStrategies
The placement strategy objects to use for tasks in your service.
public virtual object PlacementStrategies { get; set; }
Property Value
System.Object
PlatformVersion
The platform version that your tasks in the service are running on.
public virtual string PlatformVersion { get; set; }
Property Value
System.String
PropagateTags
Specifies whether to propagate the tags from the task definition to the task.
public virtual string PropagateTags { get; set; }
Property Value
System.String
Role
The name or full Amazon Resource Name (ARN) of the IAM role that allows Amazon ECS to make calls to your load balancer on your behalf.
public virtual string Role { get; set; }
Property Value
System.String
SchedulingStrategy
The scheduling strategy to use for the service.
public virtual string SchedulingStrategy { get; set; }
Property Value
System.String
Remarks
For more information, see Services .
ServiceConnectConfiguration
The configuration for this service to discover and connect to services, and be discovered by, and connected from, other services within a namespace.
public virtual object ServiceConnectConfiguration { get; set; }
Property Value
System.Object
ServiceName
The name of your service.
public virtual string ServiceName { get; set; }
Property Value
System.String
ServiceRegistries
The details of the service discovery registry to associate with this service.
public virtual object ServiceRegistries { get; set; }
Property Value
System.Object
Remarks
For more information, see Service discovery .
Tags
Tag Manager which manages the tags for this resource.
public virtual TagManager Tags { get; }
Property Value
TagsRaw
The metadata that you apply to the service to help you categorize and organize them.
public virtual ICfnTag[] TagsRaw { get; set; }
Property Value
ICfnTag[]
TaskDefinition
The family
and revision
( family:revision
) or full ARN of the task definition to run in your service.
public virtual string TaskDefinition { get; set; }
Property Value
System.String
VolumeConfigurations
The configuration for a volume specified in the task definition as a volume that is configured at launch time.
public virtual object VolumeConfigurations { get; set; }
Property Value
System.Object
VpcLatticeConfigurations
The VPC Lattice configuration for the service being created.
public virtual object VpcLatticeConfigurations { get; set; }
Property Value
System.Object
Methods
Inspect(TreeInspector)
Examines the CloudFormation resource and discloses attributes.
public virtual void Inspect(TreeInspector inspector)
Parameters
- inspector TreeInspector
tree inspector to collect and process attributes.
RenderProperties(IDictionary<String, Object>)
protected override IDictionary<string, object> RenderProperties(IDictionary<string, object> props)
Parameters
- props System.Collections.Generic.IDictionary<System.String, System.Object>
Returns
System.Collections.Generic.IDictionary<System.String, System.Object>