cdklabscdkecscodedeploy

package module
v0.0.213 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 27, 2023 License: Apache-2.0 Imports: 18 Imported by: 0

README

CDK ECS CodeDeploy

npm version Maven Central PyPI version NuGet version Gitpod Ready-to-Code Mergify

This project contains CDK constructs to create CodeDeploy ECS deployments.

Installation

TypeScript
yarn add @cdklabs/cdk-ecs-codedeploy
Java

See https://mvnrepository.com/artifact/io.github.cdklabs/cdk-ecs-codedeploy

Python

See https://pypi.org/project/cdklabs.ecs-codedeploy/

C#

See https://www.nuget.org/packages/Cdklabs.CdkEcsCodeDeploy/

Deployments

CodeDeploy for ECS can manage the deployment of new task definitions to ECS services. Only 1 deployment construct can be defined for a given EcsDeploymentGroup.

var deploymentGroup iEcsDeploymentGroup
var taskDefinition iTaskDefinition


cdklabscdkecscodedeploy.NewEcsDeployment(&EcsDeploymentProps{
	DeploymentGroup: DeploymentGroup,
	TargetService: &TargetService{
		TaskDefinition: *TaskDefinition,
		ContainerName: jsii.String("mycontainer"),
		ContainerPort: jsii.Number(80),
	},
})

The deployment will use the AutoRollbackConfig for the EcsDeploymentGroup unless it is overridden in the deployment:

var deploymentGroup iEcsDeploymentGroup
var taskDefinition iTaskDefinition


cdklabscdkecscodedeploy.NewEcsDeployment(&EcsDeploymentProps{
	DeploymentGroup: DeploymentGroup,
	TargetService: &TargetService{
		TaskDefinition: *TaskDefinition,
		ContainerName: jsii.String("mycontainer"),
		ContainerPort: jsii.Number(80),
	},
	AutoRollback: &AutoRollbackConfig{
		FailedDeployment: jsii.Boolean(true),
		DeploymentInAlarm: jsii.Boolean(true),
		StoppedDeployment: jsii.Boolean(false),
	},
})

By default, the deployment will timeout after 30 minutes. The timeout value can be overridden:

var deploymentGroup iEcsDeploymentGroup
var taskDefinition iTaskDefinition


cdklabscdkecscodedeploy.NewEcsDeployment(&EcsDeploymentProps{
	DeploymentGroup: DeploymentGroup,
	TargetService: &TargetService{
		TaskDefinition: *TaskDefinition,
		ContainerName: jsii.String("mycontainer"),
		ContainerPort: jsii.Number(80),
	},
	Timeout: awscdk.Duration_Minutes(jsii.Number(60)),
})
API Canaries

CodeDeploy can leverage Cloudwatch Alarms to trigger automatic rollbacks. The ApiCanary construct simplifies the process for creating CloudWatch Synthetics Canaries to monitor APIs. The following code demonstrates a canary that monitors https://xkcd.com/908/info.0.json and checks the JSON response to assert that safe_title has the value of 'The Cloud'.

canary := cdklabscdkecscodedeploy.NewApiCanary(stack, jsii.String("Canary"), &ApiCanaryProps{
	BaseUrl: jsii.String("https://xkcd.com"),
	DurationAlarmThreshold: awscdk.Duration_Seconds(jsii.Number(5)),
	ThreadCount: jsii.Number(5),
	Steps: []apiTestStep{
		&apiTestStep{
			Name: jsii.String("info"),
			Path: jsii.String("/908/info.0.json"),
			JmesPath: jsii.String("safe_title"),
			ExpectedValue: jsii.String("The Cloud"),
		},
	},
})
Application Load Balanced CodeDeployed Fargate Service

An L3 construct named ApplicationLoadBalancedCodeDeployedFargateService extends ApplicationLoadBalancedFargateService and adds support for deploying new versions of the service with AWS CodeDeploy. Additionally, an Amazon CloudWatch Synthetic canary is created via the ApiCanary construct and is monitored by the CodeDeploy deployment to trigger rollback if the canary begins to alarm.

var cluster iCluster
var image containerImage

service := cdklabscdkecscodedeploy.NewApplicationLoadBalancedCodeDeployedFargateService(stack, jsii.String("Service"), &ApplicationLoadBalancedCodeDeployedFargateServiceProps{
	Cluster: Cluster,
	TaskImageOptions: &ApplicationLoadBalancedTaskImageOptions{
		Image: *Image,
	},
	ApiTestSteps: []apiTestStep{
		&apiTestStep{
			Name: jsii.String("health"),
			Path: jsii.String("/health"),
			JmesPath: jsii.String("status"),
			ExpectedValue: jsii.String("ok"),
		},
	},
})

Local Development

yarn install
yarn build
yarn test

To run an integration test and update the snapshot, run:

yarn integ:ecs-deployment:deploy

To recreate snapshots for integration tests, run:

yarn integ:snapshot-all

Security

See CONTRIBUTING for more information.

License

This project is licensed under the Apache-2.0 License.

Documentation

Overview

