forked from remind101/stacker_blueprints
-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create task blueprint, subclass for apps/services (#30)
* Create task blueprint, subclass for apps/services * Add PlacementConstraints * Remove some naming to see if this works better * Add tests * Allow setting of NetworkMode * Make fargate task type * Handle extra stuff for Fargate Tasks * Fargate tasks require cpu/memory
- Loading branch information
1 parent
078152e
commit 1f3b617
Showing
9 changed files
with
881 additions
and
177 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
150 changes: 150 additions & 0 deletions
150
tests/fixtures/blueprints/ecs__base_ecs_app_deployment_config.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,150 @@ | ||
{ | ||
"Outputs": { | ||
"RoleArn": { | ||
"Value": { | ||
"Fn::GetAtt": [ | ||
"Role", | ||
"Arn" | ||
] | ||
} | ||
}, | ||
"RoleId": { | ||
"Value": { | ||
"Fn::GetAtt": [ | ||
"Role", | ||
"RoleId" | ||
] | ||
} | ||
}, | ||
"RoleName": { | ||
"Value": { | ||
"Ref": "Role" | ||
} | ||
}, | ||
"ServiceArn": { | ||
"Value": { | ||
"Ref": "Service" | ||
} | ||
}, | ||
"ServiceName": { | ||
"Value": { | ||
"Fn::GetAtt": [ | ||
"Service", | ||
"Name" | ||
] | ||
} | ||
}, | ||
"TaskDefinitionArn": { | ||
"Value": { | ||
"Ref": "TaskDefinition" | ||
} | ||
} | ||
}, | ||
"Resources": { | ||
"Role": { | ||
"Properties": { | ||
"AssumeRolePolicyDocument": { | ||
"Statement": [ | ||
{ | ||
"Action": [ | ||
"sts:AssumeRole" | ||
], | ||
"Effect": "Allow", | ||
"Principal": { | ||
"Service": [ | ||
"ecs-tasks.amazonaws.com" | ||
] | ||
} | ||
} | ||
], | ||
"Version": "2012-10-17" | ||
}, | ||
"Path": "/" | ||
}, | ||
"Type": "AWS::IAM::Role" | ||
}, | ||
"Service": { | ||
"Properties": { | ||
"Cluster": "mycluster", | ||
"DeploymentConfiguration": { | ||
"MaximumPercent": 200, | ||
"MinimumHealthyPercent": 50 | ||
}, | ||
"DesiredCount": 3, | ||
"HealthCheckGracePeriodSeconds": { | ||
"Ref": "AWS::NoValue" | ||
}, | ||
"LaunchType": "EC2", | ||
"LoadBalancers": { | ||
"Ref": "AWS::NoValue" | ||
}, | ||
"NetworkConfiguration": { | ||
"Ref": "AWS::NoValue" | ||
}, | ||
"PlacementConstraints": { | ||
"Ref": "AWS::NoValue" | ||
}, | ||
"TaskDefinition": { | ||
"Ref": "TaskDefinition" | ||
} | ||
}, | ||
"Type": "AWS::ECS::Service" | ||
}, | ||
"TaskDefinition": { | ||
"Properties": { | ||
"ContainerDefinitions": [ | ||
{ | ||
"Command": [ | ||
"/bin/run", | ||
"--args 1" | ||
], | ||
"Cpu": 1024, | ||
"Environment": [ | ||
{ | ||
"Name": "DATABASE_URL", | ||
"Value": "sql://fake_db/fake_db" | ||
}, | ||
{ | ||
"Name": "DEBUG", | ||
"Value": "false" | ||
} | ||
], | ||
"Essential": "true", | ||
"Image": "fake_repo/image:12345", | ||
"LogConfiguration": { | ||
"LogDriver": "awslogs", | ||
"Options": { | ||
"awslogs-group": "myapp", | ||
"awslogs-region": { | ||
"Ref": "AWS::Region" | ||
}, | ||
"awslogs-stream-prefix": "mytask" | ||
} | ||
}, | ||
"Memory": 2048, | ||
"Name": "mytask", | ||
"PortMappings": { | ||
"Ref": "AWS::NoValue" | ||
} | ||
} | ||
], | ||
"Cpu": { | ||
"Ref": "AWS::NoValue" | ||
}, | ||
"Memory": { | ||
"Ref": "AWS::NoValue" | ||
}, | ||
"NetworkMode": { | ||
"Ref": "AWS::NoValue" | ||
}, | ||
"TaskRoleArn": { | ||
"Fn::GetAtt": [ | ||
"Role", | ||
"Arn" | ||
] | ||
} | ||
}, | ||
"Type": "AWS::ECS::TaskDefinition" | ||
} | ||
} | ||
} |
158 changes: 158 additions & 0 deletions
158
tests/fixtures/blueprints/ecs__base_ecs_app_load_balancers.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,158 @@ | ||
{ | ||
"Outputs": { | ||
"RoleArn": { | ||
"Value": { | ||
"Fn::GetAtt": [ | ||
"Role", | ||
"Arn" | ||
] | ||
} | ||
}, | ||
"RoleId": { | ||
"Value": { | ||
"Fn::GetAtt": [ | ||
"Role", | ||
"RoleId" | ||
] | ||
} | ||
}, | ||
"RoleName": { | ||
"Value": { | ||
"Ref": "Role" | ||
} | ||
}, | ||
"ServiceArn": { | ||
"Value": { | ||
"Ref": "Service" | ||
} | ||
}, | ||
"ServiceName": { | ||
"Value": { | ||
"Fn::GetAtt": [ | ||
"Service", | ||
"Name" | ||
] | ||
} | ||
}, | ||
"TaskDefinitionArn": { | ||
"Value": { | ||
"Ref": "TaskDefinition" | ||
} | ||
} | ||
}, | ||
"Resources": { | ||
"Role": { | ||
"Properties": { | ||
"AssumeRolePolicyDocument": { | ||
"Statement": [ | ||
{ | ||
"Action": [ | ||
"sts:AssumeRole" | ||
], | ||
"Effect": "Allow", | ||
"Principal": { | ||
"Service": [ | ||
"ecs-tasks.amazonaws.com" | ||
] | ||
} | ||
} | ||
], | ||
"Version": "2012-10-17" | ||
}, | ||
"Path": "/" | ||
}, | ||
"Type": "AWS::IAM::Role" | ||
}, | ||
"Service": { | ||
"Properties": { | ||
"Cluster": "mycluster", | ||
"DeploymentConfiguration": { | ||
"Ref": "AWS::NoValue" | ||
}, | ||
"DesiredCount": 3, | ||
"HealthCheckGracePeriodSeconds": 300, | ||
"LaunchType": "EC2", | ||
"LoadBalancers": [ | ||
{ | ||
"ContainerName": "mytask", | ||
"ContainerPort": 8000, | ||
"TargetGroupArn": "arn:lb-1" | ||
}, | ||
{ | ||
"ContainerName": "mytask", | ||
"ContainerPort": 8000, | ||
"TargetGroupArn": "arn:lb-2" | ||
} | ||
], | ||
"NetworkConfiguration": { | ||
"Ref": "AWS::NoValue" | ||
}, | ||
"PlacementConstraints": { | ||
"Ref": "AWS::NoValue" | ||
}, | ||
"TaskDefinition": { | ||
"Ref": "TaskDefinition" | ||
} | ||
}, | ||
"Type": "AWS::ECS::Service" | ||
}, | ||
"TaskDefinition": { | ||
"Properties": { | ||
"ContainerDefinitions": [ | ||
{ | ||
"Command": [ | ||
"/bin/run", | ||
"--args 1" | ||
], | ||
"Cpu": 1024, | ||
"Environment": [ | ||
{ | ||
"Name": "DATABASE_URL", | ||
"Value": "sql://fake_db/fake_db" | ||
}, | ||
{ | ||
"Name": "DEBUG", | ||
"Value": "false" | ||
} | ||
], | ||
"Essential": "true", | ||
"Image": "fake_repo/image:12345", | ||
"LogConfiguration": { | ||
"LogDriver": "awslogs", | ||
"Options": { | ||
"awslogs-group": "myapp", | ||
"awslogs-region": { | ||
"Ref": "AWS::Region" | ||
}, | ||
"awslogs-stream-prefix": "mytask" | ||
} | ||
}, | ||
"Memory": 2048, | ||
"Name": "mytask", | ||
"PortMappings": [ | ||
{ | ||
"ContainerPort": 8000 | ||
} | ||
] | ||
} | ||
], | ||
"Cpu": { | ||
"Ref": "AWS::NoValue" | ||
}, | ||
"Memory": { | ||
"Ref": "AWS::NoValue" | ||
}, | ||
"NetworkMode": { | ||
"Ref": "AWS::NoValue" | ||
}, | ||
"TaskRoleArn": { | ||
"Fn::GetAtt": [ | ||
"Role", | ||
"Arn" | ||
] | ||
} | ||
}, | ||
"Type": "AWS::ECS::TaskDefinition" | ||
} | ||
} | ||
} |
Oops, something went wrong.