Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for ECS Service Circuit Breaker and Execute Command #676

Merged
merged 3 commits into from Jun 16, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion CHANGELOG.md
Expand Up @@ -3,7 +3,7 @@ CHANGELOG

## HEAD (Unreleased)
* Add support for Billing CloudWatch metrics and alarms

* Add support for ECS Service Circuit Breaker and Execute Command

## 0.30.0 (2021-04-19)

Expand Down
12 changes: 11 additions & 1 deletion nodejs/awsx/ecs/capacityProviderService.ts
Expand Up @@ -98,7 +98,12 @@ export interface CapacityProviderServiceArgs {
capacityProviderStrategies?: aws.ecs.ServiceArgs["capacityProviderStrategies"];

/**
* onfiguration block containing deployment controller configuration.
* Configuration block for deployment circuit breaker.
*/
deploymentCircuitBreaker?: aws.ecs.ServiceArgs["deploymentCircuitBreaker"];

/**
* Configuration block containing deployment controller configuration.
*/
deploymentController?: aws.ecs.ServiceArgs["deploymentController"];

Expand Down Expand Up @@ -126,6 +131,11 @@ export interface CapacityProviderServiceArgs {
*/
enableEcsManagedTags?: pulumi.Input<boolean>;

/**
* Specifies whether to enable Amazon ECS Exec for the tasks within the service.
*/
enableExecuteCommand?: pulumi.Input<boolean>;

/**
* Enable to force a new task deployment of the service. This can be used to update tasks to use a newer
* Docker image with same image/tag combination (e.g. myimage:latest), roll Fargate tasks onto a newer platform
Expand Down
12 changes: 11 additions & 1 deletion nodejs/awsx/ecs/ec2Service.ts
Expand Up @@ -214,7 +214,12 @@ export interface EC2ServiceArgs {
// Properties from ecs.ServiceArgs

/**
* onfiguration block containing deployment controller configuration.
* Configuration block for deployment circuit breaker.
*/
deploymentCircuitBreaker?: aws.ecs.ServiceArgs["deploymentCircuitBreaker"];

/**
* Configuration block containing deployment controller configuration.
*/
deploymentController?: aws.ecs.ServiceArgs["deploymentController"];

Expand Down Expand Up @@ -242,6 +247,11 @@ export interface EC2ServiceArgs {
*/
enableEcsManagedTags?: pulumi.Input<boolean>;

/**
* Specifies whether to enable Amazon ECS Exec for the tasks within the service.
*/
enableExecuteCommand?: pulumi.Input<boolean>;

/**
* Enable to force a new task deployment of the service. This can be used to update tasks to use a newer
* Docker image with same image/tag combination (e.g. myimage:latest) or immediately deploy
Expand Down
30 changes: 20 additions & 10 deletions nodejs/awsx/ecs/fargateService.ts
Expand Up @@ -54,7 +54,7 @@ export class FargateTaskDefinition extends ecs.TaskDefinition {
* Creates a service with this as its task definition.
*/
public createService(
name: string, args: ecs.FargateServiceArgs, opts: pulumi.ComponentResourceOptions = {}) {
name: string, args: ecs.FargateServiceArgs, opts: pulumi.ComponentResourceOptions = {}) {
if (args.taskDefinition) {
throw new Error("[args.taskDefinition] should not be provided.");
}
Expand All @@ -75,30 +75,30 @@ export class FargateTaskDefinition extends ecs.TaskDefinition {
* needed by the containers and we'll return the cheapest fargate config that supplies at
* least that much memory/vcpu.
*/
function * getAllFargateConfigs() {
function* getAllFargateConfigs() {
// from https://docs.aws.amazon.com/AmazonECS/latest/developerguide/task-cpu-memory-error.html
// Supported task CPU and memory values for Fargate tasks are as follows.

// CPU value Memory value (MiB)

// .25 vCPU 0.5GB, 1GB, 2GB
yield * makeFargateConfigs(.25, [.5, 1, 2]);
yield* makeFargateConfigs(.25, [.5, 1, 2]);

// .5 vCPU 1GB, 2GB, 3GB, 4GBs
yield * makeFargateConfigs(.5, makeMemoryConfigs(1, 4));
yield* makeFargateConfigs(.5, makeMemoryConfigs(1, 4));

// 1 vCPU 2GB, 3GB, 4GB, 5GB, 6GB, 7GB, 8GB
yield * makeFargateConfigs(1, makeMemoryConfigs(2, 8));
yield* makeFargateConfigs(1, makeMemoryConfigs(2, 8));

// 2 vCPU Between 4GB and 16GB in increments of 1GB
yield * makeFargateConfigs(2, makeMemoryConfigs(4, 16));
yield* makeFargateConfigs(2, makeMemoryConfigs(4, 16));

// 4 vCPU Between 8GB and 30GB in increments of 1GB
yield * makeFargateConfigs(4, makeMemoryConfigs(8, 30));
yield* makeFargateConfigs(4, makeMemoryConfigs(8, 30));

return;

function * makeMemoryConfigs(low: number, high: number) {
function* makeMemoryConfigs(low: number, high: number) {
if (low < 1) {
throw new Error(`Invalid low: ${low}`);
}
Expand All @@ -111,7 +111,7 @@ function * getAllFargateConfigs() {
}
}

function * makeFargateConfigs(vcpu: number, memory: Iterable<number>) {
function* makeFargateConfigs(vcpu: number, memory: Iterable<number>) {
if (vcpu < .25 || vcpu > 4) {
throw new Error(`Invalid vcpu: ${vcpu}`);
}
Expand Down Expand Up @@ -353,7 +353,12 @@ export interface FargateServiceArgs {
// Properties from ecs.ServiceArgs

/**
* onfiguration block containing deployment controller configuration.
* Configuration block for deployment circuit breaker.
*/
deploymentCircuitBreaker?: aws.ecs.ServiceArgs["deploymentCircuitBreaker"];

/**
* Configuration block containing deployment controller configuration.
*/
deploymentController?: aws.ecs.ServiceArgs["deploymentController"];

Expand Down Expand Up @@ -381,6 +386,11 @@ export interface FargateServiceArgs {
*/
enableEcsManagedTags?: pulumi.Input<boolean>;

/**
* Specifies whether to enable Amazon ECS Exec for the tasks within the service.
*/
enableExecuteCommand?: pulumi.Input<boolean>;

/**
* Enable to force a new task deployment of the service. This can be used to update tasks to use a newer
* Docker image with same image/tag combination (e.g. myimage:latest), roll Fargate tasks onto a newer platform
Expand Down
16 changes: 13 additions & 3 deletions nodejs/awsx/ecs/service.ts
Expand Up @@ -56,8 +56,8 @@ export abstract class Service extends pulumi.ComponentResource {
desiredCount: utils.ifUndefined(args.desiredCount, 1),
waitForSteadyState: utils.ifUndefined(args.waitForSteadyState, true),
}, pulumi.mergeOptions(opts, {
parent: this,
dependsOn: this.cluster.autoScalingGroups.map(g => g.stack),
parent: this,
dependsOn: this.cluster.autoScalingGroups.map(g => g.stack),
}));

this.taskDefinition = args.taskDefinition;
Expand Down Expand Up @@ -176,7 +176,12 @@ export interface ServiceArgs {
capacityProviderStrategies?: aws.ecs.ServiceArgs["capacityProviderStrategies"];

/**
* onfiguration block containing deployment controller configuration.
* Configuration block for deployment circuit breaker.
*/
deploymentCircuitBreaker?: aws.ecs.ServiceArgs["deploymentCircuitBreaker"];

/**
* Configuration block containing deployment controller configuration.
*/
deploymentController?: aws.ecs.ServiceArgs["deploymentController"];

Expand Down Expand Up @@ -204,6 +209,11 @@ export interface ServiceArgs {
*/
enableEcsManagedTags?: pulumi.Input<boolean>;

/**
* Specifies whether to enable Amazon ECS Exec for the tasks within the service.
*/
enableExecuteCommand?: pulumi.Input<boolean>;

/**
* Enable to force a new task deployment of the service. This can be used to update tasks
* to use a newer Docker image with same image/tag combination (e.g. `myimage:latest`), roll
Expand Down
2 changes: 1 addition & 1 deletion nodejs/awsx/package.json
Expand Up @@ -19,7 +19,7 @@
"mime": "^2.0.0"
},
"peerDependencies": {
"@pulumi/aws": "^4.0.0",
"@pulumi/aws": "^4.6.0",
"@pulumi/pulumi": "^3.0.0"
},
"devDependencies": {
Expand Down