CDK Constructs for performing ECS Deployments with CodeDeploy

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ApiCanary_IsConstruct added in v0.0.15

func ApiCanary_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 ApiCanary_IsOwnedResource added in v0.0.15

func ApiCanary_IsOwnedResource(construct constructs.IConstruct) *bool

Returns true if the construct was created by CDK, and false otherwise. Experimental.

func ApiCanary_IsResource added in v0.0.15

func ApiCanary_IsResource(construct constructs.IConstruct) *bool

Check whether the given construct is a Resource. Experimental.

func ApplicationLoadBalancedCodeDeployedFargateService_IsConstruct added in v0.0.15

func ApplicationLoadBalancedCodeDeployedFargateService_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 EcsDeployment_IsConstruct

func EcsDeployment_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 NewApiCanary_Override added in v0.0.15

func NewApiCanary_Override(a ApiCanary, scope constructs.Construct, id *string, props *ApiCanaryProps)

Experimental.

func NewApplicationLoadBalancedCodeDeployedFargateService_Override added in v0.0.15

func NewApplicationLoadBalancedCodeDeployedFargateService_Override(a ApplicationLoadBalancedCodeDeployedFargateService, scope constructs.Construct, id *string, props *ApplicationLoadBalancedCodeDeployedFargateServiceProps)

Constructs a new instance of the ApplicationLoadBalancedCodeDeployedFargateService class. Experimental.

func NewEcsAppSpec_Override

func NewEcsAppSpec_Override(e EcsAppSpec, targetService *TargetService, hooks *AppSpecHooks)

Experimental.

func NewEcsDeployment_Override

func NewEcsDeployment_Override(e EcsDeployment, props *EcsDeploymentProps)

Experimental.

Types

type ApiCanary added in v0.0.15

type ApiCanary interface {
	awssynthetics.Canary
	// Bucket where data from each canary run is stored.
	// Experimental.
	ArtifactsBucket() awss3.IBucket
	// The canary ID.
	// Experimental.
	CanaryId() *string
	// The canary Name.
	// Experimental.
	CanaryName() *string
	// The state of the canary.
	//
	// For example, 'RUNNING', 'STOPPED', 'NOT STARTED', or 'ERROR'.
	// Experimental.
	CanaryState() *string
	// Access the Connections object.
	//
	// Will fail if not a VPC-enabled Canary.
	// Experimental.
	Connections() awsec2.Connections
	// A CloudWatch Alarm that triggers when the duration of the tests exceeds the given threshold over the past 2 periods.
	// Experimental.
	DurationAlarm() awscloudwatch.Alarm
	// Experimental.
	SetDurationAlarm(val awscloudwatch.Alarm)
	// The environment this resource belongs to.
	//
	// For resources that are created and managed by the CDK
	// (generally, those created by creating new class instances like Role, Bucket, etc.),
	// this is always the same as the environment of the stack they belong to;
	// however, for imported resources
	// (those obtained from static methods like fromRoleArn, fromBucketName, etc.),
	// that might be different than the stack they were imported into.
	// Experimental.
	Env() *awscdk.ResourceEnvironment
	// The tree node.
	// Experimental.
	Node() constructs.Node
	// Returns a string-encoded token that resolves to the physical name that should be passed to the CloudFormation resource.
	//
	// This value will resolve to one of the following:
	// - a concrete value (e.g. `"my-awesome-bucket"`)
	// - `undefined`, when a name should be generated by CloudFormation
	// - a concrete name generated automatically during synthesis, in
	//   cross-environment scenarios.
	// Experimental.
	PhysicalName() *string
	// Execution role associated with this Canary.
	// Experimental.
	Role() awsiam.IRole
	// The stack in which this resource is defined.
	// Experimental.
	Stack() awscdk.Stack
	// A CloudWatch Alarm that triggers when the success rate falls below 100% over the past 2 periods.
	// Experimental.
	SuccessAlarm() awscloudwatch.Alarm
	// Experimental.
	SetSuccessAlarm(val awscloudwatch.Alarm)
	// Add a new test step to this canary.
	// Experimental.
	AddTestStep(step *ApiTestStep)
	// Apply the given removal policy to this resource.
	//
	// The Removal Policy controls what happens to this resource when it stops
	// being managed by CloudFormation, either because you've removed it from the
	// CDK application or because you've made a change that requires the resource
	// to be replaced.
	//
	// The resource can be deleted (`RemovalPolicy.DESTROY`), or left in your AWS
	// account for data recovery and cleanup later (`RemovalPolicy.RETAIN`).
	// Experimental.
	ApplyRemovalPolicy(policy awscdk.RemovalPolicy)
	// Experimental.
	GeneratePhysicalName() *string
	// Returns an environment-sensitive token that should be used for the resource's "ARN" attribute (e.g. `bucket.bucketArn`).
	//
	// Normally, this token will resolve to `arnAttr`, but if the resource is
	// referenced across environments, `arnComponents` will be used to synthesize
	// a concrete ARN with the resource's physical name. Make sure to reference
	// `this.physicalName` in `arnComponents`.
	// Experimental.
	GetResourceArnAttribute(arnAttr *string, arnComponents *awscdk.ArnComponents) *string
	// Returns an environment-sensitive token that should be used for the resource's "name" attribute (e.g. `bucket.bucketName`).
	//
	// Normally, this token will resolve to `nameAttr`, but if the resource is
	// referenced across environments, it will be resolved to `this.physicalName`,
	// which will be a concrete name.
	// Experimental.
	GetResourceNameAttribute(nameAttr *string) *string
	// Measure the Duration of a single canary run, in seconds.
	// Default: avg over 5 minutes.
	//
	// Experimental.
	MetricDuration(options *awscloudwatch.MetricOptions) awscloudwatch.Metric
	// Measure the number of failed canary runs over a given time period.
	//
	// Default: sum over 5 minutes.
	// Experimental.
	MetricFailed(options *awscloudwatch.MetricOptions) awscloudwatch.Metric
	// Measure the percentage of successful canary runs.
	// Default: avg over 5 minutes.
	//
	// Experimental.
	MetricSuccessPercent(options *awscloudwatch.MetricOptions) awscloudwatch.Metric
	// Returns a string representation of this construct.
	// Experimental.
	ToString() *string
}

