Skip to content

Commit

Permalink
davidchristiansen/LoadBalancedFargateService-ContainerNameAndRoleOver…
Browse files Browse the repository at this point in the history
…rides

Implemenation of execution tests, task role and
container name overrides + tests
  • Loading branch information
DavidChristiansen committed Jun 5, 2019
1 parent e3df21a commit 8071164
Show file tree
Hide file tree
Showing 4 changed files with 854 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import ecs = require('@aws-cdk/aws-ecs');
import iam = require('@aws-cdk/aws-iam');
import { AliasRecord, IHostedZone } from '@aws-cdk/aws-route53';
import targets = require('@aws-cdk/aws-route53-targets');
import cdk = require('@aws-cdk/cdk');
Expand Down Expand Up @@ -72,6 +73,27 @@ export interface LoadBalancedFargateServiceProps extends LoadBalancedServiceBase
* @default true
*/
readonly createLogs?: boolean;

/**
* Override for the Fargate Task Definition execution role
*
* @default - No value
*/
readonly executionRole?: iam.Role;

/**
* Override for the Fargate Task Definition task role
*
* @default - No value
*/
readonly taskRole?: iam.Role;

/**
* Override value for the container name
*
* @default - No value
*/
readonly containerName?: string;
}

/**
Expand All @@ -89,12 +111,16 @@ export class LoadBalancedFargateService extends LoadBalancedServiceBase {

const taskDefinition = new ecs.FargateTaskDefinition(this, 'TaskDef', {
memoryMiB: props.memoryMiB,
cpu: props.cpu
cpu: props.cpu,
executionRole: props.executionRole !== undefined ? props.executionRole : undefined,
taskRole: props.taskRole !== undefined ? props.taskRole : undefined
});

const optIn = props.createLogs !== undefined ? props.createLogs : true;

const container = taskDefinition.addContainer('web', {
const containerName = props.containerName !== undefined ? props.containerName : 'web';

const container = taskDefinition.addContainer(containerName, {
image: props.image,
logging: optIn ? this.createAWSLogDriver(this.node.id) : undefined,
environment: props.environment
Expand Down
Loading

0 comments on commit 8071164

Please sign in to comment.