Skip to content

Commit

Permalink
Support AWSLog driver and whatever else.
Browse files Browse the repository at this point in the history
  • Loading branch information
neilkuan committed Feb 18, 2021
1 parent c64e9fc commit cf9f231
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 14 deletions.
4 changes: 2 additions & 2 deletions API.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ new ValheimWorld(scope: Construct, id: string, props?: ValheimWorldProps)
* **environment** (<code>Map<string, string></code>) https://github.com/lloesche/valheim-server-docker#environment-variables. __*Optional*__
* **fileSystem** (<code>[FileSystem](#aws-cdk-aws-efs-filesystem)</code>) *No description* __*Optional*__
* **image** (<code>[ContainerImage](#aws-cdk-aws-ecs-containerimage)</code>) *No description* __*Optional*__
* **logGroup** (<code>[ILogGroup](#aws-cdk-aws-logs-iloggroup)</code>) valheim server log Group. __*Default*__: Create the new one for Valheim Server.
* **logGroup** (<code>[AwsLogDriver](#aws-cdk-aws-ecs-awslogdriver)</code>) Valheim Server log Group. __*Default*__: Create the new AWS Cloudwatch Log Group for Valheim Server.
* **memoryLimitMiB** (<code>number</code>) The amount (in MiB) of memory used by the task. __*Default*__: 2048
* **vpc** (<code>[IVpc](#aws-cdk-aws-ec2-ivpc)</code>) *No description* __*Optional*__

Expand Down Expand Up @@ -68,7 +68,7 @@ Name | Type | Description
**environment**? | <code>Map<string, string></code> | https://github.com/lloesche/valheim-server-docker#environment-variables.<br/>__*Optional*__
**fileSystem**? | <code>[FileSystem](#aws-cdk-aws-efs-filesystem)</code> | __*Optional*__
**image**? | <code>[ContainerImage](#aws-cdk-aws-ecs-containerimage)</code> | __*Optional*__
**logGroup**? | <code>[ILogGroup](#aws-cdk-aws-logs-iloggroup)</code> | valheim server log Group.<br/>__*Default*__: Create the new one for Valheim Server.
**logGroup**? | <code>[AwsLogDriver](#aws-cdk-aws-ecs-awslogdriver)</code> | Valheim Server log Group.<br/>__*Default*__: Create the new AWS Cloudwatch Log Group for Valheim Server.
**memoryLimitMiB**? | <code>number</code> | The amount (in MiB) of memory used by the task.<br/>__*Default*__: 2048
**vpc**? | <code>[IVpc](#aws-cdk-aws-ec2-ivpc)</code> | __*Optional*__

Expand Down
19 changes: 7 additions & 12 deletions src/valheim.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,11 @@ export interface ValheimWorldProps {
[key: string]: string;
};
/**
* valheim server log Group.
* Valheim Server log Group.
*
* @default - Create the new one for Valheim Server.
* @default - Create the new AWS Cloudwatch Log Group for Valheim Server.
*/
readonly logGroup?: logs.ILogGroup;
readonly logGroup?: ecs.AwsLogDriver;
}


Expand Down Expand Up @@ -85,14 +85,6 @@ export class ValheimWorld extends Construct {
},
};

const awsLogDriverProps: ecs.AwsLogDriverProps = props?.logGroup ? {
streamPrefix: 'valheim',
logGroup: props?.logGroup,
}: {
streamPrefix: 'valheim',
logRetention: logs.RetentionDays.ONE_DAY,
};

const taskDefinition = new ecs.FargateTaskDefinition(this, 'ValheimTaskDefinition', {
family: 'valheim-world',
volumes: [volumeConfig],
Expand All @@ -102,7 +94,10 @@ export class ValheimWorld extends Construct {

const containerDefinition = taskDefinition.addContainer('ValheimContainer', {
image: props?.image ?? ecs.ContainerImage.fromRegistry('lloesche/valheim-server'),
logging: new ecs.AwsLogDriver(awsLogDriverProps),
logging: props?.logGroup ?? new ecs.AwsLogDriver({
streamPrefix: 'valheim',
logRetention: logs.RetentionDays.ONE_DAY,
}),
environment: props?.environment,
});
containerDefinition.addMountPoints(
Expand Down

0 comments on commit cf9f231

Please sign in to comment.