A CloudWatch Synthetic Canary for monitoring APIs. Experimental.

func NewApiCanary added in v0.0.15

func NewApiCanary(scope constructs.Construct, id *string, props *ApiCanaryProps) ApiCanary

Experimental.

type ApiCanaryProps added in v0.0.15

type ApiCanaryProps struct {
	// The base URL to use for tests.
	// Experimental.
	BaseUrl *string `field:"required" json:"baseUrl" yaml:"baseUrl"`
	// The s3 location that stores the data of the canary runs.
	// Default: - A new s3 bucket will be created without a prefix.
	//
	// Experimental.
	ArtifactsBucketLocation *awssynthetics.ArtifactsBucketLocation `field:"optional" json:"artifactsBucketLocation" yaml:"artifactsBucketLocation"`
	// The name of the canary.
	//
	// Be sure to give it a descriptive name that distinguishes it from
	// other canaries in your account.
	//
	// Do not include secrets or proprietary information in your canary name. The canary name
	// makes up part of the canary ARN, which is included in outbound calls over the internet.
	// See: https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/servicelens_canaries_security.html
	//
	// Default: - A unique name will be generated from the construct ID.
	//
	// Experimental.
	CanaryName *string `field:"optional" json:"canaryName" yaml:"canaryName"`
	// The threshold for triggering an alarm on the test duration.
	// Default: - no alarm is created for duration.
	//
	// Experimental.
	DurationAlarmThreshold awscdk.Duration `field:"optional" json:"durationAlarmThreshold" yaml:"durationAlarmThreshold"`
	// How many days should failed runs be retained.
	// Default: Duration.days(31)
	//
	// Experimental.
	FailureRetentionPeriod awscdk.Duration `field:"optional" json:"failureRetentionPeriod" yaml:"failureRetentionPeriod"`
	// Canary execution role.
	//
	// This is the role that will be assumed by the canary upon execution.
	// It controls the permissions that the canary will have. The role must
	// be assumable by the AWS Lambda service principal.
	//
	// If not supplied, a role will be created with all the required permissions.
	// If you provide a Role, you must add the required permissions.
	// See: required permissions: https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-synthetics-canary.html#cfn-synthetics-canary-executionrolearn
	//
	// Default: - A unique role will be generated for this canary.
	// You can add permissions to roles by calling 'addToRolePolicy'.
	//
	// Experimental.
	Role awsiam.IRole `field:"optional" json:"role" yaml:"role"`
	// Specify the schedule for how often the canary runs.
	//
	// For example, if you set `schedule` to `rate(10 minutes)`, then the canary will run every 10 minutes.
	// You can set the schedule with `Schedule.rate(Duration)` (recommended) or you can specify an expression using `Schedule.expression()`.
	// Default: 'rate(5 minutes)'.
	//
	// Experimental.
	Schedule awssynthetics.Schedule `field:"optional" json:"schedule" yaml:"schedule"`
	// The list of security groups to associate with the canary's network interfaces.
	//
	// You must provide `vpc` when using this prop.
	// Default: - If the canary is placed within a VPC and a security group is
	// not specified a dedicated security group will be created for this canary.
	//
	// Experimental.
	SecurityGroups *[]awsec2.ISecurityGroup `field:"optional" json:"securityGroups" yaml:"securityGroups"`
	// Whether or not the canary should start after creation.
	// Default: true.
	//
	// Experimental.
	StartAfterCreation *bool `field:"optional" json:"startAfterCreation" yaml:"startAfterCreation"`
	// The steps to perform in the synthetic test.
	// Experimental.
	Steps *[]*ApiTestStep `field:"optional" json:"steps" yaml:"steps"`
	// How many days should successful runs be retained.
	// Default: Duration.days(31)
	//
	// Experimental.
	SuccessRetentionPeriod awscdk.Duration `field:"optional" json:"successRetentionPeriod" yaml:"successRetentionPeriod"`
	// The number of threads to run concurrently for the synthetic test.
	// Default: - 20.
	//
	// Experimental.
	ThreadCount *float64 `field:"optional" json:"threadCount" yaml:"threadCount"`
	// How long the canary will be in a 'RUNNING' state.
	//
	// For example, if you set `timeToLive` to be 1 hour and `schedule` to be `rate(10 minutes)`,
	// your canary will run at 10 minute intervals for an hour, for a total of 6 times.
	// Default: - no limit.
	//
	// Experimental.
	TimeToLive awscdk.Duration `field:"optional" json:"timeToLive" yaml:"timeToLive"`
	// The VPC where this canary is run.
	//
	// Specify this if the canary needs to access resources in a VPC.
	// Default: - Not in VPC.
	//
	// Experimental.
	Vpc awsec2.IVpc `field:"optional" json:"vpc" yaml:"vpc"`
	// Where to place the network interfaces within the VPC.
	//
	// You must provide `vpc` when using this prop.
	// Default: - the Vpc default strategy if not specified.
	//
	// Experimental.
	VpcSubnets *awsec2.SubnetSelection `field:"optional" json:"vpcSubnets" yaml:"vpcSubnets"`
}

