Documentation ¶
Index ¶
- func ApplicationLoadBalancedEc2Service_IsConstruct(x interface{}) *bool
- func ApplicationLoadBalancedFargateService_IsConstruct(x interface{}) *bool
- func ApplicationLoadBalancedServiceBase_IsConstruct(x interface{}) *bool
- func ApplicationMultipleTargetGroupsEc2Service_IsConstruct(x interface{}) *bool
- func ApplicationMultipleTargetGroupsFargateService_IsConstruct(x interface{}) *bool
- func ApplicationMultipleTargetGroupsServiceBase_IsConstruct(x interface{}) *bool
- func NetworkLoadBalancedEc2Service_IsConstruct(x interface{}) *bool
- func NetworkLoadBalancedFargateService_IsConstruct(x interface{}) *bool
- func NetworkLoadBalancedServiceBase_IsConstruct(x interface{}) *bool
- func NetworkMultipleTargetGroupsEc2Service_IsConstruct(x interface{}) *bool
- func NetworkMultipleTargetGroupsFargateService_IsConstruct(x interface{}) *bool
- func NetworkMultipleTargetGroupsServiceBase_IsConstruct(x interface{}) *bool
- func NewApplicationLoadBalancedEc2Service_Override(a ApplicationLoadBalancedEc2Service, scope constructs.Construct, id *string, ...)
- func NewApplicationLoadBalancedFargateService_Override(a ApplicationLoadBalancedFargateService, scope constructs.Construct, ...)
- func NewApplicationLoadBalancedServiceBase_Override(a ApplicationLoadBalancedServiceBase, scope constructs.Construct, id *string, ...)
- func NewApplicationMultipleTargetGroupsEc2Service_Override(a ApplicationMultipleTargetGroupsEc2Service, scope constructs.Construct, ...)
- func NewApplicationMultipleTargetGroupsFargateService_Override(a ApplicationMultipleTargetGroupsFargateService, scope constructs.Construct, ...)
- func NewApplicationMultipleTargetGroupsServiceBase_Override(a ApplicationMultipleTargetGroupsServiceBase, scope constructs.Construct, ...)
- func NewNetworkLoadBalancedEc2Service_Override(n NetworkLoadBalancedEc2Service, scope constructs.Construct, id *string, ...)
- func NewNetworkLoadBalancedFargateService_Override(n NetworkLoadBalancedFargateService, scope constructs.Construct, id *string, ...)
- func NewNetworkLoadBalancedServiceBase_Override(n NetworkLoadBalancedServiceBase, scope constructs.Construct, id *string, ...)
- func NewNetworkMultipleTargetGroupsEc2Service_Override(n NetworkMultipleTargetGroupsEc2Service, scope constructs.Construct, ...)
- func NewNetworkMultipleTargetGroupsFargateService_Override(n NetworkMultipleTargetGroupsFargateService, scope constructs.Construct, ...)
- func NewNetworkMultipleTargetGroupsServiceBase_Override(n NetworkMultipleTargetGroupsServiceBase, scope constructs.Construct, ...)
- func NewQueueProcessingEc2Service_Override(q QueueProcessingEc2Service, scope constructs.Construct, id *string, ...)
- func NewQueueProcessingFargateService_Override(q QueueProcessingFargateService, scope constructs.Construct, id *string, ...)
- func NewQueueProcessingServiceBase_Override(q QueueProcessingServiceBase, scope constructs.Construct, id *string, ...)
- func NewScheduledEc2Task_Override(s ScheduledEc2Task, scope constructs.Construct, id *string, ...)
- func NewScheduledFargateTask_Override(s ScheduledFargateTask, scope constructs.Construct, id *string, ...)
- func NewScheduledTaskBase_Override(s ScheduledTaskBase, scope constructs.Construct, id *string, ...)
- func QueueProcessingEc2Service_IsConstruct(x interface{}) *bool
- func QueueProcessingFargateService_IsConstruct(x interface{}) *bool
- func QueueProcessingServiceBase_IsConstruct(x interface{}) *bool
- func ScheduledEc2Task_IsConstruct(x interface{}) *bool
- func ScheduledFargateTask_IsConstruct(x interface{}) *bool
- func ScheduledTaskBase_IsConstruct(x interface{}) *bool
- type ApplicationListenerProps
- type ApplicationLoadBalancedEc2Service
- type ApplicationLoadBalancedEc2ServiceProps
- type ApplicationLoadBalancedFargateService
- type ApplicationLoadBalancedFargateServiceProps
- type ApplicationLoadBalancedServiceBase
- type ApplicationLoadBalancedServiceBaseProps
- type ApplicationLoadBalancedServiceRecordType
- type ApplicationLoadBalancedTaskImageOptions
- type ApplicationLoadBalancedTaskImageProps
- type ApplicationLoadBalancerProps
- type ApplicationMultipleTargetGroupsEc2Service
- type ApplicationMultipleTargetGroupsEc2ServiceProps
- type ApplicationMultipleTargetGroupsFargateService
- type ApplicationMultipleTargetGroupsFargateServiceProps
- type ApplicationMultipleTargetGroupsServiceBase
- type ApplicationMultipleTargetGroupsServiceBaseProps
- type ApplicationTargetProps
- type NetworkListenerProps
- type NetworkLoadBalancedEc2Service
- type NetworkLoadBalancedEc2ServiceProps
- type NetworkLoadBalancedFargateService
- type NetworkLoadBalancedFargateServiceProps
- type NetworkLoadBalancedServiceBase
- type NetworkLoadBalancedServiceBaseProps
- type NetworkLoadBalancedServiceRecordType
- type NetworkLoadBalancedTaskImageOptions
- type NetworkLoadBalancedTaskImageProps
- type NetworkLoadBalancerProps
- type NetworkMultipleTargetGroupsEc2Service
- type NetworkMultipleTargetGroupsEc2ServiceProps
- type NetworkMultipleTargetGroupsFargateService
- type NetworkMultipleTargetGroupsFargateServiceProps
- type NetworkMultipleTargetGroupsServiceBase
- type NetworkMultipleTargetGroupsServiceBaseProps
- type NetworkTargetProps
- type QueueProcessingEc2Service
- type QueueProcessingEc2ServiceProps
- type QueueProcessingFargateService
- type QueueProcessingFargateServiceProps
- type QueueProcessingServiceBase
- type QueueProcessingServiceBaseProps
- type ScheduledEc2Task
- type ScheduledEc2TaskDefinitionOptions
- type ScheduledEc2TaskImageOptions
- type ScheduledEc2TaskProps
- type ScheduledFargateTask
- type ScheduledFargateTaskDefinitionOptions
- type ScheduledFargateTaskImageOptions
- type ScheduledFargateTaskProps
- type ScheduledTaskBase
- type ScheduledTaskBaseProps
- type ScheduledTaskImageProps
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ApplicationLoadBalancedEc2Service_IsConstruct ¶
func ApplicationLoadBalancedEc2Service_IsConstruct(x interface{}) *bool
Checks if `x` is a construct.
Returns: true if `x` is an object created from a class which extends `Construct`. Deprecated: use `x instanceof Construct` instead.
func ApplicationLoadBalancedFargateService_IsConstruct ¶
func ApplicationLoadBalancedFargateService_IsConstruct(x interface{}) *bool
Checks if `x` is a construct.
Returns: true if `x` is an object created from a class which extends `Construct`. Deprecated: use `x instanceof Construct` instead.
func ApplicationLoadBalancedServiceBase_IsConstruct ¶
func ApplicationLoadBalancedServiceBase_IsConstruct(x interface{}) *bool
Checks if `x` is a construct.
Returns: true if `x` is an object created from a class which extends `Construct`. Deprecated: use `x instanceof Construct` instead.
func ApplicationMultipleTargetGroupsEc2Service_IsConstruct ¶
func ApplicationMultipleTargetGroupsEc2Service_IsConstruct(x interface{}) *bool
Checks if `x` is a construct.
Returns: true if `x` is an object created from a class which extends `Construct`. Deprecated: use `x instanceof Construct` instead.
func ApplicationMultipleTargetGroupsFargateService_IsConstruct ¶
func ApplicationMultipleTargetGroupsFargateService_IsConstruct(x interface{}) *bool
Checks if `x` is a construct.
Returns: true if `x` is an object created from a class which extends `Construct`. Deprecated: use `x instanceof Construct` instead.
func ApplicationMultipleTargetGroupsServiceBase_IsConstruct ¶
func ApplicationMultipleTargetGroupsServiceBase_IsConstruct(x interface{}) *bool
Checks if `x` is a construct.
Returns: true if `x` is an object created from a class which extends `Construct`. Deprecated: use `x instanceof Construct` instead.
func NetworkLoadBalancedEc2Service_IsConstruct ¶
func NetworkLoadBalancedEc2Service_IsConstruct(x interface{}) *bool
Checks if `x` is a construct.
Returns: true if `x` is an object created from a class which extends `Construct`. Deprecated: use `x instanceof Construct` instead.
func NetworkLoadBalancedFargateService_IsConstruct ¶
func NetworkLoadBalancedFargateService_IsConstruct(x interface{}) *bool
Checks if `x` is a construct.
Returns: true if `x` is an object created from a class which extends `Construct`. Deprecated: use `x instanceof Construct` instead.
func NetworkLoadBalancedServiceBase_IsConstruct ¶
func NetworkLoadBalancedServiceBase_IsConstruct(x interface{}) *bool
Checks if `x` is a construct.
Returns: true if `x` is an object created from a class which extends `Construct`. Deprecated: use `x instanceof Construct` instead.
func NetworkMultipleTargetGroupsEc2Service_IsConstruct ¶
func NetworkMultipleTargetGroupsEc2Service_IsConstruct(x interface{}) *bool
Checks if `x` is a construct.
Returns: true if `x` is an object created from a class which extends `Construct`. Deprecated: use `x instanceof Construct` instead.
func NetworkMultipleTargetGroupsFargateService_IsConstruct ¶
func NetworkMultipleTargetGroupsFargateService_IsConstruct(x interface{}) *bool
Checks if `x` is a construct.
Returns: true if `x` is an object created from a class which extends `Construct`. Deprecated: use `x instanceof Construct` instead.
func NetworkMultipleTargetGroupsServiceBase_IsConstruct ¶
func NetworkMultipleTargetGroupsServiceBase_IsConstruct(x interface{}) *bool
Checks if `x` is a construct.
Returns: true if `x` is an object created from a class which extends `Construct`. Deprecated: use `x instanceof Construct` instead.
func NewApplicationLoadBalancedEc2Service_Override ¶
func NewApplicationLoadBalancedEc2Service_Override(a ApplicationLoadBalancedEc2Service, scope constructs.Construct, id *string, props *ApplicationLoadBalancedEc2ServiceProps)
Constructs a new instance of the ApplicationLoadBalancedEc2Service class.
func NewApplicationLoadBalancedFargateService_Override ¶
func NewApplicationLoadBalancedFargateService_Override(a ApplicationLoadBalancedFargateService, scope constructs.Construct, id *string, props *ApplicationLoadBalancedFargateServiceProps)
Constructs a new instance of the ApplicationLoadBalancedFargateService class.
func NewApplicationLoadBalancedServiceBase_Override ¶
func NewApplicationLoadBalancedServiceBase_Override(a ApplicationLoadBalancedServiceBase, scope constructs.Construct, id *string, props *ApplicationLoadBalancedServiceBaseProps)
Constructs a new instance of the ApplicationLoadBalancedServiceBase class.
func NewApplicationMultipleTargetGroupsEc2Service_Override ¶
func NewApplicationMultipleTargetGroupsEc2Service_Override(a ApplicationMultipleTargetGroupsEc2Service, scope constructs.Construct, id *string, props *ApplicationMultipleTargetGroupsEc2ServiceProps)
Constructs a new instance of the ApplicationMultipleTargetGroupsEc2Service class.
func NewApplicationMultipleTargetGroupsFargateService_Override ¶
func NewApplicationMultipleTargetGroupsFargateService_Override(a ApplicationMultipleTargetGroupsFargateService, scope constructs.Construct, id *string, props *ApplicationMultipleTargetGroupsFargateServiceProps)
Constructs a new instance of the ApplicationMultipleTargetGroupsFargateService class.
func NewApplicationMultipleTargetGroupsServiceBase_Override ¶
func NewApplicationMultipleTargetGroupsServiceBase_Override(a ApplicationMultipleTargetGroupsServiceBase, scope constructs.Construct, id *string, props *ApplicationMultipleTargetGroupsServiceBaseProps)
Constructs a new instance of the ApplicationMultipleTargetGroupsServiceBase class.
func NewNetworkLoadBalancedEc2Service_Override ¶
func NewNetworkLoadBalancedEc2Service_Override(n NetworkLoadBalancedEc2Service, scope constructs.Construct, id *string, props *NetworkLoadBalancedEc2ServiceProps)
Constructs a new instance of the NetworkLoadBalancedEc2Service class.
func NewNetworkLoadBalancedFargateService_Override ¶
func NewNetworkLoadBalancedFargateService_Override(n NetworkLoadBalancedFargateService, scope constructs.Construct, id *string, props *NetworkLoadBalancedFargateServiceProps)
Constructs a new instance of the NetworkLoadBalancedFargateService class.
func NewNetworkLoadBalancedServiceBase_Override ¶
func NewNetworkLoadBalancedServiceBase_Override(n NetworkLoadBalancedServiceBase, scope constructs.Construct, id *string, props *NetworkLoadBalancedServiceBaseProps)
Constructs a new instance of the NetworkLoadBalancedServiceBase class.
func NewNetworkMultipleTargetGroupsEc2Service_Override ¶
func NewNetworkMultipleTargetGroupsEc2Service_Override(n NetworkMultipleTargetGroupsEc2Service, scope constructs.Construct, id *string, props *NetworkMultipleTargetGroupsEc2ServiceProps)
Constructs a new instance of the NetworkMultipleTargetGroupsEc2Service class.
func NewNetworkMultipleTargetGroupsFargateService_Override ¶
func NewNetworkMultipleTargetGroupsFargateService_Override(n NetworkMultipleTargetGroupsFargateService, scope constructs.Construct, id *string, props *NetworkMultipleTargetGroupsFargateServiceProps)
Constructs a new instance of the NetworkMultipleTargetGroupsFargateService class.
func NewNetworkMultipleTargetGroupsServiceBase_Override ¶
func NewNetworkMultipleTargetGroupsServiceBase_Override(n NetworkMultipleTargetGroupsServiceBase, scope constructs.Construct, id *string, props *NetworkMultipleTargetGroupsServiceBaseProps)
Constructs a new instance of the NetworkMultipleTargetGroupsServiceBase class.
func NewQueueProcessingEc2Service_Override ¶
func NewQueueProcessingEc2Service_Override(q QueueProcessingEc2Service, scope constructs.Construct, id *string, props *QueueProcessingEc2ServiceProps)
Constructs a new instance of the QueueProcessingEc2Service class.
func NewQueueProcessingFargateService_Override ¶
func NewQueueProcessingFargateService_Override(q QueueProcessingFargateService, scope constructs.Construct, id *string, props *QueueProcessingFargateServiceProps)
Constructs a new instance of the QueueProcessingFargateService class.
func NewQueueProcessingServiceBase_Override ¶
func NewQueueProcessingServiceBase_Override(q QueueProcessingServiceBase, scope constructs.Construct, id *string, props *QueueProcessingServiceBaseProps)
Constructs a new instance of the QueueProcessingServiceBase class.
func NewScheduledEc2Task_Override ¶
func NewScheduledEc2Task_Override(s ScheduledEc2Task, scope constructs.Construct, id *string, props *ScheduledEc2TaskProps)
Constructs a new instance of the ScheduledEc2Task class.
func NewScheduledFargateTask_Override ¶
func NewScheduledFargateTask_Override(s ScheduledFargateTask, scope constructs.Construct, id *string, props *ScheduledFargateTaskProps)
Constructs a new instance of the ScheduledFargateTask class.
func NewScheduledTaskBase_Override ¶
func NewScheduledTaskBase_Override(s ScheduledTaskBase, scope constructs.Construct, id *string, props *ScheduledTaskBaseProps)
Constructs a new instance of the ScheduledTaskBase class.
func QueueProcessingEc2Service_IsConstruct ¶
func QueueProcessingEc2Service_IsConstruct(x interface{}) *bool
Checks if `x` is a construct.
Returns: true if `x` is an object created from a class which extends `Construct`. Deprecated: use `x instanceof Construct` instead.
func QueueProcessingFargateService_IsConstruct ¶
func QueueProcessingFargateService_IsConstruct(x interface{}) *bool
Checks if `x` is a construct.
Returns: true if `x` is an object created from a class which extends `Construct`. Deprecated: use `x instanceof Construct` instead.
func QueueProcessingServiceBase_IsConstruct ¶
func QueueProcessingServiceBase_IsConstruct(x interface{}) *bool
Checks if `x` is a construct.
Returns: true if `x` is an object created from a class which extends `Construct`. Deprecated: use `x instanceof Construct` instead.
func ScheduledEc2Task_IsConstruct ¶
func ScheduledEc2Task_IsConstruct(x interface{}) *bool
Checks if `x` is a construct.
Returns: true if `x` is an object created from a class which extends `Construct`. Deprecated: use `x instanceof Construct` instead.
func ScheduledFargateTask_IsConstruct ¶
func ScheduledFargateTask_IsConstruct(x interface{}) *bool
Checks if `x` is a construct.
Returns: true if `x` is an object created from a class which extends `Construct`. Deprecated: use `x instanceof Construct` instead.
func ScheduledTaskBase_IsConstruct ¶
func ScheduledTaskBase_IsConstruct(x interface{}) *bool
Checks if `x` is a construct.
Returns: true if `x` is an object created from a class which extends `Construct`. Deprecated: use `x instanceof Construct` instead.
Types ¶
type ApplicationListenerProps ¶
type ApplicationListenerProps struct { // Name of the listener. Name *string `field:"required" json:"name" yaml:"name"` // Certificate Manager certificate to associate with the load balancer. // // Setting this option will set the load balancer protocol to HTTPS. Certificate awscertificatemanager.ICertificate `field:"optional" json:"certificate" yaml:"certificate"` // The port on which the listener listens for requests. Port *float64 `field:"optional" json:"port" yaml:"port"` // The protocol for connections from clients to the load balancer. // // The load balancer port is determined from the protocol (port 80 for // HTTP, port 443 for HTTPS). A domain name and zone must be also be // specified if using HTTPS. Protocol awselasticloadbalancingv2.ApplicationProtocol `field:"optional" json:"protocol" yaml:"protocol"` // The security policy that defines which ciphers and protocols are supported by the ALB Listener. SslPolicy awselasticloadbalancingv2.SslPolicy `field:"optional" json:"sslPolicy" yaml:"sslPolicy"` }
Properties to define an application listener.
Example:
// 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" var certificate certificate applicationListenerProps := &applicationListenerProps{ name: jsii.String("name"), // the properties below are optional certificate: certificate, port: jsii.Number(123), protocol: awscdk.Aws_elasticloadbalancingv2.applicationProtocol_HTTP, sslPolicy: awscdk.*Aws_elasticloadbalancingv2.sslPolicy_RECOMMENDED, }
type ApplicationLoadBalancedEc2Service ¶
type ApplicationLoadBalancedEc2Service interface { ApplicationLoadBalancedServiceBase // Certificate Manager certificate to associate with the load balancer. Certificate() awscertificatemanager.ICertificate // The cluster that hosts the service. Cluster() awsecs.ICluster // The desired number of instantiations of the task definition to keep running on the service. // // The default is 1 for all new services and uses the existing services desired count // when updating an existing service if one is not provided. InternalDesiredCount() *float64 // The listener for the service. Listener() awselasticloadbalancingv2.ApplicationListener // The Application Load Balancer for the service. LoadBalancer() awselasticloadbalancingv2.ApplicationLoadBalancer // The tree node. Node() constructs.Node // The redirect listener for the service if redirectHTTP is enabled. RedirectListener() awselasticloadbalancingv2.ApplicationListener // The EC2 service in this construct. Service() awsecs.Ec2Service // The target group for the service. TargetGroup() awselasticloadbalancingv2.ApplicationTargetGroup // The EC2 Task Definition in this construct. TaskDefinition() awsecs.Ec2TaskDefinition // Adds service as a target of the target group. AddServiceAsTarget(service awsecs.BaseService) CreateAWSLogDriver(prefix *string) awsecs.AwsLogDriver // Returns the default cluster. GetDefaultCluster(scope constructs.Construct, vpc awsec2.IVpc) awsecs.Cluster // Returns a string representation of this construct. ToString() *string }
An EC2 service running on an ECS cluster fronted by an application load balancer.
Example:
var cluster cluster loadBalancedEcsService := ecsPatterns.NewApplicationLoadBalancedEc2Service(this, jsii.String("Service"), &applicationLoadBalancedEc2ServiceProps{ cluster: cluster, memoryLimitMiB: jsii.Number(1024), taskImageOptions: &applicationLoadBalancedTaskImageOptions{ image: ecs.containerImage.fromRegistry(jsii.String("test")), environment: map[string]*string{ "TEST_ENVIRONMENT_VARIABLE1": jsii.String("test environment variable 1 value"), "TEST_ENVIRONMENT_VARIABLE2": jsii.String("test environment variable 2 value"), }, }, desiredCount: jsii.Number(2), })
func NewApplicationLoadBalancedEc2Service ¶
func NewApplicationLoadBalancedEc2Service(scope constructs.Construct, id *string, props *ApplicationLoadBalancedEc2ServiceProps) ApplicationLoadBalancedEc2Service
Constructs a new instance of the ApplicationLoadBalancedEc2Service class.
type ApplicationLoadBalancedEc2ServiceProps ¶
type ApplicationLoadBalancedEc2ServiceProps struct { // Certificate Manager certificate to associate with the load balancer. // // Setting this option will set the load balancer protocol to HTTPS. Certificate awscertificatemanager.ICertificate `field:"optional" json:"certificate" yaml:"certificate"` // Whether to enable the deployment circuit breaker. // // If this property is defined, circuit breaker will be implicitly // enabled. CircuitBreaker *awsecs.DeploymentCircuitBreaker `field:"optional" json:"circuitBreaker" yaml:"circuitBreaker"` // The options for configuring an Amazon ECS service to use service discovery. CloudMapOptions *awsecs.CloudMapOptions `field:"optional" json:"cloudMapOptions" yaml:"cloudMapOptions"` // The name of the cluster that hosts the service. // // If a cluster is specified, the vpc construct should be omitted. Alternatively, you can omit both cluster and vpc. Cluster awsecs.ICluster `field:"optional" json:"cluster" yaml:"cluster"` // Specifies which deployment controller to use for the service. // // For more information, see // [Amazon ECS Deployment Types](https://docs.aws.amazon.com/AmazonECS/latest/developerguide/deployment-types.html) DeploymentController *awsecs.DeploymentController `field:"optional" json:"deploymentController" yaml:"deploymentController"` // The desired number of instantiations of the task definition to keep running on the service. // // The minimum value is 1. DesiredCount *float64 `field:"optional" json:"desiredCount" yaml:"desiredCount"` // The domain name for the service, e.g. "api.example.com.". DomainName *string `field:"optional" json:"domainName" yaml:"domainName"` // The Route53 hosted zone for the domain, e.g. "example.com.". DomainZone awsroute53.IHostedZone `field:"optional" json:"domainZone" yaml:"domainZone"` // Specifies whether to enable Amazon ECS managed tags for the tasks within the service. // // For more information, see // [Tagging Your Amazon ECS Resources](https://docs.aws.amazon.com/AmazonECS/latest/developerguide/ecs-using-tags.html) EnableECSManagedTags *bool `field:"optional" json:"enableECSManagedTags" yaml:"enableECSManagedTags"` // The period of time, in seconds, that the Amazon ECS service scheduler ignores unhealthy Elastic Load Balancing target health checks after a task has first started. HealthCheckGracePeriod awscdk.Duration `field:"optional" json:"healthCheckGracePeriod" yaml:"healthCheckGracePeriod"` // Listener port of the application load balancer that will serve traffic to the service. ListenerPort *float64 `field:"optional" json:"listenerPort" yaml:"listenerPort"` // The application load balancer that will serve traffic to the service. // // The VPC attribute of a load balancer must be specified for it to be used // to create a new service with this pattern. // // [disable-awslint:ref-via-interface]. LoadBalancer awselasticloadbalancingv2.IApplicationLoadBalancer `field:"optional" json:"loadBalancer" yaml:"loadBalancer"` // Name of the load balancer. LoadBalancerName *string `field:"optional" json:"loadBalancerName" yaml:"loadBalancerName"` // The maximum number of tasks, specified as a percentage of the Amazon ECS service's DesiredCount value, that can run in a service during a deployment. MaxHealthyPercent *float64 `field:"optional" json:"maxHealthyPercent" yaml:"maxHealthyPercent"` // The minimum number of tasks, specified as a percentage of the Amazon ECS service's DesiredCount value, that must continue to run and remain healthy during a deployment. MinHealthyPercent *float64 `field:"optional" json:"minHealthyPercent" yaml:"minHealthyPercent"` // Determines whether or not the Security Group for the Load Balancer's Listener will be open to all traffic by default. OpenListener *bool `field:"optional" json:"openListener" yaml:"openListener"` // Specifies whether to propagate the tags from the task definition or the service to the tasks in the service. // // Tags can only be propagated to the tasks within the service during service creation. PropagateTags awsecs.PropagatedTagSource `field:"optional" json:"propagateTags" yaml:"propagateTags"` // The protocol for connections from clients to the load balancer. // // The load balancer port is determined from the protocol (port 80 for // HTTP, port 443 for HTTPS). A domain name and zone must be also be // specified if using HTTPS. Protocol awselasticloadbalancingv2.ApplicationProtocol `field:"optional" json:"protocol" yaml:"protocol"` // The protocol version to use. ProtocolVersion awselasticloadbalancingv2.ApplicationProtocolVersion `field:"optional" json:"protocolVersion" yaml:"protocolVersion"` // Determines whether the Load Balancer will be internet-facing. PublicLoadBalancer *bool `field:"optional" json:"publicLoadBalancer" yaml:"publicLoadBalancer"` // Specifies whether the Route53 record should be a CNAME, an A record using the Alias feature or no record at all. // // This is useful if you need to work with DNS systems that do not support alias records. RecordType ApplicationLoadBalancedServiceRecordType `field:"optional" json:"recordType" yaml:"recordType"` // Specifies whether the load balancer should redirect traffic on port 80 to port 443 to support HTTP->HTTPS redirects This is only valid if the protocol of the ALB is HTTPS. RedirectHTTP *bool `field:"optional" json:"redirectHTTP" yaml:"redirectHTTP"` // The name of the service. ServiceName *string `field:"optional" json:"serviceName" yaml:"serviceName"` // The security policy that defines which ciphers and protocols are supported by the ALB Listener. SslPolicy awselasticloadbalancingv2.SslPolicy `field:"optional" json:"sslPolicy" yaml:"sslPolicy"` // The protocol for connections from the load balancer to the ECS tasks. // // The default target port is determined from the protocol (port 80 for // HTTP, port 443 for HTTPS). TargetProtocol awselasticloadbalancingv2.ApplicationProtocol `field:"optional" json:"targetProtocol" yaml:"targetProtocol"` // The properties required to create a new task definition. // // TaskDefinition or TaskImageOptions must be specified, but not both. TaskImageOptions *ApplicationLoadBalancedTaskImageOptions `field:"optional" json:"taskImageOptions" yaml:"taskImageOptions"` // The VPC where the container instances will be launched or the elastic network interfaces (ENIs) will be deployed. // // If a vpc is specified, the cluster construct should be omitted. Alternatively, you can omit both vpc and cluster. Vpc awsec2.IVpc `field:"optional" json:"vpc" yaml:"vpc"` // The number of cpu units used by the task. // // Valid values, which determines your range of valid values for the memory parameter: // // 256 (.25 vCPU) - Available memory values: 0.5GB, 1GB, 2GB // // 512 (.5 vCPU) - Available memory values: 1GB, 2GB, 3GB, 4GB // // 1024 (1 vCPU) - Available memory values: 2GB, 3GB, 4GB, 5GB, 6GB, 7GB, 8GB // // 2048 (2 vCPU) - Available memory values: Between 4GB and 16GB in 1GB increments // // 4096 (4 vCPU) - Available memory values: Between 8GB and 30GB in 1GB increments // // This default is set in the underlying FargateTaskDefinition construct. Cpu *float64 `field:"optional" json:"cpu" yaml:"cpu"` // The hard limit (in MiB) of memory to present to the container. // // If your container attempts to exceed the allocated memory, the container // is terminated. // // At least one of memoryLimitMiB and memoryReservationMiB is required. MemoryLimitMiB *float64 `field:"optional" json:"memoryLimitMiB" yaml:"memoryLimitMiB"` // The soft limit (in MiB) of memory to reserve for the container. // // When system memory is under contention, Docker attempts to keep the // container memory within the limit. If the container requires more memory, // it can consume up to the value specified by the Memory property or all of // the available memory on the container instance—whichever comes first. // // At least one of memoryLimitMiB and memoryReservationMiB is required. MemoryReservationMiB *float64 `field:"optional" json:"memoryReservationMiB" yaml:"memoryReservationMiB"` // The placement constraints to use for tasks in the service. // // For more information, see // [Amazon ECS Task Placement Constraints](https://docs.aws.amazon.com/AmazonECS/latest/developerguide/task-placement-constraints.html). PlacementConstraints *[]awsecs.PlacementConstraint `field:"optional" json:"placementConstraints" yaml:"placementConstraints"` // The placement strategies to use for tasks in the service. // // For more information, see // [Amazon ECS Task Placement Strategies](https://docs.aws.amazon.com/AmazonECS/latest/developerguide/task-placement-strategies.html). PlacementStrategies *[]awsecs.PlacementStrategy `field:"optional" json:"placementStrategies" yaml:"placementStrategies"` // The task definition to use for tasks in the service. TaskDefinition or TaskImageOptions must be specified, but not both.. // // [disable-awslint:ref-via-interface]. TaskDefinition awsecs.Ec2TaskDefinition `field:"optional" json:"taskDefinition" yaml:"taskDefinition"` }
The properties for the ApplicationLoadBalancedEc2Service service.
Example:
var cluster cluster loadBalancedEcsService := ecsPatterns.NewApplicationLoadBalancedEc2Service(this, jsii.String("Service"), &applicationLoadBalancedEc2ServiceProps{ cluster: cluster, memoryLimitMiB: jsii.Number(1024), taskImageOptions: &applicationLoadBalancedTaskImageOptions{ image: ecs.containerImage.fromRegistry(jsii.String("test")), environment: map[string]*string{ "TEST_ENVIRONMENT_VARIABLE1": jsii.String("test environment variable 1 value"), "TEST_ENVIRONMENT_VARIABLE2": jsii.String("test environment variable 2 value"), }, }, desiredCount: jsii.Number(2), })
type ApplicationLoadBalancedFargateService ¶
type ApplicationLoadBalancedFargateService interface { ApplicationLoadBalancedServiceBase // Determines whether the service will be assigned a public IP address. AssignPublicIp() *bool // Certificate Manager certificate to associate with the load balancer. Certificate() awscertificatemanager.ICertificate // The cluster that hosts the service. Cluster() awsecs.ICluster // The desired number of instantiations of the task definition to keep running on the service. // // The default is 1 for all new services and uses the existing services desired count // when updating an existing service if one is not provided. InternalDesiredCount() *float64 // The listener for the service. Listener() awselasticloadbalancingv2.ApplicationListener // The Application Load Balancer for the service. LoadBalancer() awselasticloadbalancingv2.ApplicationLoadBalancer // The tree node. Node() constructs.Node // The redirect listener for the service if redirectHTTP is enabled. RedirectListener() awselasticloadbalancingv2.ApplicationListener // The Fargate service in this construct. Service() awsecs.FargateService // The target group for the service. TargetGroup() awselasticloadbalancingv2.ApplicationTargetGroup // The Fargate task definition in this construct. TaskDefinition() awsecs.FargateTaskDefinition // Adds service as a target of the target group. AddServiceAsTarget(service awsecs.BaseService) CreateAWSLogDriver(prefix *string) awsecs.AwsLogDriver // Returns the default cluster. GetDefaultCluster(scope constructs.Construct, vpc awsec2.IVpc) awsecs.Cluster // Returns a string representation of this construct. ToString() *string }
A Fargate service running on an ECS cluster fronted by an application load balancer.
Example:
var cluster cluster loadBalancedFargateService := ecsPatterns.NewApplicationLoadBalancedFargateService(this, jsii.String("Service"), &applicationLoadBalancedFargateServiceProps{ cluster: cluster, memoryLimitMiB: jsii.Number(1024), desiredCount: jsii.Number(1), cpu: jsii.Number(512), taskImageOptions: &applicationLoadBalancedTaskImageOptions{ image: ecs.containerImage.fromRegistry(jsii.String("amazon/amazon-ecs-sample")), }, }) scalableTarget := loadBalancedFargateService.service.autoScaleTaskCount(&enableScalingProps{ minCapacity: jsii.Number(1), maxCapacity: jsii.Number(20), }) scalableTarget.scaleOnCpuUtilization(jsii.String("CpuScaling"), &cpuUtilizationScalingProps{ targetUtilizationPercent: jsii.Number(50), }) scalableTarget.scaleOnMemoryUtilization(jsii.String("MemoryScaling"), &memoryUtilizationScalingProps{ targetUtilizationPercent: jsii.Number(50), })
func NewApplicationLoadBalancedFargateService ¶
func NewApplicationLoadBalancedFargateService(scope constructs.Construct, id *string, props *ApplicationLoadBalancedFargateServiceProps) ApplicationLoadBalancedFargateService
Constructs a new instance of the ApplicationLoadBalancedFargateService class.
type ApplicationLoadBalancedFargateServiceProps ¶
type ApplicationLoadBalancedFargateServiceProps struct { // Certificate Manager certificate to associate with the load balancer. // // Setting this option will set the load balancer protocol to HTTPS. Certificate awscertificatemanager.ICertificate `field:"optional" json:"certificate" yaml:"certificate"` // Whether to enable the deployment circuit breaker. // // If this property is defined, circuit breaker will be implicitly // enabled. CircuitBreaker *awsecs.DeploymentCircuitBreaker `field:"optional" json:"circuitBreaker" yaml:"circuitBreaker"` // The options for configuring an Amazon ECS service to use service discovery. CloudMapOptions *awsecs.CloudMapOptions `field:"optional" json:"cloudMapOptions" yaml:"cloudMapOptions"` // The name of the cluster that hosts the service. // // If a cluster is specified, the vpc construct should be omitted. Alternatively, you can omit both cluster and vpc. Cluster awsecs.ICluster `field:"optional" json:"cluster" yaml:"cluster"` // Specifies which deployment controller to use for the service. // // For more information, see // [Amazon ECS Deployment Types](https://docs.aws.amazon.com/AmazonECS/latest/developerguide/deployment-types.html) DeploymentController *awsecs.DeploymentController `field:"optional" json:"deploymentController" yaml:"deploymentController"` // The desired number of instantiations of the task definition to keep running on the service. // // The minimum value is 1. DesiredCount *float64 `field:"optional" json:"desiredCount" yaml:"desiredCount"` // The domain name for the service, e.g. "api.example.com.". DomainName *string `field:"optional" json:"domainName" yaml:"domainName"` // The Route53 hosted zone for the domain, e.g. "example.com.". DomainZone awsroute53.IHostedZone `field:"optional" json:"domainZone" yaml:"domainZone"` // Specifies whether to enable Amazon ECS managed tags for the tasks within the service. // // For more information, see // [Tagging Your Amazon ECS Resources](https://docs.aws.amazon.com/AmazonECS/latest/developerguide/ecs-using-tags.html) EnableECSManagedTags *bool `field:"optional" json:"enableECSManagedTags" yaml:"enableECSManagedTags"` // The period of time, in seconds, that the Amazon ECS service scheduler ignores unhealthy Elastic Load Balancing target health checks after a task has first started. HealthCheckGracePeriod awscdk.Duration `field:"optional" json:"healthCheckGracePeriod" yaml:"healthCheckGracePeriod"` // Listener port of the application load balancer that will serve traffic to the service. ListenerPort *float64 `field:"optional" json:"listenerPort" yaml:"listenerPort"` // The application load balancer that will serve traffic to the service. // // The VPC attribute of a load balancer must be specified for it to be used // to create a new service with this pattern. // // [disable-awslint:ref-via-interface]. LoadBalancer awselasticloadbalancingv2.IApplicationLoadBalancer `field:"optional" json:"loadBalancer" yaml:"loadBalancer"` // Name of the load balancer. LoadBalancerName *string `field:"optional" json:"loadBalancerName" yaml:"loadBalancerName"` // The maximum number of tasks, specified as a percentage of the Amazon ECS service's DesiredCount value, that can run in a service during a deployment. MaxHealthyPercent *float64 `field:"optional" json:"maxHealthyPercent" yaml:"maxHealthyPercent"` // The minimum number of tasks, specified as a percentage of the Amazon ECS service's DesiredCount value, that must continue to run and remain healthy during a deployment. MinHealthyPercent *float64 `field:"optional" json:"minHealthyPercent" yaml:"minHealthyPercent"` // Determines whether or not the Security Group for the Load Balancer's Listener will be open to all traffic by default. OpenListener *bool `field:"optional" json:"openListener" yaml:"openListener"` // Specifies whether to propagate the tags from the task definition or the service to the tasks in the service. // // Tags can only be propagated to the tasks within the service during service creation. PropagateTags awsecs.PropagatedTagSource `field:"optional" json:"propagateTags" yaml:"propagateTags"` // The protocol for connections from clients to the load balancer. // // The load balancer port is determined from the protocol (port 80 for // HTTP, port 443 for HTTPS). A domain name and zone must be also be // specified if using HTTPS. Protocol awselasticloadbalancingv2.ApplicationProtocol `field:"optional" json:"protocol" yaml:"protocol"` // The protocol version to use. ProtocolVersion awselasticloadbalancingv2.ApplicationProtocolVersion `field:"optional" json:"protocolVersion" yaml:"protocolVersion"` // Determines whether the Load Balancer will be internet-facing. PublicLoadBalancer *bool `field:"optional" json:"publicLoadBalancer" yaml:"publicLoadBalancer"` // Specifies whether the Route53 record should be a CNAME, an A record using the Alias feature or no record at all. // // This is useful if you need to work with DNS systems that do not support alias records. RecordType ApplicationLoadBalancedServiceRecordType `field:"optional" json:"recordType" yaml:"recordType"` // Specifies whether the load balancer should redirect traffic on port 80 to port 443 to support HTTP->HTTPS redirects This is only valid if the protocol of the ALB is HTTPS. RedirectHTTP *bool `field:"optional" json:"redirectHTTP" yaml:"redirectHTTP"` // The name of the service. ServiceName *string `field:"optional" json:"serviceName" yaml:"serviceName"` // The security policy that defines which ciphers and protocols are supported by the ALB Listener. SslPolicy awselasticloadbalancingv2.SslPolicy `field:"optional" json:"sslPolicy" yaml:"sslPolicy"` // The protocol for connections from the load balancer to the ECS tasks. // // The default target port is determined from the protocol (port 80 for // HTTP, port 443 for HTTPS). TargetProtocol awselasticloadbalancingv2.ApplicationProtocol `field:"optional" json:"targetProtocol" yaml:"targetProtocol"` // The properties required to create a new task definition. // // TaskDefinition or TaskImageOptions must be specified, but not both. TaskImageOptions *ApplicationLoadBalancedTaskImageOptions `field:"optional" json:"taskImageOptions" yaml:"taskImageOptions"` // The VPC where the container instances will be launched or the elastic network interfaces (ENIs) will be deployed. // // If a vpc is specified, the cluster construct should be omitted. Alternatively, you can omit both vpc and cluster. Vpc awsec2.IVpc `field:"optional" json:"vpc" yaml:"vpc"` // Determines whether the service will be assigned a public IP address. AssignPublicIp *bool `field:"optional" json:"assignPublicIp" yaml:"assignPublicIp"` // The number of cpu units used by the task. // // Valid values, which determines your range of valid values for the memory parameter: // // 256 (.25 vCPU) - Available memory values: 0.5GB, 1GB, 2GB // // 512 (.5 vCPU) - Available memory values: 1GB, 2GB, 3GB, 4GB // // 1024 (1 vCPU) - Available memory values: 2GB, 3GB, 4GB, 5GB, 6GB, 7GB, 8GB // // 2048 (2 vCPU) - Available memory values: Between 4GB and 16GB in 1GB increments // // 4096 (4 vCPU) - Available memory values: Between 8GB and 30GB in 1GB increments // // This default is set in the underlying FargateTaskDefinition construct. Cpu *float64 `field:"optional" json:"cpu" yaml:"cpu"` // The amount (in MiB) of memory used by the task. // // This field is required and you must use one of the following values, which determines your range of valid values // for the cpu parameter: // // 512 (0.5 GB), 1024 (1 GB), 2048 (2 GB) - Available cpu values: 256 (.25 vCPU) // // 1024 (1 GB), 2048 (2 GB), 3072 (3 GB), 4096 (4 GB) - Available cpu values: 512 (.5 vCPU) // // 2048 (2 GB), 3072 (3 GB), 4096 (4 GB), 5120 (5 GB), 6144 (6 GB), 7168 (7 GB), 8192 (8 GB) - Available cpu values: 1024 (1 vCPU) // // Between 4096 (4 GB) and 16384 (16 GB) in increments of 1024 (1 GB) - Available cpu values: 2048 (2 vCPU) // // Between 8192 (8 GB) and 30720 (30 GB) in increments of 1024 (1 GB) - Available cpu values: 4096 (4 vCPU) // // This default is set in the underlying FargateTaskDefinition construct. MemoryLimitMiB *float64 `field:"optional" json:"memoryLimitMiB" yaml:"memoryLimitMiB"` // The platform version on which to run your service. // // If one is not specified, the LATEST platform version is used by default. For more information, see // [AWS Fargate Platform Versions](https://docs.aws.amazon.com/AmazonECS/latest/developerguide/platform_versions.html) // in the Amazon Elastic Container Service Developer Guide. PlatformVersion awsecs.FargatePlatformVersion `field:"optional" json:"platformVersion" yaml:"platformVersion"` // The security groups to associate with the service. // // If you do not specify a security group, a new security group is created. SecurityGroups *[]awsec2.ISecurityGroup `field:"optional" json:"securityGroups" yaml:"securityGroups"` // The task definition to use for tasks in the service. TaskDefinition or TaskImageOptions must be specified, but not both. // // [disable-awslint:ref-via-interface]. TaskDefinition awsecs.FargateTaskDefinition `field:"optional" json:"taskDefinition" yaml:"taskDefinition"` // The subnets to associate with the service. TaskSubnets *awsec2.SubnetSelection `field:"optional" json:"taskSubnets" yaml:"taskSubnets"` }
The properties for the ApplicationLoadBalancedFargateService service.
Example:
var cluster cluster loadBalancedFargateService := ecsPatterns.NewApplicationLoadBalancedFargateService(this, jsii.String("Service"), &applicationLoadBalancedFargateServiceProps{ cluster: cluster, memoryLimitMiB: jsii.Number(1024), desiredCount: jsii.Number(1), cpu: jsii.Number(512), taskImageOptions: &applicationLoadBalancedTaskImageOptions{ image: ecs.containerImage.fromRegistry(jsii.String("amazon/amazon-ecs-sample")), }, }) scalableTarget := loadBalancedFargateService.service.autoScaleTaskCount(&enableScalingProps{ minCapacity: jsii.Number(1), maxCapacity: jsii.Number(20), }) scalableTarget.scaleOnCpuUtilization(jsii.String("CpuScaling"), &cpuUtilizationScalingProps{ targetUtilizationPercent: jsii.Number(50), }) scalableTarget.scaleOnMemoryUtilization(jsii.String("MemoryScaling"), &memoryUtilizationScalingProps{ targetUtilizationPercent: jsii.Number(50), })
type ApplicationLoadBalancedServiceBase ¶
type ApplicationLoadBalancedServiceBase interface { constructs.Construct // Certificate Manager certificate to associate with the load balancer. Certificate() awscertificatemanager.ICertificate // The cluster that hosts the service. Cluster() awsecs.ICluster // The desired number of instantiations of the task definition to keep running on the service. // // The default is 1 for all new services and uses the existing services desired count // when updating an existing service if one is not provided. InternalDesiredCount() *float64 // The listener for the service. Listener() awselasticloadbalancingv2.ApplicationListener // The Application Load Balancer for the service. LoadBalancer() awselasticloadbalancingv2.ApplicationLoadBalancer // The tree node. Node() constructs.Node // The redirect listener for the service if redirectHTTP is enabled. RedirectListener() awselasticloadbalancingv2.ApplicationListener // The target group for the service. TargetGroup() awselasticloadbalancingv2.ApplicationTargetGroup // Adds service as a target of the target group. AddServiceAsTarget(service awsecs.BaseService) CreateAWSLogDriver(prefix *string) awsecs.AwsLogDriver // Returns the default cluster. GetDefaultCluster(scope constructs.Construct, vpc awsec2.IVpc) awsecs.Cluster // Returns a string representation of this construct. ToString() *string }
The base class for ApplicationLoadBalancedEc2Service and ApplicationLoadBalancedFargateService services.
type ApplicationLoadBalancedServiceBaseProps ¶
type ApplicationLoadBalancedServiceBaseProps struct { // Certificate Manager certificate to associate with the load balancer. // // Setting this option will set the load balancer protocol to HTTPS. Certificate awscertificatemanager.ICertificate `field:"optional" json:"certificate" yaml:"certificate"` // Whether to enable the deployment circuit breaker. // // If this property is defined, circuit breaker will be implicitly // enabled. CircuitBreaker *awsecs.DeploymentCircuitBreaker `field:"optional" json:"circuitBreaker" yaml:"circuitBreaker"` // The options for configuring an Amazon ECS service to use service discovery. CloudMapOptions *awsecs.CloudMapOptions `field:"optional" json:"cloudMapOptions" yaml:"cloudMapOptions"` // The name of the cluster that hosts the service. // // If a cluster is specified, the vpc construct should be omitted. Alternatively, you can omit both cluster and vpc. Cluster awsecs.ICluster `field:"optional" json:"cluster" yaml:"cluster"` // Specifies which deployment controller to use for the service. // // For more information, see // [Amazon ECS Deployment Types](https://docs.aws.amazon.com/AmazonECS/latest/developerguide/deployment-types.html) DeploymentController *awsecs.DeploymentController `field:"optional" json:"deploymentController" yaml:"deploymentController"` // The desired number of instantiations of the task definition to keep running on the service. // // The minimum value is 1. DesiredCount *float64 `field:"optional" json:"desiredCount" yaml:"desiredCount"` // The domain name for the service, e.g. "api.example.com.". DomainName *string `field:"optional" json:"domainName" yaml:"domainName"` // The Route53 hosted zone for the domain, e.g. "example.com.". DomainZone awsroute53.IHostedZone `field:"optional" json:"domainZone" yaml:"domainZone"` // Specifies whether to enable Amazon ECS managed tags for the tasks within the service. // // For more information, see // [Tagging Your Amazon ECS Resources](https://docs.aws.amazon.com/AmazonECS/latest/developerguide/ecs-using-tags.html) EnableECSManagedTags *bool `field:"optional" json:"enableECSManagedTags" yaml:"enableECSManagedTags"` // The period of time, in seconds, that the Amazon ECS service scheduler ignores unhealthy Elastic Load Balancing target health checks after a task has first started. HealthCheckGracePeriod awscdk.Duration `field:"optional" json:"healthCheckGracePeriod" yaml:"healthCheckGracePeriod"` // Listener port of the application load balancer that will serve traffic to the service. ListenerPort *float64 `field:"optional" json:"listenerPort" yaml:"listenerPort"` // The application load balancer that will serve traffic to the service. // // The VPC attribute of a load balancer must be specified for it to be used // to create a new service with this pattern. // // [disable-awslint:ref-via-interface]. LoadBalancer awselasticloadbalancingv2.IApplicationLoadBalancer `field:"optional" json:"loadBalancer" yaml:"loadBalancer"` // Name of the load balancer. LoadBalancerName *string `field:"optional" json:"loadBalancerName" yaml:"loadBalancerName"` // The maximum number of tasks, specified as a percentage of the Amazon ECS service's DesiredCount value, that can run in a service during a deployment. MaxHealthyPercent *float64 `field:"optional" json:"maxHealthyPercent" yaml:"maxHealthyPercent"` // The minimum number of tasks, specified as a percentage of the Amazon ECS service's DesiredCount value, that must continue to run and remain healthy during a deployment. MinHealthyPercent *float64 `field:"optional" json:"minHealthyPercent" yaml:"minHealthyPercent"` // Determines whether or not the Security Group for the Load Balancer's Listener will be open to all traffic by default. OpenListener *bool `field:"optional" json:"openListener" yaml:"openListener"` // Specifies whether to propagate the tags from the task definition or the service to the tasks in the service. // // Tags can only be propagated to the tasks within the service during service creation. PropagateTags awsecs.PropagatedTagSource `field:"optional" json:"propagateTags" yaml:"propagateTags"` // The protocol for connections from clients to the load balancer. // // The load balancer port is determined from the protocol (port 80 for // HTTP, port 443 for HTTPS). A domain name and zone must be also be // specified if using HTTPS. Protocol awselasticloadbalancingv2.ApplicationProtocol `field:"optional" json:"protocol" yaml:"protocol"` // The protocol version to use. ProtocolVersion awselasticloadbalancingv2.ApplicationProtocolVersion `field:"optional" json:"protocolVersion" yaml:"protocolVersion"` // Determines whether the Load Balancer will be internet-facing. PublicLoadBalancer *bool `field:"optional" json:"publicLoadBalancer" yaml:"publicLoadBalancer"` // Specifies whether the Route53 record should be a CNAME, an A record using the Alias feature or no record at all. // // This is useful if you need to work with DNS systems that do not support alias records. RecordType ApplicationLoadBalancedServiceRecordType `field:"optional" json:"recordType" yaml:"recordType"` // Specifies whether the load balancer should redirect traffic on port 80 to port 443 to support HTTP->HTTPS redirects This is only valid if the protocol of the ALB is HTTPS. RedirectHTTP *bool `field:"optional" json:"redirectHTTP" yaml:"redirectHTTP"` // The name of the service. ServiceName *string `field:"optional" json:"serviceName" yaml:"serviceName"` // The security policy that defines which ciphers and protocols are supported by the ALB Listener. SslPolicy awselasticloadbalancingv2.SslPolicy `field:"optional" json:"sslPolicy" yaml:"sslPolicy"` // The protocol for connections from the load balancer to the ECS tasks. // // The default target port is determined from the protocol (port 80 for // HTTP, port 443 for HTTPS). TargetProtocol awselasticloadbalancingv2.ApplicationProtocol `field:"optional" json:"targetProtocol" yaml:"targetProtocol"` // The properties required to create a new task definition. // // TaskDefinition or TaskImageOptions must be specified, but not both. TaskImageOptions *ApplicationLoadBalancedTaskImageOptions `field:"optional" json:"taskImageOptions" yaml:"taskImageOptions"` // The VPC where the container instances will be launched or the elastic network interfaces (ENIs) will be deployed. // // If a vpc is specified, the cluster construct should be omitted. Alternatively, you can omit both vpc and cluster. Vpc awsec2.IVpc `field:"optional" json:"vpc" yaml:"vpc"` }
The properties for the base ApplicationLoadBalancedEc2Service or ApplicationLoadBalancedFargateService service.
Example:
// The code below shows an example of how to instantiate this type. // The values are placeholders you should change. import cdk "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" import "github.com/aws/aws-cdk-go/awscdk" var applicationLoadBalancer applicationLoadBalancer var certificate certificate var cluster cluster var containerDefinition containerDefinition var containerImage containerImage var hostedZone hostedZone var logDriver logDriver var namespace iNamespace var role role var secret secret var vpc vpc applicationLoadBalancedServiceBaseProps := &applicationLoadBalancedServiceBaseProps{ certificate: certificate, circuitBreaker: &deploymentCircuitBreaker{ 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), healthCheckGracePeriod: cdk.*duration.minutes(jsii.Number(30)), listenerPort: jsii.Number(123), loadBalancer: applicationLoadBalancer, loadBalancerName: jsii.String("loadBalancerName"), maxHealthyPercent: jsii.Number(123), minHealthyPercent: jsii.Number(123), openListener: jsii.Boolean(false), propagateTags: awscdk.*Aws_ecs.propagatedTagSource_SERVICE, protocol: awscdk.Aws_elasticloadbalancingv2.applicationProtocol_HTTP, protocolVersion: awscdk.*Aws_elasticloadbalancingv2.applicationProtocolVersion_GRPC, publicLoadBalancer: jsii.Boolean(false), recordType: awscdk.Aws_ecs_patterns.applicationLoadBalancedServiceRecordType_ALIAS, redirectHTTP: jsii.Boolean(false), serviceName: jsii.String("serviceName"), sslPolicy: awscdk.*Aws_elasticloadbalancingv2.sslPolicy_RECOMMENDED, targetProtocol: awscdk.*Aws_elasticloadbalancingv2.*applicationProtocol_HTTP, taskImageOptions: &applicationLoadBalancedTaskImageOptions{ 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, }
type ApplicationLoadBalancedServiceRecordType ¶
type ApplicationLoadBalancedServiceRecordType string
Describes the type of DNS record the service should create.
const ( // Create Route53 A Alias record. ApplicationLoadBalancedServiceRecordType_ALIAS ApplicationLoadBalancedServiceRecordType = "ALIAS" // Create a CNAME record. ApplicationLoadBalancedServiceRecordType_CNAME ApplicationLoadBalancedServiceRecordType = "CNAME" // Do not create any DNS records. ApplicationLoadBalancedServiceRecordType_NONE ApplicationLoadBalancedServiceRecordType = "NONE" )
type ApplicationLoadBalancedTaskImageOptions ¶
type ApplicationLoadBalancedTaskImageOptions struct { // The image used to start a container. // // Image or taskDefinition must be specified, not both. Image awsecs.ContainerImage `field:"required" json:"image" yaml:"image"` // The container name value to be specified in the task definition. ContainerName *string `field:"optional" json:"containerName" yaml:"containerName"` // The port number on the container that is bound to the user-specified or automatically assigned host port. // // If you are using containers in a task with the awsvpc or host network mode, exposed ports should be specified using containerPort. // If you are using containers in a task with the bridge network mode and you specify a container port and not a host port, // your container automatically receives a host port in the ephemeral port range. // // Port mappings that are automatically assigned in this way do not count toward the 100 reserved ports limit of a container instance. // // For more information, see // [hostPort](https://docs.aws.amazon.com/AmazonECS/latest/APIReference/API_PortMapping.html#ECS-Type-PortMapping-hostPort). ContainerPort *float64 `field:"optional" json:"containerPort" yaml:"containerPort"` // A key/value map of labels to add to the container. DockerLabels *map[string]*string `field:"optional" json:"dockerLabels" yaml:"dockerLabels"` // Flag to indicate whether to enable logging. EnableLogging *bool `field:"optional" json:"enableLogging" yaml:"enableLogging"` // The environment variables to pass to the container. Environment *map[string]*string `field:"optional" json:"environment" yaml:"environment"` // The name of the task execution IAM role that grants the Amazon ECS container agent permission to call AWS APIs on your behalf. ExecutionRole awsiam.IRole `field:"optional" json:"executionRole" yaml:"executionRole"` // The name of a family that this task definition is registered to. // // A family groups multiple versions of a task definition. Family *string `field:"optional" json:"family" yaml:"family"` // The log driver to use. LogDriver awsecs.LogDriver `field:"optional" json:"logDriver" yaml:"logDriver"` // The secret to expose to the container as an environment variable. Secrets *map[string]awsecs.Secret `field:"optional" json:"secrets" yaml:"secrets"` // The name of the task IAM role that grants containers in the task permission to call AWS APIs on your behalf. TaskRole awsiam.IRole `field:"optional" json:"taskRole" yaml:"taskRole"` }
Example:
var cluster cluster loadBalancedFargateService := ecsPatterns.NewApplicationLoadBalancedFargateService(this, jsii.String("Service"), &applicationLoadBalancedFargateServiceProps{ cluster: cluster, memoryLimitMiB: jsii.Number(1024), desiredCount: jsii.Number(1), cpu: jsii.Number(512), taskImageOptions: &applicationLoadBalancedTaskImageOptions{ image: ecs.containerImage.fromRegistry(jsii.String("amazon/amazon-ecs-sample")), }, taskSubnets: &subnetSelection{ subnets: []iSubnet{ ec2.subnet.fromSubnetId(this, jsii.String("subnet"), jsii.String("VpcISOLATEDSubnet1Subnet80F07FA0")), }, }, loadBalancerName: jsii.String("application-lb-name"), })
type ApplicationLoadBalancedTaskImageProps ¶
type ApplicationLoadBalancedTaskImageProps struct { // The image used to start a container. // // Image or taskDefinition must be specified, not both. Image awsecs.ContainerImage `field:"required" json:"image" yaml:"image"` // The container name value to be specified in the task definition. ContainerName *string `field:"optional" json:"containerName" yaml:"containerName"` // A list of port numbers on the container that is bound to the user-specified or automatically assigned host port. // // If you are using containers in a task with the awsvpc or host network mode, exposed ports should be specified using containerPort. // If you are using containers in a task with the bridge network mode and you specify a container port and not a host port, // your container automatically receives a host port in the ephemeral port range. // // Port mappings that are automatically assigned in this way do not count toward the 100 reserved ports limit of a container instance. // // For more information, see // [hostPort](https://docs.aws.amazon.com/AmazonECS/latest/APIReference/API_PortMapping.html#ECS-Type-PortMapping-hostPort). ContainerPorts *[]*float64 `field:"optional" json:"containerPorts" yaml:"containerPorts"` // A key/value map of labels to add to the container. DockerLabels *map[string]*string `field:"optional" json:"dockerLabels" yaml:"dockerLabels"` // Flag to indicate whether to enable logging. EnableLogging *bool `field:"optional" json:"enableLogging" yaml:"enableLogging"` // The environment variables to pass to the container. Environment *map[string]*string `field:"optional" json:"environment" yaml:"environment"` // The name of the task execution IAM role that grants the Amazon ECS container agent permission to call AWS APIs on your behalf. ExecutionRole awsiam.IRole `field:"optional" json:"executionRole" yaml:"executionRole"` // The name of a family that this task definition is registered to. // // A family groups multiple versions of a task definition. Family *string `field:"optional" json:"family" yaml:"family"` // The log driver to use. LogDriver awsecs.LogDriver `field:"optional" json:"logDriver" yaml:"logDriver"` // The secrets to expose to the container as an environment variable. Secrets *map[string]awsecs.Secret `field:"optional" json:"secrets" yaml:"secrets"` // The name of the task IAM role that grants containers in the task permission to call AWS APIs on your behalf. TaskRole awsiam.IRole `field:"optional" json:"taskRole" yaml:"taskRole"` }
Options for configuring a new container.
Example:
// One application load balancer with one listener and two target groups. var cluster cluster loadBalancedEc2Service := ecsPatterns.NewApplicationMultipleTargetGroupsEc2Service(this, jsii.String("Service"), &applicationMultipleTargetGroupsEc2ServiceProps{ cluster: cluster, memoryLimitMiB: jsii.Number(256), taskImageOptions: &applicationLoadBalancedTaskImageProps{ image: ecs.containerImage.fromRegistry(jsii.String("amazon/amazon-ecs-sample")), }, targetGroups: []applicationTargetProps{ &applicationTargetProps{ containerPort: jsii.Number(80), }, &applicationTargetProps{ containerPort: jsii.Number(90), pathPattern: jsii.String("a/b/c"), priority: jsii.Number(10), }, }, })
type ApplicationLoadBalancerProps ¶
type ApplicationLoadBalancerProps struct { // Listeners (at least one listener) attached to this load balancer. Listeners *[]*ApplicationListenerProps `field:"required" json:"listeners" yaml:"listeners"` // Name of the load balancer. Name *string `field:"required" json:"name" yaml:"name"` // The domain name for the service, e.g. "api.example.com.". DomainName *string `field:"optional" json:"domainName" yaml:"domainName"` // The Route53 hosted zone for the domain, e.g. "example.com.". DomainZone awsroute53.IHostedZone `field:"optional" json:"domainZone" yaml:"domainZone"` // Determines whether the Load Balancer will be internet-facing. PublicLoadBalancer *bool `field:"optional" json:"publicLoadBalancer" yaml:"publicLoadBalancer"` }
Properties to define an application load balancer.
Example:
// 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" var certificate certificate var hostedZone hostedZone applicationLoadBalancerProps := &applicationLoadBalancerProps{ listeners: []applicationListenerProps{ &applicationListenerProps{ name: jsii.String("name"), // the properties below are optional certificate: certificate, port: jsii.Number(123), protocol: awscdk.Aws_elasticloadbalancingv2.applicationProtocol_HTTP, sslPolicy: awscdk.*Aws_elasticloadbalancingv2.sslPolicy_RECOMMENDED, }, }, name: jsii.String("name"), // the properties below are optional domainName: jsii.String("domainName"), domainZone: hostedZone, publicLoadBalancer: jsii.Boolean(false), }
type ApplicationMultipleTargetGroupsEc2Service ¶
type ApplicationMultipleTargetGroupsEc2Service interface { ApplicationMultipleTargetGroupsServiceBase // The cluster that hosts the service. Cluster() awsecs.ICluster // The desired number of instantiations of the task definition to keep running on the service. // // The default is 1 for all new services and uses the existing services desired count // when updating an existing service, if one is not provided. InternalDesiredCount() *float64 // The default listener for the service (first added listener). Listener() awselasticloadbalancingv2.ApplicationListener Listeners() *[]awselasticloadbalancingv2.ApplicationListener SetListeners(val *[]awselasticloadbalancingv2.ApplicationListener) // The default Application Load Balancer for the service (first added load balancer). LoadBalancer() awselasticloadbalancingv2.ApplicationLoadBalancer LogDriver() awsecs.LogDriver SetLogDriver(val awsecs.LogDriver) // The tree node. Node() constructs.Node // The EC2 service in this construct. Service() awsecs.Ec2Service // The default target group for the service. TargetGroup() awselasticloadbalancingv2.ApplicationTargetGroup TargetGroups() *[]awselasticloadbalancingv2.ApplicationTargetGroup SetTargetGroups(val *[]awselasticloadbalancingv2.ApplicationTargetGroup) // The EC2 Task Definition in this construct. TaskDefinition() awsecs.Ec2TaskDefinition AddPortMappingForTargets(container awsecs.ContainerDefinition, targets *[]*ApplicationTargetProps) CreateAWSLogDriver(prefix *string) awsecs.AwsLogDriver FindListener(name *string) awselasticloadbalancingv2.ApplicationListener // Returns the default cluster. GetDefaultCluster(scope constructs.Construct, vpc awsec2.IVpc) awsecs.Cluster RegisterECSTargets(service awsecs.BaseService, container awsecs.ContainerDefinition, targets *[]*ApplicationTargetProps) awselasticloadbalancingv2.ApplicationTargetGroup // Returns a string representation of this construct. ToString() *string }
An EC2 service running on an ECS cluster fronted by an application load balancer.
Example:
// One application load balancer with one listener and two target groups. var cluster cluster loadBalancedEc2Service := ecsPatterns.NewApplicationMultipleTargetGroupsEc2Service(this, jsii.String("Service"), &applicationMultipleTargetGroupsEc2ServiceProps{ cluster: cluster, memoryLimitMiB: jsii.Number(256), taskImageOptions: &applicationLoadBalancedTaskImageProps{ image: ecs.containerImage.fromRegistry(jsii.String("amazon/amazon-ecs-sample")), }, targetGroups: []applicationTargetProps{ &applicationTargetProps{ containerPort: jsii.Number(80), }, &applicationTargetProps{ containerPort: jsii.Number(90), pathPattern: jsii.String("a/b/c"), priority: jsii.Number(10), }, }, })
func NewApplicationMultipleTargetGroupsEc2Service ¶
func NewApplicationMultipleTargetGroupsEc2Service(scope constructs.Construct, id *string, props *ApplicationMultipleTargetGroupsEc2ServiceProps) ApplicationMultipleTargetGroupsEc2Service
Constructs a new instance of the ApplicationMultipleTargetGroupsEc2Service class.
type ApplicationMultipleTargetGroupsEc2ServiceProps ¶
type ApplicationMultipleTargetGroupsEc2ServiceProps struct { // The options for configuring an Amazon ECS service to use service discovery. CloudMapOptions *awsecs.CloudMapOptions `field:"optional" json:"cloudMapOptions" yaml:"cloudMapOptions"` // The name of the cluster that hosts the service. // // If a cluster is specified, the vpc construct should be omitted. Alternatively, you can omit both cluster and vpc. Cluster awsecs.ICluster `field:"optional" json:"cluster" yaml:"cluster"` // The desired number of instantiations of the task definition to keep running on the service. DesiredCount *float64 `field:"optional" json:"desiredCount" yaml:"desiredCount"` // Specifies whether to enable Amazon ECS managed tags for the tasks within the service. // // For more information, see // [Tagging Your Amazon ECS Resources](https://docs.aws.amazon.com/AmazonECS/latest/developerguide/ecs-using-tags.html) EnableECSManagedTags *bool `field:"optional" json:"enableECSManagedTags" yaml:"enableECSManagedTags"` // The period of time, in seconds, that the Amazon ECS service scheduler ignores unhealthy Elastic Load Balancing target health checks after a task has first started. HealthCheckGracePeriod awscdk.Duration `field:"optional" json:"healthCheckGracePeriod" yaml:"healthCheckGracePeriod"` // The application load balancer that will serve traffic to the service. LoadBalancers *[]*ApplicationLoadBalancerProps `field:"optional" json:"loadBalancers" yaml:"loadBalancers"` // Specifies whether to propagate the tags from the task definition or the service to the tasks in the service. // // Tags can only be propagated to the tasks within the service during service creation. PropagateTags awsecs.PropagatedTagSource `field:"optional" json:"propagateTags" yaml:"propagateTags"` // The name of the service. ServiceName *string `field:"optional" json:"serviceName" yaml:"serviceName"` // Properties to specify ALB target groups. TargetGroups *[]*ApplicationTargetProps `field:"optional" json:"targetGroups" yaml:"targetGroups"` // The properties required to create a new task definition. // // Only one of TaskDefinition or TaskImageOptions must be specified. TaskImageOptions *ApplicationLoadBalancedTaskImageProps `field:"optional" json:"taskImageOptions" yaml:"taskImageOptions"` // The VPC where the container instances will be launched or the elastic network interfaces (ENIs) will be deployed. // // If a vpc is specified, the cluster construct should be omitted. Alternatively, you can omit both vpc and cluster. Vpc awsec2.IVpc `field:"optional" json:"vpc" yaml:"vpc"` // The minimum number of CPU units to reserve for the container. // // Valid values, which determines your range of valid values for the memory parameter:. Cpu *float64 `field:"optional" json:"cpu" yaml:"cpu"` // The amount (in MiB) of memory to present to the container. // // If your container attempts to exceed the allocated memory, the container // is terminated. // // At least one of memoryLimitMiB and memoryReservationMiB is required. MemoryLimitMiB *float64 `field:"optional" json:"memoryLimitMiB" yaml:"memoryLimitMiB"` // The soft limit (in MiB) of memory to reserve for the container. // // When system memory is under heavy contention, Docker attempts to keep the // container memory to this soft limit. However, your container can consume more // memory when it needs to, up to either the hard limit specified with the memory // parameter (if applicable), or all of the available memory on the container // instance, whichever comes first. // // At least one of memoryLimitMiB and memoryReservationMiB is required. // // Note that this setting will be ignored if TaskImagesOptions is specified. MemoryReservationMiB *float64 `field:"optional" json:"memoryReservationMiB" yaml:"memoryReservationMiB"` // The placement constraints to use for tasks in the service. // // For more information, see // [Amazon ECS Task Placement Constraints](https://docs.aws.amazon.com/AmazonECS/latest/developerguide/task-placement-constraints.html). PlacementConstraints *[]awsecs.PlacementConstraint `field:"optional" json:"placementConstraints" yaml:"placementConstraints"` // The placement strategies to use for tasks in the service. // // For more information, see // [Amazon ECS Task Placement Strategies](https://docs.aws.amazon.com/AmazonECS/latest/developerguide/task-placement-strategies.html). PlacementStrategies *[]awsecs.PlacementStrategy `field:"optional" json:"placementStrategies" yaml:"placementStrategies"` // The task definition to use for tasks in the service. Only one of TaskDefinition or TaskImageOptions must be specified. // // [disable-awslint:ref-via-interface]. TaskDefinition awsecs.Ec2TaskDefinition `field:"optional" json:"taskDefinition" yaml:"taskDefinition"` }
The properties for the ApplicationMultipleTargetGroupsEc2Service service.
Example:
// One application load balancer with one listener and two target groups. var cluster cluster loadBalancedEc2Service := ecsPatterns.NewApplicationMultipleTargetGroupsEc2Service(this, jsii.String("Service"), &applicationMultipleTargetGroupsEc2ServiceProps{ cluster: cluster, memoryLimitMiB: jsii.Number(256), taskImageOptions: &applicationLoadBalancedTaskImageProps{ image: ecs.containerImage.fromRegistry(jsii.String("amazon/amazon-ecs-sample")), }, targetGroups: []applicationTargetProps{ &applicationTargetProps{ containerPort: jsii.Number(80), }, &applicationTargetProps{ containerPort: jsii.Number(90), pathPattern: jsii.String("a/b/c"), priority: jsii.Number(10), }, }, })
type ApplicationMultipleTargetGroupsFargateService ¶
type ApplicationMultipleTargetGroupsFargateService interface { ApplicationMultipleTargetGroupsServiceBase // Determines whether the service will be assigned a public IP address. AssignPublicIp() *bool // The cluster that hosts the service. Cluster() awsecs.ICluster // The desired number of instantiations of the task definition to keep running on the service. // // The default is 1 for all new services and uses the existing services desired count // when updating an existing service, if one is not provided. InternalDesiredCount() *float64 // The default listener for the service (first added listener). Listener() awselasticloadbalancingv2.ApplicationListener Listeners() *[]awselasticloadbalancingv2.ApplicationListener SetListeners(val *[]awselasticloadbalancingv2.ApplicationListener) // The default Application Load Balancer for the service (first added load balancer). LoadBalancer() awselasticloadbalancingv2.ApplicationLoadBalancer LogDriver() awsecs.LogDriver SetLogDriver(val awsecs.LogDriver) // The tree node. Node() constructs.Node // The Fargate service in this construct. Service() awsecs.FargateService // The default target group for the service. TargetGroup() awselasticloadbalancingv2.ApplicationTargetGroup TargetGroups() *[]awselasticloadbalancingv2.ApplicationTargetGroup SetTargetGroups(val *[]awselasticloadbalancingv2.ApplicationTargetGroup) // The Fargate task definition in this construct. TaskDefinition() awsecs.FargateTaskDefinition AddPortMappingForTargets(container awsecs.ContainerDefinition, targets *[]*ApplicationTargetProps) CreateAWSLogDriver(prefix *string) awsecs.AwsLogDriver FindListener(name *string) awselasticloadbalancingv2.ApplicationListener // Returns the default cluster. GetDefaultCluster(scope constructs.Construct, vpc awsec2.IVpc) awsecs.Cluster RegisterECSTargets(service awsecs.BaseService, container awsecs.ContainerDefinition, targets *[]*ApplicationTargetProps) awselasticloadbalancingv2.ApplicationTargetGroup // Returns a string representation of this construct. ToString() *string }
A Fargate service running on an ECS cluster fronted by an application load balancer.
Example:
// One application load balancer with one listener and two target groups. var cluster cluster loadBalancedFargateService := ecsPatterns.NewApplicationMultipleTargetGroupsFargateService(this, jsii.String("Service"), &applicationMultipleTargetGroupsFargateServiceProps{ cluster: cluster, memoryLimitMiB: jsii.Number(1024), cpu: jsii.Number(512), taskImageOptions: &applicationLoadBalancedTaskImageProps{ image: ecs.containerImage.fromRegistry(jsii.String("amazon/amazon-ecs-sample")), }, targetGroups: []applicationTargetProps{ &applicationTargetProps{ containerPort: jsii.Number(80), }, &applicationTargetProps{ containerPort: jsii.Number(90), pathPattern: jsii.String("a/b/c"), priority: jsii.Number(10), }, }, })
func NewApplicationMultipleTargetGroupsFargateService ¶
func NewApplicationMultipleTargetGroupsFargateService(scope constructs.Construct, id *string, props *ApplicationMultipleTargetGroupsFargateServiceProps) ApplicationMultipleTargetGroupsFargateService
Constructs a new instance of the ApplicationMultipleTargetGroupsFargateService class.
type ApplicationMultipleTargetGroupsFargateServiceProps ¶
type ApplicationMultipleTargetGroupsFargateServiceProps struct { // The options for configuring an Amazon ECS service to use service discovery. CloudMapOptions *awsecs.CloudMapOptions `field:"optional" json:"cloudMapOptions" yaml:"cloudMapOptions"` // The name of the cluster that hosts the service. // // If a cluster is specified, the vpc construct should be omitted. Alternatively, you can omit both cluster and vpc. Cluster awsecs.ICluster `field:"optional" json:"cluster" yaml:"cluster"` // The desired number of instantiations of the task definition to keep running on the service. DesiredCount *float64 `field:"optional" json:"desiredCount" yaml:"desiredCount"` // Specifies whether to enable Amazon ECS managed tags for the tasks within the service. // // For more information, see // [Tagging Your Amazon ECS Resources](https://docs.aws.amazon.com/AmazonECS/latest/developerguide/ecs-using-tags.html) EnableECSManagedTags *bool `field:"optional" json:"enableECSManagedTags" yaml:"enableECSManagedTags"` // The period of time, in seconds, that the Amazon ECS service scheduler ignores unhealthy Elastic Load Balancing target health checks after a task has first started. HealthCheckGracePeriod awscdk.Duration `field:"optional" json:"healthCheckGracePeriod" yaml:"healthCheckGracePeriod"` // The application load balancer that will serve traffic to the service. LoadBalancers *[]*ApplicationLoadBalancerProps `field:"optional" json:"loadBalancers" yaml:"loadBalancers"` // Specifies whether to propagate the tags from the task definition or the service to the tasks in the service. // // Tags can only be propagated to the tasks within the service during service creation. PropagateTags awsecs.PropagatedTagSource `field:"optional" json:"propagateTags" yaml:"propagateTags"` // The name of the service. ServiceName *string `field:"optional" json:"serviceName" yaml:"serviceName"` // Properties to specify ALB target groups. TargetGroups *[]*ApplicationTargetProps `field:"optional" json:"targetGroups" yaml:"targetGroups"` // The properties required to create a new task definition. // // Only one of TaskDefinition or TaskImageOptions must be specified. TaskImageOptions *ApplicationLoadBalancedTaskImageProps `field:"optional" json:"taskImageOptions" yaml:"taskImageOptions"` // The VPC where the container instances will be launched or the elastic network interfaces (ENIs) will be deployed. // // If a vpc is specified, the cluster construct should be omitted. Alternatively, you can omit both vpc and cluster. Vpc awsec2.IVpc `field:"optional" json:"vpc" yaml:"vpc"` // Determines whether the service will be assigned a public IP address. AssignPublicIp *bool `field:"optional" json:"assignPublicIp" yaml:"assignPublicIp"` // The number of cpu units used by the task. // // Valid values, which determines your range of valid values for the memory parameter: // // 256 (.25 vCPU) - Available memory values: 0.5GB, 1GB, 2GB // // 512 (.5 vCPU) - Available memory values: 1GB, 2GB, 3GB, 4GB // // 1024 (1 vCPU) - Available memory values: 2GB, 3GB, 4GB, 5GB, 6GB, 7GB, 8GB // // 2048 (2 vCPU) - Available memory values: Between 4GB and 16GB in 1GB increments // // 4096 (4 vCPU) - Available memory values: Between 8GB and 30GB in 1GB increments // // This default is set in the underlying FargateTaskDefinition construct. Cpu *float64 `field:"optional" json:"cpu" yaml:"cpu"` // The amount (in MiB) of memory used by the task. // // This field is required and you must use one of the following values, which determines your range of valid values // for the cpu parameter: // // 512 (0.5 GB), 1024 (1 GB), 2048 (2 GB) - Available cpu values: 256 (.25 vCPU) // // 1024 (1 GB), 2048 (2 GB), 3072 (3 GB), 4096 (4 GB) - Available cpu values: 512 (.5 vCPU) // // 2048 (2 GB), 3072 (3 GB), 4096 (4 GB), 5120 (5 GB), 6144 (6 GB), 7168 (7 GB), 8192 (8 GB) - Available cpu values: 1024 (1 vCPU) // // Between 4096 (4 GB) and 16384 (16 GB) in increments of 1024 (1 GB) - Available cpu values: 2048 (2 vCPU) // // Between 8192 (8 GB) and 30720 (30 GB) in increments of 1024 (1 GB) - Available cpu values: 4096 (4 vCPU) // // This default is set in the underlying FargateTaskDefinition construct. MemoryLimitMiB *float64 `field:"optional" json:"memoryLimitMiB" yaml:"memoryLimitMiB"` // The platform version on which to run your service. // // If one is not specified, the LATEST platform version is used by default. For more information, see // [AWS Fargate Platform Versions](https://docs.aws.amazon.com/AmazonECS/latest/developerguide/platform_versions.html) // in the Amazon Elastic Container Service Developer Guide. PlatformVersion awsecs.FargatePlatformVersion `field:"optional" json:"platformVersion" yaml:"platformVersion"` // The task definition to use for tasks in the service. Only one of TaskDefinition or TaskImageOptions must be specified. // // [disable-awslint:ref-via-interface]. TaskDefinition awsecs.FargateTaskDefinition `field:"optional" json:"taskDefinition" yaml:"taskDefinition"` }
The properties for the ApplicationMultipleTargetGroupsFargateService service.
Example:
// One application load balancer with one listener and two target groups. var cluster cluster loadBalancedFargateService := ecsPatterns.NewApplicationMultipleTargetGroupsFargateService(this, jsii.String("Service"), &applicationMultipleTargetGroupsFargateServiceProps{ cluster: cluster, memoryLimitMiB: jsii.Number(1024), cpu: jsii.Number(512), taskImageOptions: &applicationLoadBalancedTaskImageProps{ image: ecs.containerImage.fromRegistry(jsii.String("amazon/amazon-ecs-sample")), }, targetGroups: []applicationTargetProps{ &applicationTargetProps{ containerPort: jsii.Number(80), }, &applicationTargetProps{ containerPort: jsii.Number(90), pathPattern: jsii.String("a/b/c"), priority: jsii.Number(10), }, }, })
type ApplicationMultipleTargetGroupsServiceBase ¶
type ApplicationMultipleTargetGroupsServiceBase interface { constructs.Construct // The cluster that hosts the service. Cluster() awsecs.ICluster // The desired number of instantiations of the task definition to keep running on the service. // // The default is 1 for all new services and uses the existing services desired count // when updating an existing service, if one is not provided. InternalDesiredCount() *float64 // The default listener for the service (first added listener). Listener() awselasticloadbalancingv2.ApplicationListener Listeners() *[]awselasticloadbalancingv2.ApplicationListener SetListeners(val *[]awselasticloadbalancingv2.ApplicationListener) // The default Application Load Balancer for the service (first added load balancer). LoadBalancer() awselasticloadbalancingv2.ApplicationLoadBalancer LogDriver() awsecs.LogDriver SetLogDriver(val awsecs.LogDriver) // The tree node. Node() constructs.Node TargetGroups() *[]awselasticloadbalancingv2.ApplicationTargetGroup SetTargetGroups(val *[]awselasticloadbalancingv2.ApplicationTargetGroup) AddPortMappingForTargets(container awsecs.ContainerDefinition, targets *[]*ApplicationTargetProps) CreateAWSLogDriver(prefix *string) awsecs.AwsLogDriver FindListener(name *string) awselasticloadbalancingv2.ApplicationListener // Returns the default cluster. GetDefaultCluster(scope constructs.Construct, vpc awsec2.IVpc) awsecs.Cluster RegisterECSTargets(service awsecs.BaseService, container awsecs.ContainerDefinition, targets *[]*ApplicationTargetProps) awselasticloadbalancingv2.ApplicationTargetGroup // Returns a string representation of this construct. ToString() *string }
The base class for ApplicationMultipleTargetGroupsEc2Service and ApplicationMultipleTargetGroupsFargateService classes.
type ApplicationMultipleTargetGroupsServiceBaseProps ¶
type ApplicationMultipleTargetGroupsServiceBaseProps struct { // The options for configuring an Amazon ECS service to use service discovery. CloudMapOptions *awsecs.CloudMapOptions `field:"optional" json:"cloudMapOptions" yaml:"cloudMapOptions"` // The name of the cluster that hosts the service. // // If a cluster is specified, the vpc construct should be omitted. Alternatively, you can omit both cluster and vpc. Cluster awsecs.ICluster `field:"optional" json:"cluster" yaml:"cluster"` // The desired number of instantiations of the task definition to keep running on the service. DesiredCount *float64 `field:"optional" json:"desiredCount" yaml:"desiredCount"` // Specifies whether to enable Amazon ECS managed tags for the tasks within the service. // // For more information, see // [Tagging Your Amazon ECS Resources](https://docs.aws.amazon.com/AmazonECS/latest/developerguide/ecs-using-tags.html) EnableECSManagedTags *bool `field:"optional" json:"enableECSManagedTags" yaml:"enableECSManagedTags"` // The period of time, in seconds, that the Amazon ECS service scheduler ignores unhealthy Elastic Load Balancing target health checks after a task has first started. HealthCheckGracePeriod awscdk.Duration `field:"optional" json:"healthCheckGracePeriod" yaml:"healthCheckGracePeriod"` // The application load balancer that will serve traffic to the service. LoadBalancers *[]*ApplicationLoadBalancerProps `field:"optional" json:"loadBalancers" yaml:"loadBalancers"` // Specifies whether to propagate the tags from the task definition or the service to the tasks in the service. // // Tags can only be propagated to the tasks within the service during service creation. PropagateTags awsecs.PropagatedTagSource `field:"optional" json:"propagateTags" yaml:"propagateTags"` // The name of the service. ServiceName *string `field:"optional" json:"serviceName" yaml:"serviceName"` // Properties to specify ALB target groups. TargetGroups *[]*ApplicationTargetProps `field:"optional" json:"targetGroups" yaml:"targetGroups"` // The properties required to create a new task definition. // // Only one of TaskDefinition or TaskImageOptions must be specified. TaskImageOptions *ApplicationLoadBalancedTaskImageProps `field:"optional" json:"taskImageOptions" yaml:"taskImageOptions"` // The VPC where the container instances will be launched or the elastic network interfaces (ENIs) will be deployed. // // If a vpc is specified, the cluster construct should be omitted. Alternatively, you can omit both vpc and cluster. Vpc awsec2.IVpc `field:"optional" json:"vpc" yaml:"vpc"` }
The properties for the base ApplicationMultipleTargetGroupsEc2Service or ApplicationMultipleTargetGroupsFargateService service.
Example:
// The code below shows an example of how to instantiate this type. // The values are placeholders you should change. import cdk "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" import "github.com/aws/aws-cdk-go/awscdk" var certificate certificate var cluster cluster var containerDefinition containerDefinition var containerImage containerImage var hostedZone hostedZone var logDriver logDriver var namespace iNamespace var role role var secret secret var vpc vpc applicationMultipleTargetGroupsServiceBaseProps := &applicationMultipleTargetGroupsServiceBaseProps{ 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, desiredCount: jsii.Number(123), enableECSManagedTags: jsii.Boolean(false), healthCheckGracePeriod: cdk.*duration.minutes(jsii.Number(30)), loadBalancers: []applicationLoadBalancerProps{ &applicationLoadBalancerProps{ listeners: []applicationListenerProps{ &applicationListenerProps{ name: jsii.String("name"), // the properties below are optional certificate: certificate, port: jsii.Number(123), protocol: awscdk.Aws_elasticloadbalancingv2.applicationProtocol_HTTP, sslPolicy: awscdk.*Aws_elasticloadbalancingv2.sslPolicy_RECOMMENDED, }, }, name: jsii.String("name"), // the properties below are optional domainName: jsii.String("domainName"), domainZone: hostedZone, publicLoadBalancer: jsii.Boolean(false), }, }, propagateTags: awscdk.Aws_ecs.propagatedTagSource_SERVICE, serviceName: jsii.String("serviceName"), targetGroups: []applicationTargetProps{ &applicationTargetProps{ containerPort: jsii.Number(123), // the properties below are optional hostHeader: jsii.String("hostHeader"), listener: jsii.String("listener"), pathPattern: jsii.String("pathPattern"), priority: jsii.Number(123), protocol: awscdk.*Aws_ecs.protocol_TCP, }, }, taskImageOptions: &applicationLoadBalancedTaskImageProps{ image: containerImage, // the properties below are optional containerName: jsii.String("containerName"), containerPorts: []*f64{ 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, }
type ApplicationTargetProps ¶
type ApplicationTargetProps struct { // The port number of the container. // // Only applicable when using application/network load balancers. ContainerPort *float64 `field:"required" json:"containerPort" yaml:"containerPort"` // Rule applies if the requested host matches the indicated host. // // May contain up to three '*' wildcards. // // Requires that priority is set. // See: https://docs.aws.amazon.com/elasticloadbalancing/latest/application/load-balancer-listeners.html#host-conditions // HostHeader *string `field:"optional" json:"hostHeader" yaml:"hostHeader"` // Name of the listener the target group attached to. Listener *string `field:"optional" json:"listener" yaml:"listener"` // Rule applies if the requested path matches the given path pattern. // // May contain up to three '*' wildcards. // // Requires that priority is set. // See: https://docs.aws.amazon.com/elasticloadbalancing/latest/application/load-balancer-listeners.html#path-conditions // PathPattern *string `field:"optional" json:"pathPattern" yaml:"pathPattern"` // Priority of this target group. // // The rule with the lowest priority will be used for every request. // If priority is not given, these target groups will be added as // defaults, and must not have conditions. // // Priorities must be unique. Priority *float64 `field:"optional" json:"priority" yaml:"priority"` // The protocol used for the port mapping. // // Only applicable when using application load balancers. Protocol awsecs.Protocol `field:"optional" json:"protocol" yaml:"protocol"` }
Properties to define an application target group.
Example:
// 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" applicationTargetProps := &applicationTargetProps{ containerPort: jsii.Number(123), // the properties below are optional hostHeader: jsii.String("hostHeader"), listener: jsii.String("listener"), pathPattern: jsii.String("pathPattern"), priority: jsii.Number(123), protocol: awscdk.Aws_ecs.protocol_TCP, }
type NetworkListenerProps ¶
type NetworkListenerProps struct { // Name of the listener. Name *string `field:"required" json:"name" yaml:"name"` // The port on which the listener listens for requests. Port *float64 `field:"optional" json:"port" yaml:"port"` }
Properties to define an network listener.
Example:
// 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" networkListenerProps := &networkListenerProps{ name: jsii.String("name"), // the properties below are optional port: jsii.Number(123), }
type NetworkLoadBalancedEc2Service ¶
type NetworkLoadBalancedEc2Service interface { NetworkLoadBalancedServiceBase // The cluster that hosts the service. Cluster() awsecs.ICluster // The desired number of instantiations of the task definition to keep running on the service. // // The default is 1 for all new services and uses the existing services desired count // when updating an existing service, if one is not provided. InternalDesiredCount() *float64 // The listener for the service. Listener() awselasticloadbalancingv2.NetworkListener // The Network Load Balancer for the service. LoadBalancer() awselasticloadbalancingv2.NetworkLoadBalancer // The tree node. Node() constructs.Node // The ECS service in this construct. Service() awsecs.Ec2Service // The target group for the service. TargetGroup() awselasticloadbalancingv2.NetworkTargetGroup // The EC2 Task Definition in this construct. TaskDefinition() awsecs.Ec2TaskDefinition // Adds service as a target of the target group. AddServiceAsTarget(service awsecs.BaseService) CreateAWSLogDriver(prefix *string) awsecs.AwsLogDriver // Returns the default cluster. GetDefaultCluster(scope constructs.Construct, vpc awsec2.IVpc) awsecs.Cluster // Returns a string representation of this construct. ToString() *string }
An EC2 service running on an ECS cluster fronted by a network load balancer.
Example:
var cluster cluster loadBalancedEcsService := ecsPatterns.NewNetworkLoadBalancedEc2Service(this, jsii.String("Service"), &networkLoadBalancedEc2ServiceProps{ cluster: cluster, memoryLimitMiB: jsii.Number(1024), taskImageOptions: &networkLoadBalancedTaskImageOptions{ image: ecs.containerImage.fromRegistry(jsii.String("test")), environment: map[string]*string{ "TEST_ENVIRONMENT_VARIABLE1": jsii.String("test environment variable 1 value"), "TEST_ENVIRONMENT_VARIABLE2": jsii.String("test environment variable 2 value"), }, }, desiredCount: jsii.Number(2), })
func NewNetworkLoadBalancedEc2Service ¶
func NewNetworkLoadBalancedEc2Service(scope constructs.Construct, id *string, props *NetworkLoadBalancedEc2ServiceProps) NetworkLoadBalancedEc2Service
Constructs a new instance of the NetworkLoadBalancedEc2Service class.
type NetworkLoadBalancedEc2ServiceProps ¶
type NetworkLoadBalancedEc2ServiceProps struct { // Whether to enable the deployment circuit breaker. // // If this property is defined, circuit breaker will be implicitly // enabled. CircuitBreaker *awsecs.DeploymentCircuitBreaker `field:"optional" json:"circuitBreaker" yaml:"circuitBreaker"` // The options for configuring an Amazon ECS service to use service discovery. CloudMapOptions *awsecs.CloudMapOptions `field:"optional" json:"cloudMapOptions" yaml:"cloudMapOptions"` // The name of the cluster that hosts the service. // // If a cluster is specified, the vpc construct should be omitted. Alternatively, you can omit both cluster and vpc. Cluster awsecs.ICluster `field:"optional" json:"cluster" yaml:"cluster"` // Specifies which deployment controller to use for the service. // // For more information, see // [Amazon ECS Deployment Types](https://docs.aws.amazon.com/AmazonECS/latest/developerguide/deployment-types.html) DeploymentController *awsecs.DeploymentController `field:"optional" json:"deploymentController" yaml:"deploymentController"` // The desired number of instantiations of the task definition to keep running on the service. // // The minimum value is 1. DesiredCount *float64 `field:"optional" json:"desiredCount" yaml:"desiredCount"` // The domain name for the service, e.g. "api.example.com.". DomainName *string `field:"optional" json:"domainName" yaml:"domainName"` // The Route53 hosted zone for the domain, e.g. "example.com.". DomainZone awsroute53.IHostedZone `field:"optional" json:"domainZone" yaml:"domainZone"` // Specifies whether to enable Amazon ECS managed tags for the tasks within the service. // // For more information, see // [Tagging Your Amazon ECS Resources](https://docs.aws.amazon.com/AmazonECS/latest/developerguide/ecs-using-tags.html) EnableECSManagedTags *bool `field:"optional" json:"enableECSManagedTags" yaml:"enableECSManagedTags"` // The period of time, in seconds, that the Amazon ECS service scheduler ignores unhealthy Elastic Load Balancing target health checks after a task has first started. HealthCheckGracePeriod awscdk.Duration `field:"optional" json:"healthCheckGracePeriod" yaml:"healthCheckGracePeriod"` // Listener port of the network load balancer that will serve traffic to the service. ListenerPort *float64 `field:"optional" json:"listenerPort" yaml:"listenerPort"` // The network load balancer that will serve traffic to the service. // // If the load balancer has been imported, the vpc attribute must be specified // in the call to fromNetworkLoadBalancerAttributes(). // // [disable-awslint:ref-via-interface]. LoadBalancer awselasticloadbalancingv2.INetworkLoadBalancer `field:"optional" json:"loadBalancer" yaml:"loadBalancer"` // The maximum number of tasks, specified as a percentage of the Amazon ECS service's DesiredCount value, that can run in a service during a deployment. MaxHealthyPercent *float64 `field:"optional" json:"maxHealthyPercent" yaml:"maxHealthyPercent"` // The minimum number of tasks, specified as a percentage of the Amazon ECS service's DesiredCount value, that must continue to run and remain healthy during a deployment. MinHealthyPercent *float64 `field:"optional" json:"minHealthyPercent" yaml:"minHealthyPercent"` // Specifies whether to propagate the tags from the task definition or the service to the tasks in the service. // // Tags can only be propagated to the tasks within the service during service creation. PropagateTags awsecs.PropagatedTagSource `field:"optional" json:"propagateTags" yaml:"propagateTags"` // Determines whether the Load Balancer will be internet-facing. PublicLoadBalancer *bool `field:"optional" json:"publicLoadBalancer" yaml:"publicLoadBalancer"` // Specifies whether the Route53 record should be a CNAME, an A record using the Alias feature or no record at all. // // This is useful if you need to work with DNS systems that do not support alias records. RecordType NetworkLoadBalancedServiceRecordType `field:"optional" json:"recordType" yaml:"recordType"` // The name of the service. ServiceName *string `field:"optional" json:"serviceName" yaml:"serviceName"` // The properties required to create a new task definition. // // One of taskImageOptions or taskDefinition must be specified. TaskImageOptions *NetworkLoadBalancedTaskImageOptions `field:"optional" json:"taskImageOptions" yaml:"taskImageOptions"` // The VPC where the container instances will be launched or the elastic network interfaces (ENIs) will be deployed. // // If a vpc is specified, the cluster construct should be omitted. Alternatively, you can omit both vpc and cluster. Vpc awsec2.IVpc `field:"optional" json:"vpc" yaml:"vpc"` // The number of cpu units used by the task. // // Valid values, which determines your range of valid values for the memory parameter: // // 256 (.25 vCPU) - Available memory values: 0.5GB, 1GB, 2GB // // 512 (.5 vCPU) - Available memory values: 1GB, 2GB, 3GB, 4GB // // 1024 (1 vCPU) - Available memory values: 2GB, 3GB, 4GB, 5GB, 6GB, 7GB, 8GB // // 2048 (2 vCPU) - Available memory values: Between 4GB and 16GB in 1GB increments // // 4096 (4 vCPU) - Available memory values: Between 8GB and 30GB in 1GB increments // // This default is set in the underlying FargateTaskDefinition construct. Cpu *float64 `field:"optional" json:"cpu" yaml:"cpu"` // The hard limit (in MiB) of memory to present to the container. // // If your container attempts to exceed the allocated memory, the container // is terminated. // // At least one of memoryLimitMiB and memoryReservationMiB is required. MemoryLimitMiB *float64 `field:"optional" json:"memoryLimitMiB" yaml:"memoryLimitMiB"` // The soft limit (in MiB) of memory to reserve for the container. // // When system memory is under contention, Docker attempts to keep the // container memory within the limit. If the container requires more memory, // it can consume up to the value specified by the Memory property or all of // the available memory on the container instance—whichever comes first. // // At least one of memoryLimitMiB and memoryReservationMiB is required. MemoryReservationMiB *float64 `field:"optional" json:"memoryReservationMiB" yaml:"memoryReservationMiB"` // The placement constraints to use for tasks in the service. // // For more information, see // [Amazon ECS Task Placement Constraints](https://docs.aws.amazon.com/AmazonECS/latest/developerguide/task-placement-constraints.html). PlacementConstraints *[]awsecs.PlacementConstraint `field:"optional" json:"placementConstraints" yaml:"placementConstraints"` // The placement strategies to use for tasks in the service. // // For more information, see // [Amazon ECS Task Placement Strategies](https://docs.aws.amazon.com/AmazonECS/latest/developerguide/task-placement-strategies.html). PlacementStrategies *[]awsecs.PlacementStrategy `field:"optional" json:"placementStrategies" yaml:"placementStrategies"` // The task definition to use for tasks in the service. TaskDefinition or TaskImageOptions must be specified, but not both.. // // [disable-awslint:ref-via-interface]. TaskDefinition awsecs.Ec2TaskDefinition `field:"optional" json:"taskDefinition" yaml:"taskDefinition"` }
The properties for the NetworkLoadBalancedEc2Service service.
Example:
var cluster cluster loadBalancedEcsService := ecsPatterns.NewNetworkLoadBalancedEc2Service(this, jsii.String("Service"), &networkLoadBalancedEc2ServiceProps{ cluster: cluster, memoryLimitMiB: jsii.Number(1024), taskImageOptions: &networkLoadBalancedTaskImageOptions{ image: ecs.containerImage.fromRegistry(jsii.String("test")), environment: map[string]*string{ "TEST_ENVIRONMENT_VARIABLE1": jsii.String("test environment variable 1 value"), "TEST_ENVIRONMENT_VARIABLE2": jsii.String("test environment variable 2 value"), }, }, desiredCount: jsii.Number(2), })
type NetworkLoadBalancedFargateService ¶
type NetworkLoadBalancedFargateService interface { NetworkLoadBalancedServiceBase AssignPublicIp() *bool // The cluster that hosts the service. Cluster() awsecs.ICluster // The desired number of instantiations of the task definition to keep running on the service. // // The default is 1 for all new services and uses the existing services desired count // when updating an existing service, if one is not provided. InternalDesiredCount() *float64 // The listener for the service. Listener() awselasticloadbalancingv2.NetworkListener // The Network Load Balancer for the service. LoadBalancer() awselasticloadbalancingv2.NetworkLoadBalancer // The tree node. Node() constructs.Node // The Fargate service in this construct. Service() awsecs.FargateService // The target group for the service. TargetGroup() awselasticloadbalancingv2.NetworkTargetGroup // The Fargate task definition in this construct. TaskDefinition() awsecs.FargateTaskDefinition // Adds service as a target of the target group. AddServiceAsTarget(service awsecs.BaseService) CreateAWSLogDriver(prefix *string) awsecs.AwsLogDriver // Returns the default cluster. GetDefaultCluster(scope constructs.Construct, vpc awsec2.IVpc) awsecs.Cluster // Returns a string representation of this construct. ToString() *string }
A Fargate service running on an ECS cluster fronted by a network load balancer.
Example:
var cluster cluster loadBalancedFargateService := ecsPatterns.NewNetworkLoadBalancedFargateService(this, jsii.String("Service"), &networkLoadBalancedFargateServiceProps{ cluster: cluster, memoryLimitMiB: jsii.Number(1024), cpu: jsii.Number(512), taskImageOptions: &networkLoadBalancedTaskImageOptions{ image: ecs.containerImage.fromRegistry(jsii.String("amazon/amazon-ecs-sample")), }, })
func NewNetworkLoadBalancedFargateService ¶
func NewNetworkLoadBalancedFargateService(scope constructs.Construct, id *string, props *NetworkLoadBalancedFargateServiceProps) NetworkLoadBalancedFargateService
Constructs a new instance of the NetworkLoadBalancedFargateService class.
type NetworkLoadBalancedFargateServiceProps ¶
type NetworkLoadBalancedFargateServiceProps struct { // Whether to enable the deployment circuit breaker. // // If this property is defined, circuit breaker will be implicitly // enabled. CircuitBreaker *awsecs.DeploymentCircuitBreaker `field:"optional" json:"circuitBreaker" yaml:"circuitBreaker"` // The options for configuring an Amazon ECS service to use service discovery. CloudMapOptions *awsecs.CloudMapOptions `field:"optional" json:"cloudMapOptions" yaml:"cloudMapOptions"` // The name of the cluster that hosts the service. // // If a cluster is specified, the vpc construct should be omitted. Alternatively, you can omit both cluster and vpc. Cluster awsecs.ICluster `field:"optional" json:"cluster" yaml:"cluster"` // Specifies which deployment controller to use for the service. // // For more information, see // [Amazon ECS Deployment Types](https://docs.aws.amazon.com/AmazonECS/latest/developerguide/deployment-types.html) DeploymentController *awsecs.DeploymentController `field:"optional" json:"deploymentController" yaml:"deploymentController"` // The desired number of instantiations of the task definition to keep running on the service. // // The minimum value is 1. DesiredCount *float64 `field:"optional" json:"desiredCount" yaml:"desiredCount"` // The domain name for the service, e.g. "api.example.com.". DomainName *string `field:"optional" json:"domainName" yaml:"domainName"` // The Route53 hosted zone for the domain, e.g. "example.com.". DomainZone awsroute53.IHostedZone `field:"optional" json:"domainZone" yaml:"domainZone"` // Specifies whether to enable Amazon ECS managed tags for the tasks within the service. // // For more information, see // [Tagging Your Amazon ECS Resources](https://docs.aws.amazon.com/AmazonECS/latest/developerguide/ecs-using-tags.html) EnableECSManagedTags *bool `field:"optional" json:"enableECSManagedTags" yaml:"enableECSManagedTags"` // The period of time, in seconds, that the Amazon ECS service scheduler ignores unhealthy Elastic Load Balancing target health checks after a task has first started. HealthCheckGracePeriod awscdk.Duration `field:"optional" json:"healthCheckGracePeriod" yaml:"healthCheckGracePeriod"` // Listener port of the network load balancer that will serve traffic to the service. ListenerPort *float64 `field:"optional" json:"listenerPort" yaml:"listenerPort"` // The network load balancer that will serve traffic to the service. // // If the load balancer has been imported, the vpc attribute must be specified // in the call to fromNetworkLoadBalancerAttributes(). // // [disable-awslint:ref-via-interface]. LoadBalancer awselasticloadbalancingv2.INetworkLoadBalancer `field:"optional" json:"loadBalancer" yaml:"loadBalancer"` // The maximum number of tasks, specified as a percentage of the Amazon ECS service's DesiredCount value, that can run in a service during a deployment. MaxHealthyPercent *float64 `field:"optional" json:"maxHealthyPercent" yaml:"maxHealthyPercent"` // The minimum number of tasks, specified as a percentage of the Amazon ECS service's DesiredCount value, that must continue to run and remain healthy during a deployment. MinHealthyPercent *float64 `field:"optional" json:"minHealthyPercent" yaml:"minHealthyPercent"` // Specifies whether to propagate the tags from the task definition or the service to the tasks in the service. // // Tags can only be propagated to the tasks within the service during service creation. PropagateTags awsecs.PropagatedTagSource `field:"optional" json:"propagateTags" yaml:"propagateTags"` // Determines whether the Load Balancer will be internet-facing. PublicLoadBalancer *bool `field:"optional" json:"publicLoadBalancer" yaml:"publicLoadBalancer"` // Specifies whether the Route53 record should be a CNAME, an A record using the Alias feature or no record at all. // // This is useful if you need to work with DNS systems that do not support alias records. RecordType NetworkLoadBalancedServiceRecordType `field:"optional" json:"recordType" yaml:"recordType"` // The name of the service. ServiceName *string `field:"optional" json:"serviceName" yaml:"serviceName"` // The properties required to create a new task definition. // // One of taskImageOptions or taskDefinition must be specified. TaskImageOptions *NetworkLoadBalancedTaskImageOptions `field:"optional" json:"taskImageOptions" yaml:"taskImageOptions"` // The VPC where the container instances will be launched or the elastic network interfaces (ENIs) will be deployed. // // If a vpc is specified, the cluster construct should be omitted. Alternatively, you can omit both vpc and cluster. Vpc awsec2.IVpc `field:"optional" json:"vpc" yaml:"vpc"` // Determines whether the service will be assigned a public IP address. AssignPublicIp *bool `field:"optional" json:"assignPublicIp" yaml:"assignPublicIp"` // The number of cpu units used by the task. // // Valid values, which determines your range of valid values for the memory parameter: // // 256 (.25 vCPU) - Available memory values: 0.5GB, 1GB, 2GB // // 512 (.5 vCPU) - Available memory values: 1GB, 2GB, 3GB, 4GB // // 1024 (1 vCPU) - Available memory values: 2GB, 3GB, 4GB, 5GB, 6GB, 7GB, 8GB // // 2048 (2 vCPU) - Available memory values: Between 4GB and 16GB in 1GB increments // // 4096 (4 vCPU) - Available memory values: Between 8GB and 30GB in 1GB increments // // This default is set in the underlying FargateTaskDefinition construct. Cpu *float64 `field:"optional" json:"cpu" yaml:"cpu"` // The amount (in MiB) of memory used by the task. // // This field is required and you must use one of the following values, which determines your range of valid values // for the cpu parameter: // // 512 (0.5 GB), 1024 (1 GB), 2048 (2 GB) - Available cpu values: 256 (.25 vCPU) // // 1024 (1 GB), 2048 (2 GB), 3072 (3 GB), 4096 (4 GB) - Available cpu values: 512 (.5 vCPU) // // 2048 (2 GB), 3072 (3 GB), 4096 (4 GB), 5120 (5 GB), 6144 (6 GB), 7168 (7 GB), 8192 (8 GB) - Available cpu values: 1024 (1 vCPU) // // Between 4096 (4 GB) and 16384 (16 GB) in increments of 1024 (1 GB) - Available cpu values: 2048 (2 vCPU) // // Between 8192 (8 GB) and 30720 (30 GB) in increments of 1024 (1 GB) - Available cpu values: 4096 (4 vCPU) // // This default is set in the underlying FargateTaskDefinition construct. MemoryLimitMiB *float64 `field:"optional" json:"memoryLimitMiB" yaml:"memoryLimitMiB"` // The platform version on which to run your service. // // If one is not specified, the LATEST platform version is used by default. For more information, see // [AWS Fargate Platform Versions](https://docs.aws.amazon.com/AmazonECS/latest/developerguide/platform_versions.html) // in the Amazon Elastic Container Service Developer Guide. PlatformVersion awsecs.FargatePlatformVersion `field:"optional" json:"platformVersion" yaml:"platformVersion"` // The task definition to use for tasks in the service. TaskDefinition or TaskImageOptions must be specified, but not both. // // [disable-awslint:ref-via-interface]. TaskDefinition awsecs.FargateTaskDefinition `field:"optional" json:"taskDefinition" yaml:"taskDefinition"` // The subnets to associate with the service. TaskSubnets *awsec2.SubnetSelection `field:"optional" json:"taskSubnets" yaml:"taskSubnets"` }
The properties for the NetworkLoadBalancedFargateService service.
Example:
var cluster cluster loadBalancedFargateService := ecsPatterns.NewNetworkLoadBalancedFargateService(this, jsii.String("Service"), &networkLoadBalancedFargateServiceProps{ cluster: cluster, memoryLimitMiB: jsii.Number(1024), cpu: jsii.Number(512), taskImageOptions: &networkLoadBalancedTaskImageOptions{ image: ecs.containerImage.fromRegistry(jsii.String("amazon/amazon-ecs-sample")), }, })
type NetworkLoadBalancedServiceBase ¶
type NetworkLoadBalancedServiceBase interface { constructs.Construct // The cluster that hosts the service. Cluster() awsecs.ICluster // The desired number of instantiations of the task definition to keep running on the service. // // The default is 1 for all new services and uses the existing services desired count // when updating an existing service, if one is not provided. InternalDesiredCount() *float64 // The listener for the service. Listener() awselasticloadbalancingv2.NetworkListener // The Network Load Balancer for the service. LoadBalancer() awselasticloadbalancingv2.NetworkLoadBalancer // The tree node. Node() constructs.Node // The target group for the service. TargetGroup() awselasticloadbalancingv2.NetworkTargetGroup // Adds service as a target of the target group. AddServiceAsTarget(service awsecs.BaseService) CreateAWSLogDriver(prefix *string) awsecs.AwsLogDriver // Returns the default cluster. GetDefaultCluster(scope constructs.Construct, vpc awsec2.IVpc) awsecs.Cluster // Returns a string representation of this construct. ToString() *string }
The base class for NetworkLoadBalancedEc2Service and NetworkLoadBalancedFargateService services.
type NetworkLoadBalancedServiceBaseProps ¶
type NetworkLoadBalancedServiceBaseProps struct { // Whether to enable the deployment circuit breaker. // // If this property is defined, circuit breaker will be implicitly // enabled. CircuitBreaker *awsecs.DeploymentCircuitBreaker `field:"optional" json:"circuitBreaker" yaml:"circuitBreaker"` // The options for configuring an Amazon ECS service to use service discovery. CloudMapOptions *awsecs.CloudMapOptions `field:"optional" json:"cloudMapOptions" yaml:"cloudMapOptions"` // The name of the cluster that hosts the service. // // If a cluster is specified, the vpc construct should be omitted. Alternatively, you can omit both cluster and vpc. Cluster awsecs.ICluster `field:"optional" json:"cluster" yaml:"cluster"` // Specifies which deployment controller to use for the service. // // For more information, see // [Amazon ECS Deployment Types](https://docs.aws.amazon.com/AmazonECS/latest/developerguide/deployment-types.html) DeploymentController *awsecs.DeploymentController `field:"optional" json:"deploymentController" yaml:"deploymentController"` // The desired number of instantiations of the task definition to keep running on the service. // // The minimum value is 1. DesiredCount *float64 `field:"optional" json:"desiredCount" yaml:"desiredCount"` // The domain name for the service, e.g. "api.example.com.". DomainName *string `field:"optional" json:"domainName" yaml:"domainName"` // The Route53 hosted zone for the domain, e.g. "example.com.". DomainZone awsroute53.IHostedZone `field:"optional" json:"domainZone" yaml:"domainZone"` // Specifies whether to enable Amazon ECS managed tags for the tasks within the service. // // For more information, see // [Tagging Your Amazon ECS Resources](https://docs.aws.amazon.com/AmazonECS/latest/developerguide/ecs-using-tags.html) EnableECSManagedTags *bool `field:"optional" json:"enableECSManagedTags" yaml:"enableECSManagedTags"` // The period of time, in seconds, that the Amazon ECS service scheduler ignores unhealthy Elastic Load Balancing target health checks after a task has first started. HealthCheckGracePeriod awscdk.Duration `field:"optional" json:"healthCheckGracePeriod" yaml:"healthCheckGracePeriod"` // Listener port of the network load balancer that will serve traffic to the service. ListenerPort *float64 `field:"optional" json:"listenerPort" yaml:"listenerPort"` // The network load balancer that will serve traffic to the service. // // If the load balancer has been imported, the vpc attribute must be specified // in the call to fromNetworkLoadBalancerAttributes(). // // [disable-awslint:ref-via-interface]. LoadBalancer awselasticloadbalancingv2.INetworkLoadBalancer `field:"optional" json:"loadBalancer" yaml:"loadBalancer"` // The maximum number of tasks, specified as a percentage of the Amazon ECS service's DesiredCount value, that can run in a service during a deployment. MaxHealthyPercent *float64 `field:"optional" json:"maxHealthyPercent" yaml:"maxHealthyPercent"` // The minimum number of tasks, specified as a percentage of the Amazon ECS service's DesiredCount value, that must continue to run and remain healthy during a deployment. MinHealthyPercent *float64 `field:"optional" json:"minHealthyPercent" yaml:"minHealthyPercent"` // Specifies whether to propagate the tags from the task definition or the service to the tasks in the service. // // Tags can only be propagated to the tasks within the service during service creation. PropagateTags awsecs.PropagatedTagSource `field:"optional" json:"propagateTags" yaml:"propagateTags"` // Determines whether the Load Balancer will be internet-facing. PublicLoadBalancer *bool `field:"optional" json:"publicLoadBalancer" yaml:"publicLoadBalancer"` // Specifies whether the Route53 record should be a CNAME, an A record using the Alias feature or no record at all. // // This is useful if you need to work with DNS systems that do not support alias records. RecordType NetworkLoadBalancedServiceRecordType `field:"optional" json:"recordType" yaml:"recordType"` // The name of the service. ServiceName *string `field:"optional" json:"serviceName" yaml:"serviceName"` // The properties required to create a new task definition. // // One of taskImageOptions or taskDefinition must be specified. TaskImageOptions *NetworkLoadBalancedTaskImageOptions `field:"optional" json:"taskImageOptions" yaml:"taskImageOptions"` // The VPC where the container instances will be launched or the elastic network interfaces (ENIs) will be deployed. // // If a vpc is specified, the cluster construct should be omitted. Alternatively, you can omit both vpc and cluster. Vpc awsec2.IVpc `field:"optional" json:"vpc" yaml:"vpc"` }
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 cdk "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 logDriver logDriver var namespace iNamespace var networkLoadBalancer networkLoadBalancer var role role var secret secret var vpc vpc networkLoadBalancedServiceBaseProps := &networkLoadBalancedServiceBaseProps{ circuitBreaker: &deploymentCircuitBreaker{ 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), healthCheckGracePeriod: cdk.*duration.minutes(jsii.Number(30)), 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, }
type NetworkLoadBalancedServiceRecordType ¶
type NetworkLoadBalancedServiceRecordType string
Describes the type of DNS record the service should create.
const ( // Create Route53 A Alias record. NetworkLoadBalancedServiceRecordType_ALIAS NetworkLoadBalancedServiceRecordType = "ALIAS" // Create a CNAME record. NetworkLoadBalancedServiceRecordType_CNAME NetworkLoadBalancedServiceRecordType = "CNAME" // Do not create any DNS records. NetworkLoadBalancedServiceRecordType_NONE NetworkLoadBalancedServiceRecordType = "NONE" )
type NetworkLoadBalancedTaskImageOptions ¶
type NetworkLoadBalancedTaskImageOptions struct { // The image used to start a container. // // Image or taskDefinition must be specified, but not both. Image awsecs.ContainerImage `field:"required" json:"image" yaml:"image"` // The container name value to be specified in the task definition. ContainerName *string `field:"optional" json:"containerName" yaml:"containerName"` // The port number on the container that is bound to the user-specified or automatically assigned host port. // // If you are using containers in a task with the awsvpc or host network mode, exposed ports should be specified using containerPort. // If you are using containers in a task with the bridge network mode and you specify a container port and not a host port, // your container automatically receives a host port in the ephemeral port range. // // Port mappings that are automatically assigned in this way do not count toward the 100 reserved ports limit of a container instance. // // For more information, see // [hostPort](https://docs.aws.amazon.com/AmazonECS/latest/APIReference/API_PortMapping.html#ECS-Type-PortMapping-hostPort). ContainerPort *float64 `field:"optional" json:"containerPort" yaml:"containerPort"` // A key/value map of labels to add to the container. DockerLabels *map[string]*string `field:"optional" json:"dockerLabels" yaml:"dockerLabels"` // Flag to indicate whether to enable logging. EnableLogging *bool `field:"optional" json:"enableLogging" yaml:"enableLogging"` // The environment variables to pass to the container. Environment *map[string]*string `field:"optional" json:"environment" yaml:"environment"` // The name of the task execution IAM role that grants the Amazon ECS container agent permission to call AWS APIs on your behalf. ExecutionRole awsiam.IRole `field:"optional" json:"executionRole" yaml:"executionRole"` // The name of a family that this task definition is registered to. // // A family groups multiple versions of a task definition. Family *string `field:"optional" json:"family" yaml:"family"` // The log driver to use. LogDriver awsecs.LogDriver `field:"optional" json:"logDriver" yaml:"logDriver"` // The secret to expose to the container as an environment variable. Secrets *map[string]awsecs.Secret `field:"optional" json:"secrets" yaml:"secrets"` // The name of the task IAM role that grants containers in the task permission to call AWS APIs on your behalf. TaskRole awsiam.IRole `field:"optional" json:"taskRole" yaml:"taskRole"` }
Example:
var cluster cluster loadBalancedEcsService := ecsPatterns.NewNetworkLoadBalancedEc2Service(this, jsii.String("Service"), &networkLoadBalancedEc2ServiceProps{ cluster: cluster, memoryLimitMiB: jsii.Number(1024), taskImageOptions: &networkLoadBalancedTaskImageOptions{ image: ecs.containerImage.fromRegistry(jsii.String("test")), environment: map[string]*string{ "TEST_ENVIRONMENT_VARIABLE1": jsii.String("test environment variable 1 value"), "TEST_ENVIRONMENT_VARIABLE2": jsii.String("test environment variable 2 value"), }, }, desiredCount: jsii.Number(2), })
type NetworkLoadBalancedTaskImageProps ¶
type NetworkLoadBalancedTaskImageProps struct { // The image used to start a container. // // Image or taskDefinition must be specified, but not both. Image awsecs.ContainerImage `field:"required" json:"image" yaml:"image"` // The container name value to be specified in the task definition. ContainerName *string `field:"optional" json:"containerName" yaml:"containerName"` // A list of port numbers on the container that is bound to the user-specified or automatically assigned host port. // // If you are using containers in a task with the awsvpc or host network mode, exposed ports should be specified using containerPort. // If you are using containers in a task with the bridge network mode and you specify a container port and not a host port, // your container automatically receives a host port in the ephemeral port range. // // Port mappings that are automatically assigned in this way do not count toward the 100 reserved ports limit of a container instance. // // For more information, see // [hostPort](https://docs.aws.amazon.com/AmazonECS/latest/APIReference/API_PortMapping.html#ECS-Type-PortMapping-hostPort). ContainerPorts *[]*float64 `field:"optional" json:"containerPorts" yaml:"containerPorts"` // A key/value map of labels to add to the container. DockerLabels *map[string]*string `field:"optional" json:"dockerLabels" yaml:"dockerLabels"` // Flag to indicate whether to enable logging. EnableLogging *bool `field:"optional" json:"enableLogging" yaml:"enableLogging"` // The environment variables to pass to the container. Environment *map[string]*string `field:"optional" json:"environment" yaml:"environment"` // The name of the task execution IAM role that grants the Amazon ECS container agent permission to call AWS APIs on your behalf. ExecutionRole awsiam.IRole `field:"optional" json:"executionRole" yaml:"executionRole"` // The name of a family that this task definition is registered to. // // A family groups multiple versions of a task definition. Family *string `field:"optional" json:"family" yaml:"family"` // The log driver to use. LogDriver awsecs.LogDriver `field:"optional" json:"logDriver" yaml:"logDriver"` // The secrets to expose to the container as an environment variable. Secrets *map[string]awsecs.Secret `field:"optional" json:"secrets" yaml:"secrets"` // The name of the task IAM role that grants containers in the task permission to call AWS APIs on your behalf. TaskRole awsiam.IRole `field:"optional" json:"taskRole" yaml:"taskRole"` }
Options for configuring a new container.
Example:
// Two network load balancers, each with their own listener and target group. var cluster cluster loadBalancedEc2Service := ecsPatterns.NewNetworkMultipleTargetGroupsEc2Service(this, jsii.String("Service"), &networkMultipleTargetGroupsEc2ServiceProps{ cluster: cluster, memoryLimitMiB: jsii.Number(256), taskImageOptions: &networkLoadBalancedTaskImageProps{ image: ecs.containerImage.fromRegistry(jsii.String("amazon/amazon-ecs-sample")), }, loadBalancers: []networkLoadBalancerProps{ &networkLoadBalancerProps{ name: jsii.String("lb1"), listeners: []networkListenerProps{ &networkListenerProps{ name: jsii.String("listener1"), }, }, }, &networkLoadBalancerProps{ name: jsii.String("lb2"), listeners: []*networkListenerProps{ &networkListenerProps{ name: jsii.String("listener2"), }, }, }, }, targetGroups: []networkTargetProps{ &networkTargetProps{ containerPort: jsii.Number(80), listener: jsii.String("listener1"), }, &networkTargetProps{ containerPort: jsii.Number(90), listener: jsii.String("listener2"), }, }, })
type NetworkLoadBalancerProps ¶
type NetworkLoadBalancerProps struct { // Listeners (at least one listener) attached to this load balancer. Listeners *[]*NetworkListenerProps `field:"required" json:"listeners" yaml:"listeners"` // Name of the load balancer. Name *string `field:"required" json:"name" yaml:"name"` // The domain name for the service, e.g. "api.example.com.". DomainName *string `field:"optional" json:"domainName" yaml:"domainName"` // The Route53 hosted zone for the domain, e.g. "example.com.". DomainZone awsroute53.IHostedZone `field:"optional" json:"domainZone" yaml:"domainZone"` // Determines whether the Load Balancer will be internet-facing. PublicLoadBalancer *bool `field:"optional" json:"publicLoadBalancer" yaml:"publicLoadBalancer"` }
Properties to define an network load balancer.
Example:
// 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 hostedZone hostedZone networkLoadBalancerProps := &networkLoadBalancerProps{ listeners: []networkListenerProps{ &networkListenerProps{ name: jsii.String("name"), // the properties below are optional port: jsii.Number(123), }, }, name: jsii.String("name"), // the properties below are optional domainName: jsii.String("domainName"), domainZone: hostedZone, publicLoadBalancer: jsii.Boolean(false), }
type NetworkMultipleTargetGroupsEc2Service ¶
type NetworkMultipleTargetGroupsEc2Service interface { NetworkMultipleTargetGroupsServiceBase // The cluster that hosts the service. Cluster() awsecs.ICluster // The desired number of instantiations of the task definition to keep running on the service. // // The default is 1 for all new services and uses the existing services desired count // when updating an existing service, if one is not provided. InternalDesiredCount() *float64 // The listener for the service. Listener() awselasticloadbalancingv2.NetworkListener Listeners() *[]awselasticloadbalancingv2.NetworkListener SetListeners(val *[]awselasticloadbalancingv2.NetworkListener) // The Network Load Balancer for the service. LoadBalancer() awselasticloadbalancingv2.NetworkLoadBalancer LogDriver() awsecs.LogDriver SetLogDriver(val awsecs.LogDriver) // The tree node. Node() constructs.Node // The EC2 service in this construct. Service() awsecs.Ec2Service // The default target group for the service. TargetGroup() awselasticloadbalancingv2.NetworkTargetGroup TargetGroups() *[]awselasticloadbalancingv2.NetworkTargetGroup SetTargetGroups(val *[]awselasticloadbalancingv2.NetworkTargetGroup) // The EC2 Task Definition in this construct. TaskDefinition() awsecs.Ec2TaskDefinition AddPortMappingForTargets(container awsecs.ContainerDefinition, targets *[]*NetworkTargetProps) CreateAWSLogDriver(prefix *string) awsecs.AwsLogDriver FindListener(name *string) awselasticloadbalancingv2.NetworkListener // Returns the default cluster. GetDefaultCluster(scope constructs.Construct, vpc awsec2.IVpc) awsecs.Cluster RegisterECSTargets(service awsecs.BaseService, container awsecs.ContainerDefinition, targets *[]*NetworkTargetProps) awselasticloadbalancingv2.NetworkTargetGroup // Returns a string representation of this construct. ToString() *string }
An EC2 service running on an ECS cluster fronted by a network load balancer.
Example:
// Two network load balancers, each with their own listener and target group. var cluster cluster loadBalancedEc2Service := ecsPatterns.NewNetworkMultipleTargetGroupsEc2Service(this, jsii.String("Service"), &networkMultipleTargetGroupsEc2ServiceProps{ cluster: cluster, memoryLimitMiB: jsii.Number(256), taskImageOptions: &networkLoadBalancedTaskImageProps{ image: ecs.containerImage.fromRegistry(jsii.String("amazon/amazon-ecs-sample")), }, loadBalancers: []networkLoadBalancerProps{ &networkLoadBalancerProps{ name: jsii.String("lb1"), listeners: []networkListenerProps{ &networkListenerProps{ name: jsii.String("listener1"), }, }, }, &networkLoadBalancerProps{ name: jsii.String("lb2"), listeners: []*networkListenerProps{ &networkListenerProps{ name: jsii.String("listener2"), }, }, }, }, targetGroups: []networkTargetProps{ &networkTargetProps{ containerPort: jsii.Number(80), listener: jsii.String("listener1"), }, &networkTargetProps{ containerPort: jsii.Number(90), listener: jsii.String("listener2"), }, }, })
func NewNetworkMultipleTargetGroupsEc2Service ¶
func NewNetworkMultipleTargetGroupsEc2Service(scope constructs.Construct, id *string, props *NetworkMultipleTargetGroupsEc2ServiceProps) NetworkMultipleTargetGroupsEc2Service
Constructs a new instance of the NetworkMultipleTargetGroupsEc2Service class.
type NetworkMultipleTargetGroupsEc2ServiceProps ¶
type NetworkMultipleTargetGroupsEc2ServiceProps struct { // The options for configuring an Amazon ECS service to use service discovery. CloudMapOptions *awsecs.CloudMapOptions `field:"optional" json:"cloudMapOptions" yaml:"cloudMapOptions"` // The name of the cluster that hosts the service. // // If a cluster is specified, the vpc construct should be omitted. Alternatively, you can omit both cluster and vpc. Cluster awsecs.ICluster `field:"optional" json:"cluster" yaml:"cluster"` // The desired number of instantiations of the task definition to keep running on the service. // // The minimum value is 1. DesiredCount *float64 `field:"optional" json:"desiredCount" yaml:"desiredCount"` // Specifies whether to enable Amazon ECS managed tags for the tasks within the service. // // For more information, see // [Tagging Your Amazon ECS Resources](https://docs.aws.amazon.com/AmazonECS/latest/developerguide/ecs-using-tags.html) EnableECSManagedTags *bool `field:"optional" json:"enableECSManagedTags" yaml:"enableECSManagedTags"` // The period of time, in seconds, that the Amazon ECS service scheduler ignores unhealthy Elastic Load Balancing target health checks after a task has first started. HealthCheckGracePeriod awscdk.Duration `field:"optional" json:"healthCheckGracePeriod" yaml:"healthCheckGracePeriod"` // The network load balancer that will serve traffic to the service. LoadBalancers *[]*NetworkLoadBalancerProps `field:"optional" json:"loadBalancers" yaml:"loadBalancers"` // Specifies whether to propagate the tags from the task definition or the service to the tasks in the service. // // Tags can only be propagated to the tasks within the service during service creation. PropagateTags awsecs.PropagatedTagSource `field:"optional" json:"propagateTags" yaml:"propagateTags"` // Name of the service. ServiceName *string `field:"optional" json:"serviceName" yaml:"serviceName"` // Properties to specify NLB target groups. TargetGroups *[]*NetworkTargetProps `field:"optional" json:"targetGroups" yaml:"targetGroups"` // The properties required to create a new task definition. // // Only one of TaskDefinition or TaskImageOptions must be specified. TaskImageOptions *NetworkLoadBalancedTaskImageProps `field:"optional" json:"taskImageOptions" yaml:"taskImageOptions"` // The VPC where the container instances will be launched or the elastic network interfaces (ENIs) will be deployed. // // If a vpc is specified, the cluster construct should be omitted. Alternatively, you can omit both vpc and cluster. Vpc awsec2.IVpc `field:"optional" json:"vpc" yaml:"vpc"` // The minimum number of CPU units to reserve for the container. // // Valid values, which determines your range of valid values for the memory parameter:. Cpu *float64 `field:"optional" json:"cpu" yaml:"cpu"` // The amount (in MiB) of memory to present to the container. // // If your container attempts to exceed the allocated memory, the container // is terminated. // // At least one of memoryLimitMiB and memoryReservationMiB is required. MemoryLimitMiB *float64 `field:"optional" json:"memoryLimitMiB" yaml:"memoryLimitMiB"` // The soft limit (in MiB) of memory to reserve for the container. // // When system memory is under heavy contention, Docker attempts to keep the // container memory to this soft limit. However, your container can consume more // memory when it needs to, up to either the hard limit specified with the memory // parameter (if applicable), or all of the available memory on the container // instance, whichever comes first. // // At least one of memoryLimitMiB and memoryReservationMiB is required. // // Note that this setting will be ignored if TaskImagesOptions is specified. MemoryReservationMiB *float64 `field:"optional" json:"memoryReservationMiB" yaml:"memoryReservationMiB"` // The placement constraints to use for tasks in the service. // // For more information, see // [Amazon ECS Task Placement Constraints](https://docs.aws.amazon.com/AmazonECS/latest/developerguide/task-placement-constraints.html). PlacementConstraints *[]awsecs.PlacementConstraint `field:"optional" json:"placementConstraints" yaml:"placementConstraints"` // The placement strategies to use for tasks in the service. // // For more information, see // [Amazon ECS Task Placement Strategies](https://docs.aws.amazon.com/AmazonECS/latest/developerguide/task-placement-strategies.html). PlacementStrategies *[]awsecs.PlacementStrategy `field:"optional" json:"placementStrategies" yaml:"placementStrategies"` // The task definition to use for tasks in the service. Only one of TaskDefinition or TaskImageOptions must be specified. // // [disable-awslint:ref-via-interface]. TaskDefinition awsecs.Ec2TaskDefinition `field:"optional" json:"taskDefinition" yaml:"taskDefinition"` }
The properties for the NetworkMultipleTargetGroupsEc2Service service.
Example:
// Two network load balancers, each with their own listener and target group. var cluster cluster loadBalancedEc2Service := ecsPatterns.NewNetworkMultipleTargetGroupsEc2Service(this, jsii.String("Service"), &networkMultipleTargetGroupsEc2ServiceProps{ cluster: cluster, memoryLimitMiB: jsii.Number(256), taskImageOptions: &networkLoadBalancedTaskImageProps{ image: ecs.containerImage.fromRegistry(jsii.String("amazon/amazon-ecs-sample")), }, loadBalancers: []networkLoadBalancerProps{ &networkLoadBalancerProps{ name: jsii.String("lb1"), listeners: []networkListenerProps{ &networkListenerProps{ name: jsii.String("listener1"), }, }, }, &networkLoadBalancerProps{ name: jsii.String("lb2"), listeners: []*networkListenerProps{ &networkListenerProps{ name: jsii.String("listener2"), }, }, }, }, targetGroups: []networkTargetProps{ &networkTargetProps{ containerPort: jsii.Number(80), listener: jsii.String("listener1"), }, &networkTargetProps{ containerPort: jsii.Number(90), listener: jsii.String("listener2"), }, }, })
type NetworkMultipleTargetGroupsFargateService ¶
type NetworkMultipleTargetGroupsFargateService interface { NetworkMultipleTargetGroupsServiceBase // Determines whether the service will be assigned a public IP address. AssignPublicIp() *bool // The cluster that hosts the service. Cluster() awsecs.ICluster // The desired number of instantiations of the task definition to keep running on the service. // // The default is 1 for all new services and uses the existing services desired count // when updating an existing service, if one is not provided. InternalDesiredCount() *float64 // The listener for the service. Listener() awselasticloadbalancingv2.NetworkListener Listeners() *[]awselasticloadbalancingv2.NetworkListener SetListeners(val *[]awselasticloadbalancingv2.NetworkListener) // The Network Load Balancer for the service. LoadBalancer() awselasticloadbalancingv2.NetworkLoadBalancer LogDriver() awsecs.LogDriver SetLogDriver(val awsecs.LogDriver) // The tree node. Node() constructs.Node // The Fargate service in this construct. Service() awsecs.FargateService // The default target group for the service. TargetGroup() awselasticloadbalancingv2.NetworkTargetGroup TargetGroups() *[]awselasticloadbalancingv2.NetworkTargetGroup SetTargetGroups(val *[]awselasticloadbalancingv2.NetworkTargetGroup) // The Fargate task definition in this construct. TaskDefinition() awsecs.FargateTaskDefinition AddPortMappingForTargets(container awsecs.ContainerDefinition, targets *[]*NetworkTargetProps) CreateAWSLogDriver(prefix *string) awsecs.AwsLogDriver FindListener(name *string) awselasticloadbalancingv2.NetworkListener // Returns the default cluster. GetDefaultCluster(scope constructs.Construct, vpc awsec2.IVpc) awsecs.Cluster RegisterECSTargets(service awsecs.BaseService, container awsecs.ContainerDefinition, targets *[]*NetworkTargetProps) awselasticloadbalancingv2.NetworkTargetGroup // Returns a string representation of this construct. ToString() *string }
A Fargate service running on an ECS cluster fronted by a network load balancer.
Example:
// Two network load balancers, each with their own listener and target group. var cluster cluster loadBalancedFargateService := ecsPatterns.NewNetworkMultipleTargetGroupsFargateService(this, jsii.String("Service"), &networkMultipleTargetGroupsFargateServiceProps{ cluster: cluster, memoryLimitMiB: jsii.Number(512), taskImageOptions: &networkLoadBalancedTaskImageProps{ image: ecs.containerImage.fromRegistry(jsii.String("amazon/amazon-ecs-sample")), }, loadBalancers: []networkLoadBalancerProps{ &networkLoadBalancerProps{ name: jsii.String("lb1"), listeners: []networkListenerProps{ &networkListenerProps{ name: jsii.String("listener1"), }, }, }, &networkLoadBalancerProps{ name: jsii.String("lb2"), listeners: []*networkListenerProps{ &networkListenerProps{ name: jsii.String("listener2"), }, }, }, }, targetGroups: []networkTargetProps{ &networkTargetProps{ containerPort: jsii.Number(80), listener: jsii.String("listener1"), }, &networkTargetProps{ containerPort: jsii.Number(90), listener: jsii.String("listener2"), }, }, })
func NewNetworkMultipleTargetGroupsFargateService ¶
func NewNetworkMultipleTargetGroupsFargateService(scope constructs.Construct, id *string, props *NetworkMultipleTargetGroupsFargateServiceProps) NetworkMultipleTargetGroupsFargateService
Constructs a new instance of the NetworkMultipleTargetGroupsFargateService class.
type NetworkMultipleTargetGroupsFargateServiceProps ¶
type NetworkMultipleTargetGroupsFargateServiceProps struct { // The options for configuring an Amazon ECS service to use service discovery. CloudMapOptions *awsecs.CloudMapOptions `field:"optional" json:"cloudMapOptions" yaml:"cloudMapOptions"` // The name of the cluster that hosts the service. // // If a cluster is specified, the vpc construct should be omitted. Alternatively, you can omit both cluster and vpc. Cluster awsecs.ICluster `field:"optional" json:"cluster" yaml:"cluster"` // The desired number of instantiations of the task definition to keep running on the service. // // The minimum value is 1. DesiredCount *float64 `field:"optional" json:"desiredCount" yaml:"desiredCount"` // Specifies whether to enable Amazon ECS managed tags for the tasks within the service. // // For more information, see // [Tagging Your Amazon ECS Resources](https://docs.aws.amazon.com/AmazonECS/latest/developerguide/ecs-using-tags.html) EnableECSManagedTags *bool `field:"optional" json:"enableECSManagedTags" yaml:"enableECSManagedTags"` // The period of time, in seconds, that the Amazon ECS service scheduler ignores unhealthy Elastic Load Balancing target health checks after a task has first started. HealthCheckGracePeriod awscdk.Duration `field:"optional" json:"healthCheckGracePeriod" yaml:"healthCheckGracePeriod"` // The network load balancer that will serve traffic to the service. LoadBalancers *[]*NetworkLoadBalancerProps `field:"optional" json:"loadBalancers" yaml:"loadBalancers"` // Specifies whether to propagate the tags from the task definition or the service to the tasks in the service. // // Tags can only be propagated to the tasks within the service during service creation. PropagateTags awsecs.PropagatedTagSource `field:"optional" json:"propagateTags" yaml:"propagateTags"` // Name of the service. ServiceName *string `field:"optional" json:"serviceName" yaml:"serviceName"` // Properties to specify NLB target groups. TargetGroups *[]*NetworkTargetProps `field:"optional" json:"targetGroups" yaml:"targetGroups"` // The properties required to create a new task definition. // // Only one of TaskDefinition or TaskImageOptions must be specified. TaskImageOptions *NetworkLoadBalancedTaskImageProps `field:"optional" json:"taskImageOptions" yaml:"taskImageOptions"` // The VPC where the container instances will be launched or the elastic network interfaces (ENIs) will be deployed. // // If a vpc is specified, the cluster construct should be omitted. Alternatively, you can omit both vpc and cluster. Vpc awsec2.IVpc `field:"optional" json:"vpc" yaml:"vpc"` // Determines whether the service will be assigned a public IP address. AssignPublicIp *bool `field:"optional" json:"assignPublicIp" yaml:"assignPublicIp"` // The number of cpu units used by the task. // // Valid values, which determines your range of valid values for the memory parameter: // // 256 (.25 vCPU) - Available memory values: 0.5GB, 1GB, 2GB // // 512 (.5 vCPU) - Available memory values: 1GB, 2GB, 3GB, 4GB // // 1024 (1 vCPU) - Available memory values: 2GB, 3GB, 4GB, 5GB, 6GB, 7GB, 8GB // // 2048 (2 vCPU) - Available memory values: Between 4GB and 16GB in 1GB increments // // 4096 (4 vCPU) - Available memory values: Between 8GB and 30GB in 1GB increments // // This default is set in the underlying FargateTaskDefinition construct. Cpu *float64 `field:"optional" json:"cpu" yaml:"cpu"` // The amount (in MiB) of memory used by the task. // // This field is required and you must use one of the following values, which determines your range of valid values // for the cpu parameter: // // 512 (0.5 GB), 1024 (1 GB), 2048 (2 GB) - Available cpu values: 256 (.25 vCPU) // // 1024 (1 GB), 2048 (2 GB), 3072 (3 GB), 4096 (4 GB) - Available cpu values: 512 (.5 vCPU) // // 2048 (2 GB), 3072 (3 GB), 4096 (4 GB), 5120 (5 GB), 6144 (6 GB), 7168 (7 GB), 8192 (8 GB) - Available cpu values: 1024 (1 vCPU) // // Between 4096 (4 GB) and 16384 (16 GB) in increments of 1024 (1 GB) - Available cpu values: 2048 (2 vCPU) // // Between 8192 (8 GB) and 30720 (30 GB) in increments of 1024 (1 GB) - Available cpu values: 4096 (4 vCPU) // // This default is set in the underlying FargateTaskDefinition construct. MemoryLimitMiB *float64 `field:"optional" json:"memoryLimitMiB" yaml:"memoryLimitMiB"` // The platform version on which to run your service. // // If one is not specified, the LATEST platform version is used by default. For more information, see // [AWS Fargate Platform Versions](https://docs.aws.amazon.com/AmazonECS/latest/developerguide/platform_versions.html) // in the Amazon Elastic Container Service Developer Guide. PlatformVersion awsecs.FargatePlatformVersion `field:"optional" json:"platformVersion" yaml:"platformVersion"` // The task definition to use for tasks in the service. Only one of TaskDefinition or TaskImageOptions must be specified. // // [disable-awslint:ref-via-interface]. TaskDefinition awsecs.FargateTaskDefinition `field:"optional" json:"taskDefinition" yaml:"taskDefinition"` }
The properties for the NetworkMultipleTargetGroupsFargateService service.
Example:
// Two network load balancers, each with their own listener and target group. var cluster cluster loadBalancedFargateService := ecsPatterns.NewNetworkMultipleTargetGroupsFargateService(this, jsii.String("Service"), &networkMultipleTargetGroupsFargateServiceProps{ cluster: cluster, memoryLimitMiB: jsii.Number(512), taskImageOptions: &networkLoadBalancedTaskImageProps{ image: ecs.containerImage.fromRegistry(jsii.String("amazon/amazon-ecs-sample")), }, loadBalancers: []networkLoadBalancerProps{ &networkLoadBalancerProps{ name: jsii.String("lb1"), listeners: []networkListenerProps{ &networkListenerProps{ name: jsii.String("listener1"), }, }, }, &networkLoadBalancerProps{ name: jsii.String("lb2"), listeners: []*networkListenerProps{ &networkListenerProps{ name: jsii.String("listener2"), }, }, }, }, targetGroups: []networkTargetProps{ &networkTargetProps{ containerPort: jsii.Number(80), listener: jsii.String("listener1"), }, &networkTargetProps{ containerPort: jsii.Number(90), listener: jsii.String("listener2"), }, }, })
type NetworkMultipleTargetGroupsServiceBase ¶
type NetworkMultipleTargetGroupsServiceBase interface { constructs.Construct // The cluster that hosts the service. Cluster() awsecs.ICluster // The desired number of instantiations of the task definition to keep running on the service. // // The default is 1 for all new services and uses the existing services desired count // when updating an existing service, if one is not provided. InternalDesiredCount() *float64 // The listener for the service. Listener() awselasticloadbalancingv2.NetworkListener Listeners() *[]awselasticloadbalancingv2.NetworkListener SetListeners(val *[]awselasticloadbalancingv2.NetworkListener) // The Network Load Balancer for the service. LoadBalancer() awselasticloadbalancingv2.NetworkLoadBalancer LogDriver() awsecs.LogDriver SetLogDriver(val awsecs.LogDriver) // The tree node. Node() constructs.Node TargetGroups() *[]awselasticloadbalancingv2.NetworkTargetGroup SetTargetGroups(val *[]awselasticloadbalancingv2.NetworkTargetGroup) AddPortMappingForTargets(container awsecs.ContainerDefinition, targets *[]*NetworkTargetProps) CreateAWSLogDriver(prefix *string) awsecs.AwsLogDriver FindListener(name *string) awselasticloadbalancingv2.NetworkListener // Returns the default cluster. GetDefaultCluster(scope constructs.Construct, vpc awsec2.IVpc) awsecs.Cluster RegisterECSTargets(service awsecs.BaseService, container awsecs.ContainerDefinition, targets *[]*NetworkTargetProps) awselasticloadbalancingv2.NetworkTargetGroup // Returns a string representation of this construct. ToString() *string }
The base class for NetworkMultipleTargetGroupsEc2Service and NetworkMultipleTargetGroupsFargateService classes.
type NetworkMultipleTargetGroupsServiceBaseProps ¶
type NetworkMultipleTargetGroupsServiceBaseProps struct { // The options for configuring an Amazon ECS service to use service discovery. CloudMapOptions *awsecs.CloudMapOptions `field:"optional" json:"cloudMapOptions" yaml:"cloudMapOptions"` // The name of the cluster that hosts the service. // // If a cluster is specified, the vpc construct should be omitted. Alternatively, you can omit both cluster and vpc. Cluster awsecs.ICluster `field:"optional" json:"cluster" yaml:"cluster"` // The desired number of instantiations of the task definition to keep running on the service. // // The minimum value is 1. DesiredCount *float64 `field:"optional" json:"desiredCount" yaml:"desiredCount"` // Specifies whether to enable Amazon ECS managed tags for the tasks within the service. // // For more information, see // [Tagging Your Amazon ECS Resources](https://docs.aws.amazon.com/AmazonECS/latest/developerguide/ecs-using-tags.html) EnableECSManagedTags *bool `field:"optional" json:"enableECSManagedTags" yaml:"enableECSManagedTags"` // The period of time, in seconds, that the Amazon ECS service scheduler ignores unhealthy Elastic Load Balancing target health checks after a task has first started. HealthCheckGracePeriod awscdk.Duration `field:"optional" json:"healthCheckGracePeriod" yaml:"healthCheckGracePeriod"` // The network load balancer that will serve traffic to the service. LoadBalancers *[]*NetworkLoadBalancerProps `field:"optional" json:"loadBalancers" yaml:"loadBalancers"` // Specifies whether to propagate the tags from the task definition or the service to the tasks in the service. // // Tags can only be propagated to the tasks within the service during service creation. PropagateTags awsecs.PropagatedTagSource `field:"optional" json:"propagateTags" yaml:"propagateTags"` // Name of the service. ServiceName *string `field:"optional" json:"serviceName" yaml:"serviceName"` // Properties to specify NLB target groups. TargetGroups *[]*NetworkTargetProps `field:"optional" json:"targetGroups" yaml:"targetGroups"` // The properties required to create a new task definition. // // Only one of TaskDefinition or TaskImageOptions must be specified. TaskImageOptions *NetworkLoadBalancedTaskImageProps `field:"optional" json:"taskImageOptions" yaml:"taskImageOptions"` // The VPC where the container instances will be launched or the elastic network interfaces (ENIs) will be deployed. // // If a vpc is specified, the cluster construct should be omitted. Alternatively, you can omit both vpc and cluster. Vpc awsec2.IVpc `field:"optional" json:"vpc" yaml:"vpc"` }
The properties for the base NetworkMultipleTargetGroupsEc2Service or NetworkMultipleTargetGroupsFargateService service.
Example:
// The code below shows an example of how to instantiate this type. // The values are placeholders you should change. import cdk "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 logDriver logDriver var namespace iNamespace var role role var secret secret var vpc vpc networkMultipleTargetGroupsServiceBaseProps := &networkMultipleTargetGroupsServiceBaseProps{ 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, desiredCount: jsii.Number(123), enableECSManagedTags: jsii.Boolean(false), healthCheckGracePeriod: cdk.*duration.minutes(jsii.Number(30)), loadBalancers: []networkLoadBalancerProps{ &networkLoadBalancerProps{ listeners: []networkListenerProps{ &networkListenerProps{ name: jsii.String("name"), // the properties below are optional port: jsii.Number(123), }, }, name: jsii.String("name"), // the properties below are optional domainName: jsii.String("domainName"), domainZone: hostedZone, publicLoadBalancer: jsii.Boolean(false), }, }, propagateTags: awscdk.Aws_ecs.propagatedTagSource_SERVICE, serviceName: jsii.String("serviceName"), targetGroups: []networkTargetProps{ &networkTargetProps{ containerPort: jsii.Number(123), // the properties below are optional listener: jsii.String("listener"), }, }, taskImageOptions: &networkLoadBalancedTaskImageProps{ image: containerImage, // the properties below are optional containerName: jsii.String("containerName"), containerPorts: []*f64{ 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, }
type NetworkTargetProps ¶
type NetworkTargetProps struct { // The port number of the container. // // Only applicable when using application/network load balancers. ContainerPort *float64 `field:"required" json:"containerPort" yaml:"containerPort"` // Name of the listener the target group attached to. Listener *string `field:"optional" json:"listener" yaml:"listener"` }
Properties to define a network load balancer target group.
Example:
// 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" networkTargetProps := &networkTargetProps{ containerPort: jsii.Number(123), // the properties below are optional listener: jsii.String("listener"), }
type QueueProcessingEc2Service ¶
type QueueProcessingEc2Service interface { QueueProcessingServiceBase // The cluster where your service will be deployed. Cluster() awsecs.ICluster // The dead letter queue for the primary SQS queue. DeadLetterQueue() awssqs.IQueue // Environment variables that will include the queue name. Environment() *map[string]*string // The AwsLogDriver to use for logging if logging is enabled. LogDriver() awsecs.LogDriver // The maximum number of instances for autoscaling to scale up to. MaxCapacity() *float64 // The minimum number of instances for autoscaling to scale down to. MinCapacity() *float64 // The tree node. Node() constructs.Node // The scaling interval for autoscaling based off an SQS Queue size. ScalingSteps() *[]*awsapplicationautoscaling.ScalingInterval // The secret environment variables. Secrets() *map[string]awsecs.Secret // The EC2 service in this construct. Service() awsecs.Ec2Service // The SQS queue that the service will process from. SqsQueue() awssqs.IQueue // The EC2 task definition in this construct. TaskDefinition() awsecs.Ec2TaskDefinition // Configure autoscaling based off of CPU utilization as well as the number of messages visible in the SQS queue. ConfigureAutoscalingForService(service awsecs.BaseService) // Returns the default cluster. GetDefaultCluster(scope constructs.Construct, vpc awsec2.IVpc) awsecs.Cluster // Grant SQS permissions to an ECS service. GrantPermissionsToService(service awsecs.BaseService) // Returns a string representation of this construct. ToString() *string }
Class to create a queue processing EC2 service.
Example:
var cluster cluster queueProcessingEc2Service := ecsPatterns.NewQueueProcessingEc2Service(this, jsii.String("Service"), &queueProcessingEc2ServiceProps{ cluster: cluster, memoryLimitMiB: jsii.Number(1024), image: ecs.containerImage.fromRegistry(jsii.String("test")), command: []*string{ jsii.String("-c"), jsii.String("4"), jsii.String("amazon.com"), }, enableLogging: jsii.Boolean(false), desiredTaskCount: jsii.Number(2), environment: map[string]*string{ "TEST_ENVIRONMENT_VARIABLE1": jsii.String("test environment variable 1 value"), "TEST_ENVIRONMENT_VARIABLE2": jsii.String("test environment variable 2 value"), }, maxScalingCapacity: jsii.Number(5), containerName: jsii.String("test"), })
func NewQueueProcessingEc2Service ¶
func NewQueueProcessingEc2Service(scope constructs.Construct, id *string, props *QueueProcessingEc2ServiceProps) QueueProcessingEc2Service
Constructs a new instance of the QueueProcessingEc2Service class.
type QueueProcessingEc2ServiceProps ¶
type QueueProcessingEc2ServiceProps struct { // The image used to start a container. Image awsecs.ContainerImage `field:"required" json:"image" yaml:"image"` // A list of Capacity Provider strategies used to place a service. CapacityProviderStrategies *[]*awsecs.CapacityProviderStrategy `field:"optional" json:"capacityProviderStrategies" yaml:"capacityProviderStrategies"` // Whether to enable the deployment circuit breaker. // // If this property is defined, circuit breaker will be implicitly // enabled. CircuitBreaker *awsecs.DeploymentCircuitBreaker `field:"optional" json:"circuitBreaker" yaml:"circuitBreaker"` // The name of the cluster that hosts the service. // // If a cluster is specified, the vpc construct should be omitted. Alternatively, you can omit both cluster and vpc. Cluster awsecs.ICluster `field:"optional" json:"cluster" yaml:"cluster"` // The command that is passed to the container. // // If you provide a shell command as a single string, you have to quote command-line arguments. Command *[]*string `field:"optional" json:"command" yaml:"command"` // Specifies which deployment controller to use for the service. // // For more information, see // [Amazon ECS Deployment Types](https://docs.aws.amazon.com/AmazonECS/latest/developerguide/deployment-types.html) DeploymentController *awsecs.DeploymentController `field:"optional" json:"deploymentController" yaml:"deploymentController"` // Specifies whether to enable Amazon ECS managed tags for the tasks within the service. // // For more information, see // [Tagging Your Amazon ECS Resources](https://docs.aws.amazon.com/AmazonECS/latest/developerguide/ecs-using-tags.html) EnableECSManagedTags *bool `field:"optional" json:"enableECSManagedTags" yaml:"enableECSManagedTags"` // Flag to indicate whether to enable logging. EnableLogging *bool `field:"optional" json:"enableLogging" yaml:"enableLogging"` // The environment variables to pass to the container. // // The variable `QUEUE_NAME` with value `queue.queueName` will // always be passed. Environment *map[string]*string `field:"optional" json:"environment" yaml:"environment"` // The name of a family that the task definition is registered to. // // A family groups multiple versions of a task definition. Family *string `field:"optional" json:"family" yaml:"family"` // The log driver to use. LogDriver awsecs.LogDriver `field:"optional" json:"logDriver" yaml:"logDriver"` // The maximum number of tasks, specified as a percentage of the Amazon ECS service's DesiredCount value, that can run in a service during a deployment. MaxHealthyPercent *float64 `field:"optional" json:"maxHealthyPercent" yaml:"maxHealthyPercent"` // The maximum number of times that a message can be received by consumers. // // When this value is exceeded for a message the message will be automatically sent to the Dead Letter Queue. MaxReceiveCount *float64 `field:"optional" json:"maxReceiveCount" yaml:"maxReceiveCount"` // Maximum capacity to scale to. MaxScalingCapacity *float64 `field:"optional" json:"maxScalingCapacity" yaml:"maxScalingCapacity"` // The minimum number of tasks, specified as a percentage of the Amazon ECS service's DesiredCount value, that must continue to run and remain healthy during a deployment. MinHealthyPercent *float64 `field:"optional" json:"minHealthyPercent" yaml:"minHealthyPercent"` // Minimum capacity to scale to. MinScalingCapacity *float64 `field:"optional" json:"minScalingCapacity" yaml:"minScalingCapacity"` // Specifies whether to propagate the tags from the task definition or the service to the tasks in the service. // // Tags can only be propagated to the tasks within the service during service creation. PropagateTags awsecs.PropagatedTagSource `field:"optional" json:"propagateTags" yaml:"propagateTags"` // A queue for which to process items from. // // If specified and this is a FIFO queue, the queue name must end in the string '.fifo'. See // [CreateQueue](https://docs.aws.amazon.com/AWSSimpleQueueService/latest/APIReference/API_CreateQueue.html) Queue awssqs.IQueue `field:"optional" json:"queue" yaml:"queue"` // The number of seconds that Dead Letter Queue retains a message. RetentionPeriod awscdk.Duration `field:"optional" json:"retentionPeriod" yaml:"retentionPeriod"` // The intervals for scaling based on the SQS queue's ApproximateNumberOfMessagesVisible metric. // // Maps a range of metric values to a particular scaling behavior. See // [Simple and Step Scaling Policies for Amazon EC2 Auto Scaling](https://docs.aws.amazon.com/autoscaling/ec2/userguide/as-scaling-simple-step.html) ScalingSteps *[]*awsapplicationautoscaling.ScalingInterval `field:"optional" json:"scalingSteps" yaml:"scalingSteps"` // The secret to expose to the container as an environment variable. Secrets *map[string]awsecs.Secret `field:"optional" json:"secrets" yaml:"secrets"` // The name of the service. ServiceName *string `field:"optional" json:"serviceName" yaml:"serviceName"` // Timeout of processing a single message. // // After dequeuing, the processor has this much time to handle the message and delete it from the queue // before it becomes visible again for dequeueing by another processor. Values must be between 0 and (12 hours). VisibilityTimeout awscdk.Duration `field:"optional" json:"visibilityTimeout" yaml:"visibilityTimeout"` // The VPC where the container instances will be launched or the elastic network interfaces (ENIs) will be deployed. // // If a vpc is specified, the cluster construct should be omitted. Alternatively, you can omit both vpc and cluster. Vpc awsec2.IVpc `field:"optional" json:"vpc" yaml:"vpc"` // Optional name for the container added. ContainerName *string `field:"optional" json:"containerName" yaml:"containerName"` // The number of cpu units used by the task. // // Valid values, which determines your range of valid values for the memory parameter: // // 256 (.25 vCPU) - Available memory values: 0.5GB, 1GB, 2GB // // 512 (.5 vCPU) - Available memory values: 1GB, 2GB, 3GB, 4GB // // 1024 (1 vCPU) - Available memory values: 2GB, 3GB, 4GB, 5GB, 6GB, 7GB, 8GB // // 2048 (2 vCPU) - Available memory values: Between 4GB and 16GB in 1GB increments // // 4096 (4 vCPU) - Available memory values: Between 8GB and 30GB in 1GB increments // // This default is set in the underlying FargateTaskDefinition construct. Cpu *float64 `field:"optional" json:"cpu" yaml:"cpu"` // Gpu count for container in task definition. // // Set this if you want to use gpu based instances. GpuCount *float64 `field:"optional" json:"gpuCount" yaml:"gpuCount"` // The hard limit (in MiB) of memory to present to the container. // // If your container attempts to exceed the allocated memory, the container // is terminated. // // At least one of memoryLimitMiB and memoryReservationMiB is required for non-Fargate services. MemoryLimitMiB *float64 `field:"optional" json:"memoryLimitMiB" yaml:"memoryLimitMiB"` // The soft limit (in MiB) of memory to reserve for the container. // // When system memory is under contention, Docker attempts to keep the // container memory within the limit. If the container requires more memory, // it can consume up to the value specified by the Memory property or all of // the available memory on the container instance—whichever comes first. // // At least one of memoryLimitMiB and memoryReservationMiB is required for non-Fargate services. MemoryReservationMiB *float64 `field:"optional" json:"memoryReservationMiB" yaml:"memoryReservationMiB"` // The placement constraints to use for tasks in the service. // // For more information, see // [Amazon ECS Task Placement Constraints](https://docs.aws.amazon.com/AmazonECS/latest/developerguide/task-placement-constraints.html). PlacementConstraints *[]awsecs.PlacementConstraint `field:"optional" json:"placementConstraints" yaml:"placementConstraints"` // The placement strategies to use for tasks in the service. // // For more information, see // [Amazon ECS Task Placement Strategies](https://docs.aws.amazon.com/AmazonECS/latest/developerguide/task-placement-strategies.html). PlacementStrategies *[]awsecs.PlacementStrategy `field:"optional" json:"placementStrategies" yaml:"placementStrategies"` }
The properties for the QueueProcessingEc2Service service.
Example:
var cluster cluster queueProcessingEc2Service := ecsPatterns.NewQueueProcessingEc2Service(this, jsii.String("Service"), &queueProcessingEc2ServiceProps{ cluster: cluster, memoryLimitMiB: jsii.Number(1024), image: ecs.containerImage.fromRegistry(jsii.String("test")), command: []*string{ jsii.String("-c"), jsii.String("4"), jsii.String("amazon.com"), }, enableLogging: jsii.Boolean(false), desiredTaskCount: jsii.Number(2), environment: map[string]*string{ "TEST_ENVIRONMENT_VARIABLE1": jsii.String("test environment variable 1 value"), "TEST_ENVIRONMENT_VARIABLE2": jsii.String("test environment variable 2 value"), }, maxScalingCapacity: jsii.Number(5), containerName: jsii.String("test"), })
type QueueProcessingFargateService ¶
type QueueProcessingFargateService interface { QueueProcessingServiceBase // The cluster where your service will be deployed. Cluster() awsecs.ICluster // The dead letter queue for the primary SQS queue. DeadLetterQueue() awssqs.IQueue // Environment variables that will include the queue name. Environment() *map[string]*string // The AwsLogDriver to use for logging if logging is enabled. LogDriver() awsecs.LogDriver // The maximum number of instances for autoscaling to scale up to. MaxCapacity() *float64 // The minimum number of instances for autoscaling to scale down to. MinCapacity() *float64 // The tree node. Node() constructs.Node // The scaling interval for autoscaling based off an SQS Queue size. ScalingSteps() *[]*awsapplicationautoscaling.ScalingInterval // The secret environment variables. Secrets() *map[string]awsecs.Secret // The Fargate service in this construct. Service() awsecs.FargateService // The SQS queue that the service will process from. SqsQueue() awssqs.IQueue // The Fargate task definition in this construct. TaskDefinition() awsecs.FargateTaskDefinition // Configure autoscaling based off of CPU utilization as well as the number of messages visible in the SQS queue. ConfigureAutoscalingForService(service awsecs.BaseService) // Returns the default cluster. GetDefaultCluster(scope constructs.Construct, vpc awsec2.IVpc) awsecs.Cluster // Grant SQS permissions to an ECS service. GrantPermissionsToService(service awsecs.BaseService) // Returns a string representation of this construct. ToString() *string }
Class to create a queue processing Fargate service.
Example:
var cluster cluster cluster.enableFargateCapacityProviders() queueProcessingFargateService := ecsPatterns.NewQueueProcessingFargateService(this, jsii.String("Service"), &queueProcessingFargateServiceProps{ cluster: cluster, memoryLimitMiB: jsii.Number(512), image: ecs.containerImage.fromRegistry(jsii.String("test")), capacityProviderStrategies: []capacityProviderStrategy{ &capacityProviderStrategy{ capacityProvider: jsii.String("FARGATE_SPOT"), weight: jsii.Number(2), }, &capacityProviderStrategy{ capacityProvider: jsii.String("FARGATE"), weight: jsii.Number(1), }, }, })
func NewQueueProcessingFargateService ¶
func NewQueueProcessingFargateService(scope constructs.Construct, id *string, props *QueueProcessingFargateServiceProps) QueueProcessingFargateService
Constructs a new instance of the QueueProcessingFargateService class.
type QueueProcessingFargateServiceProps ¶
type QueueProcessingFargateServiceProps struct { // The image used to start a container. Image awsecs.ContainerImage `field:"required" json:"image" yaml:"image"` // A list of Capacity Provider strategies used to place a service. CapacityProviderStrategies *[]*awsecs.CapacityProviderStrategy `field:"optional" json:"capacityProviderStrategies" yaml:"capacityProviderStrategies"` // Whether to enable the deployment circuit breaker. // // If this property is defined, circuit breaker will be implicitly // enabled. CircuitBreaker *awsecs.DeploymentCircuitBreaker `field:"optional" json:"circuitBreaker" yaml:"circuitBreaker"` // The name of the cluster that hosts the service. // // If a cluster is specified, the vpc construct should be omitted. Alternatively, you can omit both cluster and vpc. Cluster awsecs.ICluster `field:"optional" json:"cluster" yaml:"cluster"` // The command that is passed to the container. // // If you provide a shell command as a single string, you have to quote command-line arguments. Command *[]*string `field:"optional" json:"command" yaml:"command"` // Specifies which deployment controller to use for the service. // // For more information, see // [Amazon ECS Deployment Types](https://docs.aws.amazon.com/AmazonECS/latest/developerguide/deployment-types.html) DeploymentController *awsecs.DeploymentController `field:"optional" json:"deploymentController" yaml:"deploymentController"` // Specifies whether to enable Amazon ECS managed tags for the tasks within the service. // // For more information, see // [Tagging Your Amazon ECS Resources](https://docs.aws.amazon.com/AmazonECS/latest/developerguide/ecs-using-tags.html) EnableECSManagedTags *bool `field:"optional" json:"enableECSManagedTags" yaml:"enableECSManagedTags"` // Flag to indicate whether to enable logging. EnableLogging *bool `field:"optional" json:"enableLogging" yaml:"enableLogging"` // The environment variables to pass to the container. // // The variable `QUEUE_NAME` with value `queue.queueName` will // always be passed. Environment *map[string]*string `field:"optional" json:"environment" yaml:"environment"` // The name of a family that the task definition is registered to. // // A family groups multiple versions of a task definition. Family *string `field:"optional" json:"family" yaml:"family"` // The log driver to use. LogDriver awsecs.LogDriver `field:"optional" json:"logDriver" yaml:"logDriver"` // The maximum number of tasks, specified as a percentage of the Amazon ECS service's DesiredCount value, that can run in a service during a deployment. MaxHealthyPercent *float64 `field:"optional" json:"maxHealthyPercent" yaml:"maxHealthyPercent"` // The maximum number of times that a message can be received by consumers. // // When this value is exceeded for a message the message will be automatically sent to the Dead Letter Queue. MaxReceiveCount *float64 `field:"optional" json:"maxReceiveCount" yaml:"maxReceiveCount"` // Maximum capacity to scale to. MaxScalingCapacity *float64 `field:"optional" json:"maxScalingCapacity" yaml:"maxScalingCapacity"` // The minimum number of tasks, specified as a percentage of the Amazon ECS service's DesiredCount value, that must continue to run and remain healthy during a deployment. MinHealthyPercent *float64 `field:"optional" json:"minHealthyPercent" yaml:"minHealthyPercent"` // Minimum capacity to scale to. MinScalingCapacity *float64 `field:"optional" json:"minScalingCapacity" yaml:"minScalingCapacity"` // Specifies whether to propagate the tags from the task definition or the service to the tasks in the service. // // Tags can only be propagated to the tasks within the service during service creation. PropagateTags awsecs.PropagatedTagSource `field:"optional" json:"propagateTags" yaml:"propagateTags"` // A queue for which to process items from. // // If specified and this is a FIFO queue, the queue name must end in the string '.fifo'. See // [CreateQueue](https://docs.aws.amazon.com/AWSSimpleQueueService/latest/APIReference/API_CreateQueue.html) Queue awssqs.IQueue `field:"optional" json:"queue" yaml:"queue"` // The number of seconds that Dead Letter Queue retains a message. RetentionPeriod awscdk.Duration `field:"optional" json:"retentionPeriod" yaml:"retentionPeriod"` // The intervals for scaling based on the SQS queue's ApproximateNumberOfMessagesVisible metric. // // Maps a range of metric values to a particular scaling behavior. See // [Simple and Step Scaling Policies for Amazon EC2 Auto Scaling](https://docs.aws.amazon.com/autoscaling/ec2/userguide/as-scaling-simple-step.html) ScalingSteps *[]*awsapplicationautoscaling.ScalingInterval `field:"optional" json:"scalingSteps" yaml:"scalingSteps"` // The secret to expose to the container as an environment variable. Secrets *map[string]awsecs.Secret `field:"optional" json:"secrets" yaml:"secrets"` // The name of the service. ServiceName *string `field:"optional" json:"serviceName" yaml:"serviceName"` // Timeout of processing a single message. // // After dequeuing, the processor has this much time to handle the message and delete it from the queue // before it becomes visible again for dequeueing by another processor. Values must be between 0 and (12 hours). VisibilityTimeout awscdk.Duration `field:"optional" json:"visibilityTimeout" yaml:"visibilityTimeout"` // The VPC where the container instances will be launched or the elastic network interfaces (ENIs) will be deployed. // // If a vpc is specified, the cluster construct should be omitted. Alternatively, you can omit both vpc and cluster. Vpc awsec2.IVpc `field:"optional" json:"vpc" yaml:"vpc"` // Specifies whether the task's elastic network interface receives a public IP address. // // If true, each task will receive a public IP address. AssignPublicIp *bool `field:"optional" json:"assignPublicIp" yaml:"assignPublicIp"` // Optional name for the container added. ContainerName *string `field:"optional" json:"containerName" yaml:"containerName"` // The number of cpu units used by the task. // // Valid values, which determines your range of valid values for the memory parameter: // // 256 (.25 vCPU) - Available memory values: 0.5GB, 1GB, 2GB // // 512 (.5 vCPU) - Available memory values: 1GB, 2GB, 3GB, 4GB // // 1024 (1 vCPU) - Available memory values: 2GB, 3GB, 4GB, 5GB, 6GB, 7GB, 8GB // // 2048 (2 vCPU) - Available memory values: Between 4GB and 16GB in 1GB increments // // 4096 (4 vCPU) - Available memory values: Between 8GB and 30GB in 1GB increments // // This default is set in the underlying FargateTaskDefinition construct. Cpu *float64 `field:"optional" json:"cpu" yaml:"cpu"` // The health check command and associated configuration parameters for the container. HealthCheck *awsecs.HealthCheck `field:"optional" json:"healthCheck" yaml:"healthCheck"` // The amount (in MiB) of memory used by the task. // // This field is required and you must use one of the following values, which determines your range of valid values // for the cpu parameter: // // 0.5GB, 1GB, 2GB - Available cpu values: 256 (.25 vCPU) // // 1GB, 2GB, 3GB, 4GB - Available cpu values: 512 (.5 vCPU) // // 2GB, 3GB, 4GB, 5GB, 6GB, 7GB, 8GB - Available cpu values: 1024 (1 vCPU) // // Between 4GB and 16GB in 1GB increments - Available cpu values: 2048 (2 vCPU) // // Between 8GB and 30GB in 1GB increments - Available cpu values: 4096 (4 vCPU) // // This default is set in the underlying FargateTaskDefinition construct. MemoryLimitMiB *float64 `field:"optional" json:"memoryLimitMiB" yaml:"memoryLimitMiB"` // The platform version on which to run your service. // // If one is not specified, the LATEST platform version is used by default. For more information, see // [AWS Fargate Platform Versions](https://docs.aws.amazon.com/AmazonECS/latest/developerguide/platform_versions.html) // in the Amazon Elastic Container Service Developer Guide. PlatformVersion awsecs.FargatePlatformVersion `field:"optional" json:"platformVersion" yaml:"platformVersion"` // The security groups to associate with the service. // // If you do not specify a security group, a new security group is created. SecurityGroups *[]awsec2.ISecurityGroup `field:"optional" json:"securityGroups" yaml:"securityGroups"` // The subnets to associate with the service. TaskSubnets *awsec2.SubnetSelection `field:"optional" json:"taskSubnets" yaml:"taskSubnets"` }
The properties for the QueueProcessingFargateService service.
Example:
var cluster cluster cluster.enableFargateCapacityProviders() queueProcessingFargateService := ecsPatterns.NewQueueProcessingFargateService(this, jsii.String("Service"), &queueProcessingFargateServiceProps{ cluster: cluster, memoryLimitMiB: jsii.Number(512), image: ecs.containerImage.fromRegistry(jsii.String("test")), capacityProviderStrategies: []capacityProviderStrategy{ &capacityProviderStrategy{ capacityProvider: jsii.String("FARGATE_SPOT"), weight: jsii.Number(2), }, &capacityProviderStrategy{ capacityProvider: jsii.String("FARGATE"), weight: jsii.Number(1), }, }, })
type QueueProcessingServiceBase ¶
type QueueProcessingServiceBase interface { constructs.Construct // The cluster where your service will be deployed. Cluster() awsecs.ICluster // The dead letter queue for the primary SQS queue. DeadLetterQueue() awssqs.IQueue // Environment variables that will include the queue name. Environment() *map[string]*string // The AwsLogDriver to use for logging if logging is enabled. LogDriver() awsecs.LogDriver // The maximum number of instances for autoscaling to scale up to. MaxCapacity() *float64 // The minimum number of instances for autoscaling to scale down to. MinCapacity() *float64 // The tree node. Node() constructs.Node // The scaling interval for autoscaling based off an SQS Queue size. ScalingSteps() *[]*awsapplicationautoscaling.ScalingInterval // The secret environment variables. Secrets() *map[string]awsecs.Secret // The SQS queue that the service will process from. SqsQueue() awssqs.IQueue // Configure autoscaling based off of CPU utilization as well as the number of messages visible in the SQS queue. ConfigureAutoscalingForService(service awsecs.BaseService) // Returns the default cluster. GetDefaultCluster(scope constructs.Construct, vpc awsec2.IVpc) awsecs.Cluster // Grant SQS permissions to an ECS service. GrantPermissionsToService(service awsecs.BaseService) // Returns a string representation of this construct. ToString() *string }
The base class for QueueProcessingEc2Service and QueueProcessingFargateService services.
type QueueProcessingServiceBaseProps ¶
type QueueProcessingServiceBaseProps struct { // The image used to start a container. Image awsecs.ContainerImage `field:"required" json:"image" yaml:"image"` // A list of Capacity Provider strategies used to place a service. CapacityProviderStrategies *[]*awsecs.CapacityProviderStrategy `field:"optional" json:"capacityProviderStrategies" yaml:"capacityProviderStrategies"` // Whether to enable the deployment circuit breaker. // // If this property is defined, circuit breaker will be implicitly // enabled. CircuitBreaker *awsecs.DeploymentCircuitBreaker `field:"optional" json:"circuitBreaker" yaml:"circuitBreaker"` // The name of the cluster that hosts the service. // // If a cluster is specified, the vpc construct should be omitted. Alternatively, you can omit both cluster and vpc. Cluster awsecs.ICluster `field:"optional" json:"cluster" yaml:"cluster"` // The command that is passed to the container. // // If you provide a shell command as a single string, you have to quote command-line arguments. Command *[]*string `field:"optional" json:"command" yaml:"command"` // Specifies which deployment controller to use for the service. // // For more information, see // [Amazon ECS Deployment Types](https://docs.aws.amazon.com/AmazonECS/latest/developerguide/deployment-types.html) DeploymentController *awsecs.DeploymentController `field:"optional" json:"deploymentController" yaml:"deploymentController"` // Specifies whether to enable Amazon ECS managed tags for the tasks within the service. // // For more information, see // [Tagging Your Amazon ECS Resources](https://docs.aws.amazon.com/AmazonECS/latest/developerguide/ecs-using-tags.html) EnableECSManagedTags *bool `field:"optional" json:"enableECSManagedTags" yaml:"enableECSManagedTags"` // Flag to indicate whether to enable logging. EnableLogging *bool `field:"optional" json:"enableLogging" yaml:"enableLogging"` // The environment variables to pass to the container. // // The variable `QUEUE_NAME` with value `queue.queueName` will // always be passed. Environment *map[string]*string `field:"optional" json:"environment" yaml:"environment"` // The name of a family that the task definition is registered to. // // A family groups multiple versions of a task definition. Family *string `field:"optional" json:"family" yaml:"family"` // The log driver to use. LogDriver awsecs.LogDriver `field:"optional" json:"logDriver" yaml:"logDriver"` // The maximum number of tasks, specified as a percentage of the Amazon ECS service's DesiredCount value, that can run in a service during a deployment. MaxHealthyPercent *float64 `field:"optional" json:"maxHealthyPercent" yaml:"maxHealthyPercent"` // The maximum number of times that a message can be received by consumers. // // When this value is exceeded for a message the message will be automatically sent to the Dead Letter Queue. MaxReceiveCount *float64 `field:"optional" json:"maxReceiveCount" yaml:"maxReceiveCount"` // Maximum capacity to scale to. MaxScalingCapacity *float64 `field:"optional" json:"maxScalingCapacity" yaml:"maxScalingCapacity"` // The minimum number of tasks, specified as a percentage of the Amazon ECS service's DesiredCount value, that must continue to run and remain healthy during a deployment. MinHealthyPercent *float64 `field:"optional" json:"minHealthyPercent" yaml:"minHealthyPercent"` // Minimum capacity to scale to. MinScalingCapacity *float64 `field:"optional" json:"minScalingCapacity" yaml:"minScalingCapacity"` // Specifies whether to propagate the tags from the task definition or the service to the tasks in the service. // // Tags can only be propagated to the tasks within the service during service creation. PropagateTags awsecs.PropagatedTagSource `field:"optional" json:"propagateTags" yaml:"propagateTags"` // A queue for which to process items from. // // If specified and this is a FIFO queue, the queue name must end in the string '.fifo'. See // [CreateQueue](https://docs.aws.amazon.com/AWSSimpleQueueService/latest/APIReference/API_CreateQueue.html) Queue awssqs.IQueue `field:"optional" json:"queue" yaml:"queue"` // The number of seconds that Dead Letter Queue retains a message. RetentionPeriod awscdk.Duration `field:"optional" json:"retentionPeriod" yaml:"retentionPeriod"` // The intervals for scaling based on the SQS queue's ApproximateNumberOfMessagesVisible metric. // // Maps a range of metric values to a particular scaling behavior. See // [Simple and Step Scaling Policies for Amazon EC2 Auto Scaling](https://docs.aws.amazon.com/autoscaling/ec2/userguide/as-scaling-simple-step.html) ScalingSteps *[]*awsapplicationautoscaling.ScalingInterval `field:"optional" json:"scalingSteps" yaml:"scalingSteps"` // The secret to expose to the container as an environment variable. Secrets *map[string]awsecs.Secret `field:"optional" json:"secrets" yaml:"secrets"` // The name of the service. ServiceName *string `field:"optional" json:"serviceName" yaml:"serviceName"` // Timeout of processing a single message. // // After dequeuing, the processor has this much time to handle the message and delete it from the queue // before it becomes visible again for dequeueing by another processor. Values must be between 0 and (12 hours). VisibilityTimeout awscdk.Duration `field:"optional" json:"visibilityTimeout" yaml:"visibilityTimeout"` // The VPC where the container instances will be launched or the elastic network interfaces (ENIs) will be deployed. // // If a vpc is specified, the cluster construct should be omitted. Alternatively, you can omit both vpc and cluster. Vpc awsec2.IVpc `field:"optional" json:"vpc" yaml:"vpc"` }
The properties for the base QueueProcessingEc2Service or QueueProcessingFargateService service.
Example:
// The code below shows an example of how to instantiate this type. // The values are placeholders you should change. import cdk "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 containerImage containerImage var logDriver logDriver var queue queue var secret secret var vpc vpc queueProcessingServiceBaseProps := &queueProcessingServiceBaseProps{ image: containerImage, // the properties below are optional capacityProviderStrategies: []capacityProviderStrategy{ &capacityProviderStrategy{ capacityProvider: jsii.String("capacityProvider"), // the properties below are optional base: jsii.Number(123), weight: jsii.Number(123), }, }, circuitBreaker: &deploymentCircuitBreaker{ rollback: jsii.Boolean(false), }, cluster: cluster, command: []*string{ jsii.String("command"), }, deploymentController: &deploymentController{ type: awscdk.Aws_ecs.deploymentControllerType_ECS, }, enableECSManagedTags: jsii.Boolean(false), enableLogging: jsii.Boolean(false), environment: map[string]*string{ "environmentKey": jsii.String("environment"), }, family: jsii.String("family"), logDriver: logDriver, maxHealthyPercent: jsii.Number(123), maxReceiveCount: jsii.Number(123), maxScalingCapacity: jsii.Number(123), minHealthyPercent: jsii.Number(123), minScalingCapacity: jsii.Number(123), propagateTags: awscdk.*Aws_ecs.propagatedTagSource_SERVICE, queue: queue, retentionPeriod: cdk.duration.minutes(jsii.Number(30)), scalingSteps: []scalingInterval{ &scalingInterval{ change: jsii.Number(123), // the properties below are optional lower: jsii.Number(123), upper: jsii.Number(123), }, }, secrets: map[string]*secret{ "secretsKey": secret, }, serviceName: jsii.String("serviceName"), visibilityTimeout: cdk.*duration.minutes(jsii.Number(30)), vpc: vpc, }
type ScheduledEc2Task ¶
type ScheduledEc2Task interface { ScheduledTaskBase // The name of the cluster that hosts the service. Cluster() awsecs.ICluster // The desired number of instantiations of the task definition to keep running on the service. // // The minimum value is 1. DesiredTaskCount() *float64 // The CloudWatch Events rule for the service. EventRule() awsevents.Rule // The tree node. Node() constructs.Node // In what subnets to place the task's ENIs. // // (Only applicable in case the TaskDefinition is configured for AwsVpc networking). SubnetSelection() *awsec2.SubnetSelection // The ECS task in this construct. Task() awseventstargets.EcsTask // The EC2 task definition in this construct. TaskDefinition() awsecs.Ec2TaskDefinition // Adds task as a target of the scheduled event rule. AddTaskAsTarget(ecsTaskTarget awseventstargets.EcsTask) // Create an ECS task using the task definition provided and add it to the scheduled event rule. AddTaskDefinitionToEventTarget(taskDefinition awsecs.TaskDefinition) awseventstargets.EcsTask // Create an AWS Log Driver with the provided streamPrefix. CreateAWSLogDriver(prefix *string) awsecs.AwsLogDriver // Returns the default cluster. GetDefaultCluster(scope constructs.Construct, vpc awsec2.IVpc) awsecs.Cluster // Returns a string representation of this construct. ToString() *string }
A scheduled EC2 task that will be initiated off of CloudWatch Events.
Example:
// Instantiate an Amazon EC2 Task to run at a scheduled interval var cluster cluster ecsScheduledTask := ecsPatterns.NewScheduledEc2Task(this, jsii.String("ScheduledTask"), &scheduledEc2TaskProps{ cluster: cluster, scheduledEc2TaskImageOptions: &scheduledEc2TaskImageOptions{ image: ecs.containerImage.fromRegistry(jsii.String("amazon/amazon-ecs-sample")), memoryLimitMiB: jsii.Number(256), environment: map[string]*string{ "name": jsii.String("TRIGGER"), "value": jsii.String("CloudWatch Events"), }, }, schedule: appscaling.schedule.expression(jsii.String("rate(1 minute)")), enabled: jsii.Boolean(true), ruleName: jsii.String("sample-scheduled-task-rule"), })
func NewScheduledEc2Task ¶
func NewScheduledEc2Task(scope constructs.Construct, id *string, props *ScheduledEc2TaskProps) ScheduledEc2Task
Constructs a new instance of the ScheduledEc2Task class.
type ScheduledEc2TaskDefinitionOptions ¶
type ScheduledEc2TaskDefinitionOptions struct { // The task definition to use for tasks in the service. One of image or taskDefinition must be specified. // // [disable-awslint:ref-via-interface]. TaskDefinition awsecs.Ec2TaskDefinition `field:"required" json:"taskDefinition" yaml:"taskDefinition"` }
The properties for the ScheduledEc2Task using a task definition.
Example:
// 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 ec2TaskDefinition ec2TaskDefinition scheduledEc2TaskDefinitionOptions := &scheduledEc2TaskDefinitionOptions{ taskDefinition: ec2TaskDefinition, }
type ScheduledEc2TaskImageOptions ¶
type ScheduledEc2TaskImageOptions struct { // The image used to start a container. // // Image or taskDefinition must be specified, but not both. Image awsecs.ContainerImage `field:"required" json:"image" yaml:"image"` // The command that is passed to the container. // // If you provide a shell command as a single string, you have to quote command-line arguments. Command *[]*string `field:"optional" json:"command" yaml:"command"` // The environment variables to pass to the container. Environment *map[string]*string `field:"optional" json:"environment" yaml:"environment"` // The log driver to use. LogDriver awsecs.LogDriver `field:"optional" json:"logDriver" yaml:"logDriver"` // The secret to expose to the container as an environment variable. Secrets *map[string]awsecs.Secret `field:"optional" json:"secrets" yaml:"secrets"` // The minimum number of CPU units to reserve for the container. Cpu *float64 `field:"optional" json:"cpu" yaml:"cpu"` // The hard limit (in MiB) of memory to present to the container. // // If your container attempts to exceed the allocated memory, the container // is terminated. // // At least one of memoryLimitMiB and memoryReservationMiB is required for non-Fargate services. MemoryLimitMiB *float64 `field:"optional" json:"memoryLimitMiB" yaml:"memoryLimitMiB"` // The soft limit (in MiB) of memory to reserve for the container. // // When system memory is under contention, Docker attempts to keep the // container memory within the limit. If the container requires more memory, // it can consume up to the value specified by the Memory property or all of // the available memory on the container instance—whichever comes first. // // At least one of memoryLimitMiB and memoryReservationMiB is required for non-Fargate services. MemoryReservationMiB *float64 `field:"optional" json:"memoryReservationMiB" yaml:"memoryReservationMiB"` }
The properties for the ScheduledEc2Task using an image.
Example:
// Instantiate an Amazon EC2 Task to run at a scheduled interval var cluster cluster ecsScheduledTask := ecsPatterns.NewScheduledEc2Task(this, jsii.String("ScheduledTask"), &scheduledEc2TaskProps{ cluster: cluster, scheduledEc2TaskImageOptions: &scheduledEc2TaskImageOptions{ image: ecs.containerImage.fromRegistry(jsii.String("amazon/amazon-ecs-sample")), memoryLimitMiB: jsii.Number(256), environment: map[string]*string{ "name": jsii.String("TRIGGER"), "value": jsii.String("CloudWatch Events"), }, }, schedule: appscaling.schedule.expression(jsii.String("rate(1 minute)")), enabled: jsii.Boolean(true), ruleName: jsii.String("sample-scheduled-task-rule"), })
type ScheduledEc2TaskProps ¶
type ScheduledEc2TaskProps struct { // The schedule or rate (frequency) that determines when CloudWatch Events runs the rule. // // For more information, see // [Schedule Expression Syntax for Rules](https://docs.aws.amazon.com/AmazonCloudWatch/latest/events/ScheduledEvents.html) // in the Amazon CloudWatch User Guide. Schedule awsapplicationautoscaling.Schedule `field:"required" json:"schedule" yaml:"schedule"` // The name of the cluster that hosts the service. // // If a cluster is specified, the vpc construct should be omitted. Alternatively, you can omit both cluster and vpc. Cluster awsecs.ICluster `field:"optional" json:"cluster" yaml:"cluster"` // The desired number of instantiations of the task definition to keep running on the service. DesiredTaskCount *float64 `field:"optional" json:"desiredTaskCount" yaml:"desiredTaskCount"` // Indicates whether the rule is enabled. Enabled *bool `field:"optional" json:"enabled" yaml:"enabled"` // A name for the rule. RuleName *string `field:"optional" json:"ruleName" yaml:"ruleName"` // Existing security groups to use for your service. SecurityGroups *[]awsec2.ISecurityGroup `field:"optional" json:"securityGroups" yaml:"securityGroups"` // In what subnets to place the task's ENIs. // // (Only applicable in case the TaskDefinition is configured for AwsVpc networking). SubnetSelection *awsec2.SubnetSelection `field:"optional" json:"subnetSelection" yaml:"subnetSelection"` // The VPC where the container instances will be launched or the elastic network interfaces (ENIs) will be deployed. // // If a vpc is specified, the cluster construct should be omitted. Alternatively, you can omit both vpc and cluster. Vpc awsec2.IVpc `field:"optional" json:"vpc" yaml:"vpc"` // The properties to define if using an existing TaskDefinition in this construct. // // ScheduledEc2TaskDefinitionOptions or ScheduledEc2TaskImageOptions must be defined, but not both. ScheduledEc2TaskDefinitionOptions *ScheduledEc2TaskDefinitionOptions `field:"optional" json:"scheduledEc2TaskDefinitionOptions" yaml:"scheduledEc2TaskDefinitionOptions"` // The properties to define if the construct is to create a TaskDefinition. // // ScheduledEc2TaskDefinitionOptions or ScheduledEc2TaskImageOptions must be defined, but not both. ScheduledEc2TaskImageOptions *ScheduledEc2TaskImageOptions `field:"optional" json:"scheduledEc2TaskImageOptions" yaml:"scheduledEc2TaskImageOptions"` }
The properties for the ScheduledEc2Task task.
Example:
// Instantiate an Amazon EC2 Task to run at a scheduled interval var cluster cluster ecsScheduledTask := ecsPatterns.NewScheduledEc2Task(this, jsii.String("ScheduledTask"), &scheduledEc2TaskProps{ cluster: cluster, scheduledEc2TaskImageOptions: &scheduledEc2TaskImageOptions{ image: ecs.containerImage.fromRegistry(jsii.String("amazon/amazon-ecs-sample")), memoryLimitMiB: jsii.Number(256), environment: map[string]*string{ "name": jsii.String("TRIGGER"), "value": jsii.String("CloudWatch Events"), }, }, schedule: appscaling.schedule.expression(jsii.String("rate(1 minute)")), enabled: jsii.Boolean(true), ruleName: jsii.String("sample-scheduled-task-rule"), })
type ScheduledFargateTask ¶
type ScheduledFargateTask interface { ScheduledTaskBase // The name of the cluster that hosts the service. Cluster() awsecs.ICluster // The desired number of instantiations of the task definition to keep running on the service. // // The minimum value is 1. DesiredTaskCount() *float64 // The CloudWatch Events rule for the service. EventRule() awsevents.Rule // The tree node. Node() constructs.Node // In what subnets to place the task's ENIs. // // (Only applicable in case the TaskDefinition is configured for AwsVpc networking). SubnetSelection() *awsec2.SubnetSelection // The ECS task in this construct. Task() awseventstargets.EcsTask // The Fargate task definition in this construct. TaskDefinition() awsecs.FargateTaskDefinition // Adds task as a target of the scheduled event rule. AddTaskAsTarget(ecsTaskTarget awseventstargets.EcsTask) // Create an ECS task using the task definition provided and add it to the scheduled event rule. AddTaskDefinitionToEventTarget(taskDefinition awsecs.TaskDefinition) awseventstargets.EcsTask // Create an AWS Log Driver with the provided streamPrefix. CreateAWSLogDriver(prefix *string) awsecs.AwsLogDriver // Returns the default cluster. GetDefaultCluster(scope constructs.Construct, vpc awsec2.IVpc) awsecs.Cluster // Returns a string representation of this construct. ToString() *string }
A scheduled Fargate task that will be initiated off of CloudWatch Events.
Example:
var cluster cluster scheduledFargateTask := ecsPatterns.NewScheduledFargateTask(this, jsii.String("ScheduledFargateTask"), &scheduledFargateTaskProps{ cluster: cluster, scheduledFargateTaskImageOptions: &scheduledFargateTaskImageOptions{ image: ecs.containerImage.fromRegistry(jsii.String("amazon/amazon-ecs-sample")), memoryLimitMiB: jsii.Number(512), }, schedule: appscaling.schedule.expression(jsii.String("rate(1 minute)")), platformVersion: ecs.fargatePlatformVersion_LATEST, })
func NewScheduledFargateTask ¶
func NewScheduledFargateTask(scope constructs.Construct, id *string, props *ScheduledFargateTaskProps) ScheduledFargateTask
Constructs a new instance of the ScheduledFargateTask class.
type ScheduledFargateTaskDefinitionOptions ¶
type ScheduledFargateTaskDefinitionOptions struct { // The task definition to use for tasks in the service. Image or taskDefinition must be specified, but not both. // // [disable-awslint:ref-via-interface]. TaskDefinition awsecs.FargateTaskDefinition `field:"required" json:"taskDefinition" yaml:"taskDefinition"` }
The properties for the ScheduledFargateTask using a task definition.
Example:
// 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 fargateTaskDefinition fargateTaskDefinition scheduledFargateTaskDefinitionOptions := &scheduledFargateTaskDefinitionOptions{ taskDefinition: fargateTaskDefinition, }
type ScheduledFargateTaskImageOptions ¶
type ScheduledFargateTaskImageOptions struct { // The image used to start a container. // // Image or taskDefinition must be specified, but not both. Image awsecs.ContainerImage `field:"required" json:"image" yaml:"image"` // The command that is passed to the container. // // If you provide a shell command as a single string, you have to quote command-line arguments. Command *[]*string `field:"optional" json:"command" yaml:"command"` // The environment variables to pass to the container. Environment *map[string]*string `field:"optional" json:"environment" yaml:"environment"` // The log driver to use. LogDriver awsecs.LogDriver `field:"optional" json:"logDriver" yaml:"logDriver"` // The secret to expose to the container as an environment variable. Secrets *map[string]awsecs.Secret `field:"optional" json:"secrets" yaml:"secrets"` // The number of cpu units used by the task. // // Valid values, which determines your range of valid values for the memory parameter: // // 256 (.25 vCPU) - Available memory values: 0.5GB, 1GB, 2GB // // 512 (.5 vCPU) - Available memory values: 1GB, 2GB, 3GB, 4GB // // 1024 (1 vCPU) - Available memory values: 2GB, 3GB, 4GB, 5GB, 6GB, 7GB, 8GB // // 2048 (2 vCPU) - Available memory values: Between 4GB and 16GB in 1GB increments // // 4096 (4 vCPU) - Available memory values: Between 8GB and 30GB in 1GB increments // // This default is set in the underlying FargateTaskDefinition construct. Cpu *float64 `field:"optional" json:"cpu" yaml:"cpu"` // The hard limit (in MiB) of memory to present to the container. // // If your container attempts to exceed the allocated memory, the container // is terminated. MemoryLimitMiB *float64 `field:"optional" json:"memoryLimitMiB" yaml:"memoryLimitMiB"` }
The properties for the ScheduledFargateTask using an image.
Example:
var cluster cluster scheduledFargateTask := ecsPatterns.NewScheduledFargateTask(this, jsii.String("ScheduledFargateTask"), &scheduledFargateTaskProps{ cluster: cluster, scheduledFargateTaskImageOptions: &scheduledFargateTaskImageOptions{ image: ecs.containerImage.fromRegistry(jsii.String("amazon/amazon-ecs-sample")), memoryLimitMiB: jsii.Number(512), }, schedule: appscaling.schedule.expression(jsii.String("rate(1 minute)")), platformVersion: ecs.fargatePlatformVersion_LATEST, })
type ScheduledFargateTaskProps ¶
type ScheduledFargateTaskProps struct { // The schedule or rate (frequency) that determines when CloudWatch Events runs the rule. // // For more information, see // [Schedule Expression Syntax for Rules](https://docs.aws.amazon.com/AmazonCloudWatch/latest/events/ScheduledEvents.html) // in the Amazon CloudWatch User Guide. Schedule awsapplicationautoscaling.Schedule `field:"required" json:"schedule" yaml:"schedule"` // The name of the cluster that hosts the service. // // If a cluster is specified, the vpc construct should be omitted. Alternatively, you can omit both cluster and vpc. Cluster awsecs.ICluster `field:"optional" json:"cluster" yaml:"cluster"` // The desired number of instantiations of the task definition to keep running on the service. DesiredTaskCount *float64 `field:"optional" json:"desiredTaskCount" yaml:"desiredTaskCount"` // Indicates whether the rule is enabled. Enabled *bool `field:"optional" json:"enabled" yaml:"enabled"` // A name for the rule. RuleName *string `field:"optional" json:"ruleName" yaml:"ruleName"` // Existing security groups to use for your service. SecurityGroups *[]awsec2.ISecurityGroup `field:"optional" json:"securityGroups" yaml:"securityGroups"` // In what subnets to place the task's ENIs. // // (Only applicable in case the TaskDefinition is configured for AwsVpc networking). SubnetSelection *awsec2.SubnetSelection `field:"optional" json:"subnetSelection" yaml:"subnetSelection"` // The VPC where the container instances will be launched or the elastic network interfaces (ENIs) will be deployed. // // If a vpc is specified, the cluster construct should be omitted. Alternatively, you can omit both vpc and cluster. Vpc awsec2.IVpc `field:"optional" json:"vpc" yaml:"vpc"` // The platform version on which to run your service. // // If one is not specified, the LATEST platform version is used by default. For more information, see // [AWS Fargate Platform Versions](https://docs.aws.amazon.com/AmazonECS/latest/developerguide/platform_versions.html) // in the Amazon Elastic Container Service Developer Guide. PlatformVersion awsecs.FargatePlatformVersion `field:"optional" json:"platformVersion" yaml:"platformVersion"` // The properties to define if using an existing TaskDefinition in this construct. // // ScheduledFargateTaskDefinitionOptions or ScheduledFargateTaskImageOptions must be defined, but not both. ScheduledFargateTaskDefinitionOptions *ScheduledFargateTaskDefinitionOptions `field:"optional" json:"scheduledFargateTaskDefinitionOptions" yaml:"scheduledFargateTaskDefinitionOptions"` // The properties to define if the construct is to create a TaskDefinition. // // ScheduledFargateTaskDefinitionOptions or ScheduledFargateTaskImageOptions must be defined, but not both. ScheduledFargateTaskImageOptions *ScheduledFargateTaskImageOptions `field:"optional" json:"scheduledFargateTaskImageOptions" yaml:"scheduledFargateTaskImageOptions"` }
The properties for the ScheduledFargateTask task.
Example:
var cluster cluster scheduledFargateTask := ecsPatterns.NewScheduledFargateTask(this, jsii.String("ScheduledFargateTask"), &scheduledFargateTaskProps{ cluster: cluster, scheduledFargateTaskImageOptions: &scheduledFargateTaskImageOptions{ image: ecs.containerImage.fromRegistry(jsii.String("amazon/amazon-ecs-sample")), memoryLimitMiB: jsii.Number(512), }, schedule: appscaling.schedule.expression(jsii.String("rate(1 minute)")), platformVersion: ecs.fargatePlatformVersion_LATEST, })
type ScheduledTaskBase ¶
type ScheduledTaskBase interface { constructs.Construct // The name of the cluster that hosts the service. Cluster() awsecs.ICluster // The desired number of instantiations of the task definition to keep running on the service. // // The minimum value is 1. DesiredTaskCount() *float64 // The CloudWatch Events rule for the service. EventRule() awsevents.Rule // The tree node. Node() constructs.Node // In what subnets to place the task's ENIs. // // (Only applicable in case the TaskDefinition is configured for AwsVpc networking). SubnetSelection() *awsec2.SubnetSelection // Adds task as a target of the scheduled event rule. AddTaskAsTarget(ecsTaskTarget awseventstargets.EcsTask) // Create an ECS task using the task definition provided and add it to the scheduled event rule. AddTaskDefinitionToEventTarget(taskDefinition awsecs.TaskDefinition) awseventstargets.EcsTask // Create an AWS Log Driver with the provided streamPrefix. CreateAWSLogDriver(prefix *string) awsecs.AwsLogDriver // Returns the default cluster. GetDefaultCluster(scope constructs.Construct, vpc awsec2.IVpc) awsecs.Cluster // Returns a string representation of this construct. ToString() *string }
The base class for ScheduledEc2Task and ScheduledFargateTask tasks.
type ScheduledTaskBaseProps ¶
type ScheduledTaskBaseProps struct { // The schedule or rate (frequency) that determines when CloudWatch Events runs the rule. // // For more information, see // [Schedule Expression Syntax for Rules](https://docs.aws.amazon.com/AmazonCloudWatch/latest/events/ScheduledEvents.html) // in the Amazon CloudWatch User Guide. Schedule awsapplicationautoscaling.Schedule `field:"required" json:"schedule" yaml:"schedule"` // The name of the cluster that hosts the service. // // If a cluster is specified, the vpc construct should be omitted. Alternatively, you can omit both cluster and vpc. Cluster awsecs.ICluster `field:"optional" json:"cluster" yaml:"cluster"` // The desired number of instantiations of the task definition to keep running on the service. DesiredTaskCount *float64 `field:"optional" json:"desiredTaskCount" yaml:"desiredTaskCount"` // Indicates whether the rule is enabled. Enabled *bool `field:"optional" json:"enabled" yaml:"enabled"` // A name for the rule. RuleName *string `field:"optional" json:"ruleName" yaml:"ruleName"` // Existing security groups to use for your service. SecurityGroups *[]awsec2.ISecurityGroup `field:"optional" json:"securityGroups" yaml:"securityGroups"` // In what subnets to place the task's ENIs. // // (Only applicable in case the TaskDefinition is configured for AwsVpc networking). SubnetSelection *awsec2.SubnetSelection `field:"optional" json:"subnetSelection" yaml:"subnetSelection"` // The VPC where the container instances will be launched or the elastic network interfaces (ENIs) will be deployed. // // If a vpc is specified, the cluster construct should be omitted. Alternatively, you can omit both vpc and cluster. Vpc awsec2.IVpc `field:"optional" json:"vpc" yaml:"vpc"` }
The properties for the base ScheduledEc2Task or ScheduledFargateTask task.
Example:
// 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" var cluster cluster var schedule schedule var securityGroup securityGroup var subnet subnet var subnetFilter subnetFilter var vpc vpc scheduledTaskBaseProps := &scheduledTaskBaseProps{ schedule: schedule, // the properties below are optional cluster: cluster, desiredTaskCount: jsii.Number(123), enabled: jsii.Boolean(false), ruleName: jsii.String("ruleName"), securityGroups: []iSecurityGroup{ securityGroup, }, subnetSelection: &subnetSelection{ availabilityZones: []*string{ jsii.String("availabilityZones"), }, onePerAz: jsii.Boolean(false), subnetFilters: []*subnetFilter{ subnetFilter, }, subnetGroupName: jsii.String("subnetGroupName"), subnets: []iSubnet{ subnet, }, subnetType: awscdk.Aws_ec2.subnetType_PRIVATE_ISOLATED, }, vpc: vpc, }
type ScheduledTaskImageProps ¶
type ScheduledTaskImageProps struct { // The image used to start a container. // // Image or taskDefinition must be specified, but not both. Image awsecs.ContainerImage `field:"required" json:"image" yaml:"image"` // The command that is passed to the container. // // If you provide a shell command as a single string, you have to quote command-line arguments. Command *[]*string `field:"optional" json:"command" yaml:"command"` // The environment variables to pass to the container. Environment *map[string]*string `field:"optional" json:"environment" yaml:"environment"` // The log driver to use. LogDriver awsecs.LogDriver `field:"optional" json:"logDriver" yaml:"logDriver"` // The secret to expose to the container as an environment variable. Secrets *map[string]awsecs.Secret `field:"optional" json:"secrets" yaml:"secrets"` }
Example:
// 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 containerImage containerImage var logDriver logDriver var secret secret scheduledTaskImageProps := &scheduledTaskImageProps{ image: containerImage, // the properties below are optional command: []*string{ jsii.String("command"), }, environment: map[string]*string{ "environmentKey": jsii.String("environment"), }, logDriver: logDriver, secrets: map[string]*secret{ "secretsKey": secret, }, }