Experimental.

type ApiTestStep added in v0.0.15

type ApiTestStep struct {
	// Name of test.
	// Experimental.
	Name *string `field:"required" json:"name" yaml:"name"`
	// Path of HTTP request, relative to baseUrl.
	// Experimental.
	Path *string `field:"required" json:"path" yaml:"path"`
	// Optional body to include in HTTP request.
	// Default: - no body included.
	//
	// Experimental.
	Body *string `field:"optional" json:"body" yaml:"body"`
	// Expected value to compare against the jmesPath.
	// Default: - undefined.
	//
	// Experimental.
	ExpectedValue interface{} `field:"optional" json:"expectedValue" yaml:"expectedValue"`
	// Optional headers to include in HTTP request.
	// Default: - no headers included.
	//
	// Experimental.
	Headers *map[string]*string `field:"optional" json:"headers" yaml:"headers"`
	// JMESPath to apply against the response from the HTTP request and compare against expected value.
	// Default: - no JMESPath assertion will be performed.
	//
	// Experimental.
	JmesPath *string `field:"optional" json:"jmesPath" yaml:"jmesPath"`
	// Optional method to for HTTP request.
	// Default: - GET.
	//
	// Experimental.
	Method *string `field:"optional" json:"method" yaml:"method"`
}

Experimental.

type AppSpecHooks added in v0.0.155

type AppSpecHooks struct {
	// Lambda or ARN of a lambda to run tasks after the test listener serves traffic to the replacement task set.
	// Experimental.
	AfterAllowTestTraffic interface{} `field:"optional" json:"afterAllowTestTraffic" yaml:"afterAllowTestTraffic"`
	// Lambda or ARN of a lambda to run tasks after the second target group serves traffic to the replacement task set.
	// Experimental.
	AfterAllowTraffic interface{} `field:"optional" json:"afterAllowTraffic" yaml:"afterAllowTraffic"`
	// Lambda or ARN of a lambda to run tasks after the replacement task set is created and one of the target groups is associated with it.
	// Experimental.
	AfterInstall interface{} `field:"optional" json:"afterInstall" yaml:"afterInstall"`
	// Lambda or ARN of a lambda to run tasks after the second target group is associated with the replacement task set, but before traffic is shifted to the replacement task set.
	// Experimental.
	BeforeAllowTraffic interface{} `field:"optional" json:"beforeAllowTraffic" yaml:"beforeAllowTraffic"`
	// Lambda or ARN of a lambda to run tasks before the replacement task set is created.
	// Experimental.
	BeforeInstall interface{} `field:"optional" json:"beforeInstall" yaml:"beforeInstall"`
}

Lifecycle hooks configuration. Experimental.

type ApplicationLoadBalancedCodeDeployedFargateService added in v0.0.15

type ApplicationLoadBalancedCodeDeployedFargateService interface {
	awsecspatterns.ApplicationLoadBalancedFargateService
	// S3 Bucket used for access logs.
	// Experimental.
	AccessLogBucket() awss3.IBucket
	// Experimental.
	SetAccessLogBucket(val awss3.IBucket)
	// API Canary for the service.
	// Experimental.
	ApiCanary() ApiCanary
	// Experimental.
	SetApiCanary(val ApiCanary)
	// CodeDeploy application for this service.
	// Experimental.
	Application() awscodedeploy.EcsApplication
	// Experimental.
	SetApplication(val awscodedeploy.EcsApplication)
	// Determines whether the service will be assigned a public IP address.
	// Experimental.
	AssignPublicIp() *bool
	// Certificate Manager certificate to associate with the load balancer.
	// Experimental.
	Certificate() awscertificatemanager.ICertificate
	// The cluster that hosts the service.
	// Experimental.
	Cluster() awsecs.ICluster
	// CodeDeploy deployment for this service.
	// Experimental.
	Deployment() EcsDeployment
	// Experimental.
	SetDeployment(val EcsDeployment)
	// CodeDeploy deployment group for this service.
	// Experimental.
	DeploymentGroup() awscodedeploy.EcsDeploymentGroup
	// Experimental.
	SetDeploymentGroup(val awscodedeploy.EcsDeploymentGroup)
	// Test target group to use for CodeDeploy deployments.
	// Experimental.
	GreenTargetGroup() awselasticloadbalancingv2.ApplicationTargetGroup
	// Experimental.
	SetGreenTargetGroup(val awselasticloadbalancingv2.ApplicationTargetGroup)
	// Composite alarm for monitoring health of service.
	// Experimental.
	HealthAlarm() awscloudwatch.IAlarm
	// Experimental.
	SetHealthAlarm(val awscloudwatch.IAlarm)
	// 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.
	// Experimental.
	InternalDesiredCount() *float64
	// The listener for the service.
	// Experimental.
	Listener() awselasticloadbalancingv2.ApplicationListener
	// The Application Load Balancer for the service.
	// Experimental.
	LoadBalancer() awselasticloadbalancingv2.ApplicationLoadBalancer
	// The tree node.
	// Experimental.
	Node() constructs.Node
	// The redirect listener for the service if redirectHTTP is enabled.
	// Experimental.
	RedirectListener() awselasticloadbalancingv2.ApplicationListener
	// The Fargate service in this construct.
	// Experimental.
	Service() awsecs.FargateService
	// The target group for the service.
	// Experimental.
	TargetGroup() awselasticloadbalancingv2.ApplicationTargetGroup
	// The Fargate task definition in this construct.
	// Experimental.
	TaskDefinition() awsecs.FargateTaskDefinition
	// Test listener to use for CodeDeploy deployments.
	// Experimental.
	TestListener() awselasticloadbalancingv2.ApplicationListener
	// Experimental.
	SetTestListener(val awselasticloadbalancingv2.ApplicationListener)
	// Adds service as a target of the target group.
	// Experimental.
	AddServiceAsTarget(service awsecs.BaseService)
	// Experimental.
	CreateAWSLogDriver(prefix *string) awsecs.AwsLogDriver
	// Returns the default cluster.
	// Experimental.
	GetDefaultCluster(scope constructs.Construct, vpc awsec2.IVpc) awsecs.Cluster
	// Returns a string representation of this construct.
	// Experimental.
	ToString() *string
}

A Fargate service running on an ECS cluster fronted by an application load balancer and deployed by CodeDeploy. Experimental.

func NewApplicationLoadBalancedCodeDeployedFargateService added in v0.0.15

func NewApplicationLoadBalancedCodeDeployedFargateService(scope constructs.Construct, id *string, props *ApplicationLoadBalancedCodeDeployedFargateServiceProps) ApplicationLoadBalancedCodeDeployedFargateService

Constructs a new instance of the ApplicationLoadBalancedCodeDeployedFargateService class. Experimental.

type ApplicationLoadBalancedCodeDeployedFargateServiceProps added in v0.0.15

type ApplicationLoadBalancedCodeDeployedFargateServiceProps struct {
	// A list of Capacity Provider strategies used to place a service.
	// Default: - undefined.
	//
	// Experimental.
	CapacityProviderStrategies *[]*awsecs.CapacityProviderStrategy `field:"optional" json:"capacityProviderStrategies" yaml:"capacityProviderStrategies"`
	// Certificate Manager certificate to associate with the load balancer.
	//
	// Setting this option will set the load balancer protocol to HTTPS.
	// Default: - No certificate associated with the load balancer, if using
	// the HTTP protocol. For HTTPS, a DNS-validated certificate will be
	// created for the load balancer's specified domain name if a domain name
	// and domain zone are specified.
	//
	// Experimental.
	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.
	// Default: - disabled.
	//
	// Experimental.
	CircuitBreaker *awsecs.DeploymentCircuitBreaker `field:"optional" json:"circuitBreaker" yaml:"circuitBreaker"`
	// The options for configuring an Amazon ECS service to use service discovery.
	// Default: - AWS Cloud Map service discovery is not enabled.
	//
	// Experimental.
	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.
	// Default: - create a new cluster; if both cluster and vpc are omitted, a new VPC will be created for you.
	//
	// Experimental.
	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)
	// Default: - Rolling update (ECS).
	//
	// Experimental.
	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.
	// Default: - If the feature flag, ECS_REMOVE_DEFAULT_DESIRED_COUNT is false, the default is 1;
	// if true, the default is 1 for all new services and uses the existing services desired count
	// when updating an existing service.
	//
	// Experimental.
	DesiredCount *float64 `field:"optional" json:"desiredCount" yaml:"desiredCount"`
	// The domain name for the service, e.g. "api.example.com.".
	// Default: - No domain name.
	//
	// Experimental.
	DomainName *string `field:"optional" json:"domainName" yaml:"domainName"`
	// The Route53 hosted zone for the domain, e.g. "example.com.".
	// Default: - No Route53 hosted domain zone.
	//
	// Experimental.
	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)
	// Default: false.
	//
	// Experimental.
	EnableECSManagedTags *bool `field:"optional" json:"enableECSManagedTags" yaml:"enableECSManagedTags"`
	// Whether ECS Exec should be enabled.
	// Default: - false.
	//
	// Experimental.
	EnableExecuteCommand *bool `field:"optional" json:"enableExecuteCommand" yaml:"enableExecuteCommand"`
	// 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.
	// Default: - defaults to 60 seconds if at least one load balancer is in-use and it is not already set.
	//
	// Experimental.
	HealthCheckGracePeriod awscdk.Duration `field:"optional" json:"healthCheckGracePeriod" yaml:"healthCheckGracePeriod"`
	// The load balancer idle timeout, in seconds.
	//
	// Can be between 1 and 4000 seconds.
	// Default: - CloudFormation sets idle timeout to 60 seconds.
	//
	// Experimental.
	IdleTimeout awscdk.Duration `field:"optional" json:"idleTimeout" yaml:"idleTimeout"`
	// Listener port of the application load balancer that will serve traffic to the service.
	// Default: - The default listener 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.
	//
	// Experimental.
	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].
	// Default: - a new load balancer will be created.
	//
	// Experimental.
	LoadBalancer awselasticloadbalancingv2.IApplicationLoadBalancer `field:"optional" json:"loadBalancer" yaml:"loadBalancer"`
	// Name of the load balancer.
	// Default: - Automatically generated name.
	//
	// Experimental.
	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.
	// Default: - 100 if daemon, otherwise 200.
	//
	// Experimental.
	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.
	// Default: - 0 if daemon, otherwise 50.
	//
	// Experimental.
	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.
	// Default: true -- The security group allows ingress from all IP addresses.
	//
	// Experimental.
	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.
	// Default: - none.
	//
	// Experimental.
	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).  If HTTPS, either a certificate or domain
	// name and domain zone must also be specified.
	// Default: HTTP. If a certificate is specified, the protocol will be
	// set by default to HTTPS.
	//
	// Experimental.
	Protocol awselasticloadbalancingv2.ApplicationProtocol `field:"optional" json:"protocol" yaml:"protocol"`
	// The protocol version to use.
	// Default: ApplicationProtocolVersion.HTTP1
	//
	// Experimental.
	ProtocolVersion awselasticloadbalancingv2.ApplicationProtocolVersion `field:"optional" json:"protocolVersion" yaml:"protocolVersion"`
	// Determines whether the Load Balancer will be internet-facing.
	// Default: true.
	//
	// Experimental.
	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.
	// Default: ApplicationLoadBalancedServiceRecordType.ALIAS
	//
	// Experimental.
	RecordType awsecspatterns.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.
	// Default: false.
	//
	// Experimental.
	RedirectHTTP *bool `field:"optional" json:"redirectHTTP" yaml:"redirectHTTP"`
	// The name of the service.
	// Default: - CloudFormation-generated name.
	//
	// Experimental.
	ServiceName *string `field:"optional" json:"serviceName" yaml:"serviceName"`
	// The security policy that defines which ciphers and protocols are supported by the ALB Listener.
	// Default: - The recommended elastic load balancing security policy.
	//
	// Experimental.
	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).
	// Default: HTTP.
	//
	// Experimental.
	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.
	// Default: none.
	//
	// Experimental.
	TaskImageOptions *awsecspatterns.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.
	// Default: - uses the VPC defined in the cluster or creates a new VPC.
	//
	// Experimental.
	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
	//
	// 8192 (8 vCPU) - Available memory values: Between 16GB and 60GB in 4GB increments
	//
	// 16384 (16 vCPU) - Available memory values: Between 32GB and 120GB in 8GB increments
	//
	// This default is set in the underlying FargateTaskDefinition construct.
	// Default: 256.
	//
	// Experimental.
	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)
	//
	// Between 16384 (16 GB) and 61440 (60 GB) in increments of 4096 (4 GB) - Available cpu values: 8192 (8 vCPU)
	//
	// Between 32768 (32 GB) and 122880 (120 GB) in increments of 8192 (8 GB) - Available cpu values: 16384 (16 vCPU)
	//
	// This default is set in the underlying FargateTaskDefinition construct.
	// Default: 512.
	//
	// Experimental.
	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.
	// Default: Latest.
	//
	// Experimental.
	PlatformVersion awsecs.FargatePlatformVersion `field:"optional" json:"platformVersion" yaml:"platformVersion"`
	// The runtime platform of the task definition.
	// Default: - If the property is undefined, `operatingSystemFamily` is LINUX and `cpuArchitecture` is X86_64.
	//
	// Experimental.
	RuntimePlatform *awsecs.RuntimePlatform `field:"optional" json:"runtimePlatform" yaml:"runtimePlatform"`
	// The task definition to use for tasks in the service. TaskDefinition or TaskImageOptions must be specified, but not both.
	//
	// [disable-awslint:ref-via-interface].
	// Default: - none.
	//
	// Experimental.
	TaskDefinition awsecs.FargateTaskDefinition `field:"optional" json:"taskDefinition" yaml:"taskDefinition"`
	// Determines whether the service will be assigned a public IP address.
	// Default: false.
	//
	// Experimental.
	AssignPublicIp *bool `field:"optional" json:"assignPublicIp" yaml:"assignPublicIp"`
	// The security groups to associate with the service.
	//
	// If you do not specify a security group, a new security group is created.
	// Default: - A new security group is created.
	//
	// Experimental.
	SecurityGroups *[]awsec2.ISecurityGroup `field:"optional" json:"securityGroups" yaml:"securityGroups"`
	// The subnets to associate with the service.
	// Default: - Public subnets if `assignPublicIp` is set, otherwise the first available one of Private, Isolated, Public, in that order.
	//
	// Experimental.
	TaskSubnets *awsec2.SubnetSelection `field:"optional" json:"taskSubnets" yaml:"taskSubnets"`
	// The bucket to use for access logs from the Application Load Balancer.
	// Default: - a new S3 bucket will be created.
	//
	// Experimental.
	AccessLogBucket awss3.IBucket `field:"optional" json:"accessLogBucket" yaml:"accessLogBucket"`
	// The prefix to use for access logs from the Application Load Balancer.
	// Default: - none.
	//
	// Experimental.
	AccessLogPrefix *string `field:"optional" json:"accessLogPrefix" yaml:"accessLogPrefix"`
	// The frequency for running the api canaries.
	// Default: - 5 minutes.
	//
	// Experimental.
	ApiCanarySchedule awscdk.Duration `field:"optional" json:"apiCanarySchedule" yaml:"apiCanarySchedule"`
	// The number of threads to run concurrently for the synthetic test.
	// Default: - 20.
	//
	// Experimental.
	ApiCanaryThreadCount *float64 `field:"optional" json:"apiCanaryThreadCount" yaml:"apiCanaryThreadCount"`
	// The threshold for how long a api canary can take to run.
	// Default: - no alarm is created for test duration.
	//
	// Experimental.
	ApiCanaryTimeout awscdk.Duration `field:"optional" json:"apiCanaryTimeout" yaml:"apiCanaryTimeout"`
	// The steps to run in the canary.
	// Default: - no synthetic test will be created.
	//
	// Experimental.
	ApiTestSteps *[]*ApiTestStep `field:"optional" json:"apiTestSteps" yaml:"apiTestSteps"`
	// The deployment configuration to use for the deployment group.
	// Default: - EcsDeploymentConfig.ALL_AT_ONCE
	//
	// Experimental.
	DeploymentConfig awscodedeploy.IEcsDeploymentConfig `field:"optional" json:"deploymentConfig" yaml:"deploymentConfig"`
	// The timeout for a CodeDeploy deployment.
	// Default: - 60 minutes.
	//
	// Experimental.
	DeploymentTimeout awscdk.Duration `field:"optional" json:"deploymentTimeout" yaml:"deploymentTimeout"`
	// The amount of time for ELB to wait before changing the state of a deregistering target from 'draining' to 'unused'.
	// Default: - 300 seconds.
	//
	// Experimental.
	DeregistrationDelay awscdk.Duration `field:"optional" json:"deregistrationDelay" yaml:"deregistrationDelay"`
	// The healthcheck to configure on the Application Load Balancer target groups.
	// Default: - no health check is configured.
	//
	// Experimental.
	HealthCheck *awselasticloadbalancingv2.HealthCheck `field:"optional" json:"healthCheck" yaml:"healthCheck"`
	// Optional lifecycle hooks.
	// Default: - no lifecycle hooks.
	//
	// Experimental.
	Hooks *AppSpecHooks `field:"optional" json:"hooks" yaml:"hooks"`
	// The threshold for response time alarm.
	// Default: - no alarm will be created.
	//
	// Experimental.
	ResponseTimeAlarmThreshold awscdk.Duration `field:"optional" json:"responseTimeAlarmThreshold" yaml:"responseTimeAlarmThreshold"`
	// The time to wait before terminating the original (blue) task set.
	// Default: - 10 minutes.
	//
	// Experimental.
	TerminationWaitTime awscdk.Duration `field:"optional" json:"terminationWaitTime" yaml:"terminationWaitTime"`
	// The port to use for test traffic on the listener.
	// Default: - listenerPort + 1.
	//
	// Experimental.
	TestPort *float64 `field:"optional" json:"testPort" yaml:"testPort"`
}

The properties for the ApplicationLoadBalancedCodeDeployedFargateService service. Experimental.

type AwsvpcConfiguration

type AwsvpcConfiguration struct {
	// Assign a public IP address to the task.
	// Experimental.
	AssignPublicIp *bool `field:"required" json:"assignPublicIp" yaml:"assignPublicIp"`
	// The Security Groups to use for the task.
	// Experimental.
	SecurityGroups *[]awsec2.ISecurityGroup `field:"required" json:"securityGroups" yaml:"securityGroups"`
	// The VPC to use for the task.
	// Experimental.
	Vpc awsec2.IVpc `field:"required" json:"vpc" yaml:"vpc"`
	// The Subnets to use for the task.
	// Experimental.
	VpcSubnets *awsec2.SubnetSelection `field:"required" json:"vpcSubnets" yaml:"vpcSubnets"`
}

Network configuration for ECS services that have a network type of `awsvpc`. Experimental.

type EcsAppSpec

type EcsAppSpec interface {
	// Render JSON string for this AppSpec to be used.
	//
	// Returns: string representation of this AppSpec.
	// Experimental.
	ToString() *string
}

Represents an AppSpec to be used for ECS services.

see: https://docs.aws.amazon.com/codedeploy/latest/userguide/reference-appspec-file-structure-resources.html#reference-appspec-file-structure-resources-ecs Experimental.

func NewEcsAppSpec

func NewEcsAppSpec(targetService *TargetService, hooks *AppSpecHooks) EcsAppSpec

Experimental.

type EcsDeployment

type EcsDeployment interface {
	constructs.Construct
	// The id of the deployment that was created.
	// Experimental.
	DeploymentId() *string
	// Experimental.
	SetDeploymentId(val *string)
	// The tree node.
	// Experimental.
	Node() constructs.Node
	// Returns a string representation of this construct.
	// Experimental.
	ToString() *string
}

A CodeDeploy Deployment for a Amazon ECS service DeploymentGroup.

An EcsDeploymentGroup must only have 1 EcsDeployment. This limit is enforced by removing the scope and id from the constructor. The scope will always be set to the EcsDeploymentGroup and the id will always be set to the string 'Deployment' to force an error if mulitiple EcsDeployment constructs are created for a single EcsDeploymentGroup. Experimental.

func NewEcsDeployment

func NewEcsDeployment(props *EcsDeploymentProps) EcsDeployment

Experimental.

type EcsDeploymentProps

type EcsDeploymentProps struct {
	// The deployment group to target for this deployment.
	// Experimental.
	DeploymentGroup awscodedeploy.IEcsDeploymentGroup `field:"required" json:"deploymentGroup" yaml:"deploymentGroup"`
	// The ECS service to target for the deployment.
	//
	// see: https://docs.aws.amazon.com/codedeploy/latest/userguide/reference-appspec-file-structure-resources.html#reference-appspec-file-structure-resources-ecs
	// Experimental.
	TargetService *TargetService `field:"required" json:"targetService" yaml:"targetService"`
	// The configuration for rollback in the event that a deployment fails.
	// Default: : no automatic rollback triggered.
	//
	// Experimental.
	AutoRollback *awscodedeploy.AutoRollbackConfig `field:"optional" json:"autoRollback" yaml:"autoRollback"`
	// The description for the deployment.
	// Default: no description.
	//
	// Experimental.
	Description *string `field:"optional" json:"description" yaml:"description"`
	// Optional lifecycle hooks.
	// Default: - no lifecycle hooks.
	//
	// Experimental.
	Hooks *AppSpecHooks `field:"optional" json:"hooks" yaml:"hooks"`
	// The timeout for the deployment.
	//
	// If the timeout is reached, it will trigger a rollback of the stack.
	// Default: 30 minutes.
	//
	// Experimental.
	Timeout awscdk.Duration `field:"optional" json:"timeout" yaml:"timeout"`
}

Construction properties of EcsDeployment. Experimental.

type TargetService

type TargetService struct {
	// The name of the Amazon ECS container that contains your Amazon ECS application.
	//
	// It must be a container specified in your Amazon ECS task definition.
	// Experimental.
	ContainerName *string `field:"required" json:"containerName" yaml:"containerName"`
	// The port on the container where traffic will be routed to.
	// Experimental.
	ContainerPort *float64 `field:"required" json:"containerPort" yaml:"containerPort"`
	// The TaskDefintion to deploy to the target services.
	// Experimental.
	TaskDefinition awsecs.ITaskDefinition `field:"required" json:"taskDefinition" yaml:"taskDefinition"`
	// Network configuration for ECS services that have a network type of `awsvpc`.
	// Default: reuse current network settings for ECS service.
	//
	// Experimental.
	AwsvpcConfiguration *AwsvpcConfiguration `field:"optional" json:"awsvpcConfiguration" yaml:"awsvpcConfiguration"`
	// A list of Amazon ECS capacity providers to use for the deployment.
	// Default: reuse current capcity provider strategy for ECS service.
	//
	// Experimental.
	CapacityProviderStrategy *[]*awsecs.CapacityProviderStrategy `field:"optional" json:"capacityProviderStrategy" yaml:"capacityProviderStrategy"`
	// The platform version of the Fargate tasks in the deployed Amazon ECS service.
	//
	// see: https://docs.aws.amazon.com/AmazonECS/latest/developerguide/platform_versions.html
	// Default: LATEST.
	//
	// Experimental.
	PlatformVersion awsecs.FargatePlatformVersion `field:"optional" json:"platformVersion" yaml:"platformVersion"`
}

Describe the target for CodeDeploy to use when creating a deployment for an ecs.EcsDeploymentGroup. Experimental.

Directories

Path Synopsis
Package jsii contains the functionaility needed for jsii packages to initialize their dependencies and themselves.
Package jsii contains the functionaility needed for jsii packages to initialize their dependencies and themselves.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL