Skip to content

Commit

Permalink
fix(ecs): support file as firelens config type (#6322)
Browse files Browse the repository at this point in the history
* Allow file config type in firelens-log-router

* add test for FILE fluentbit config type

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
  • Loading branch information
bvtujo and mergify[bot] committed Feb 18, 2020
1 parent f865d5e commit f9996f3
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 2 deletions.
2 changes: 1 addition & 1 deletion packages/@aws-cdk/aws-ecs/lib/firelens-log-router.ts
Expand Up @@ -201,7 +201,7 @@ export class FirelensLogRouter extends ContainerDefinition {
const options = props.firelensConfig.options;
if (options) {
const enableECSLogMetadata = options.enableECSLogMetadata || options.enableECSLogMetadata === undefined;
const configFileType = options.configFileType ||
const configFileType = (options.configFileType === undefined || options.configFileType === FirelensConfigFileType.S3) &&
(cdk.Token.isUnresolved(options.configFileValue) || /arn:aws[a-zA-Z-]*:s3:::.+/.test(options.configFileValue))
? FirelensConfigFileType.S3 : FirelensConfigFileType.FILE;
this.firelensConfig = {
Expand Down
39 changes: 38 additions & 1 deletion packages/@aws-cdk/aws-ecs/test/test.firelens-log-driver.ts
Expand Up @@ -14,7 +14,6 @@ export = {

cb();
},

'create a firelens log driver with default options'(test: Test) {
// WHEN
td.addContainer('Container', {
Expand Down Expand Up @@ -191,5 +190,43 @@ export = {

test.done();
},

"fluent-bit log router with file config type"(test: Test) {
// GIVEN
td.addFirelensLogRouter('log_router', {
image: ecs.obtainDefaultFluentBitECRImage(td, undefined, '2.1.0'),
firelensConfig: {
type: ecs.FirelensLogRouterType.FLUENTBIT,
options: {
enableECSLogMetadata: false,
configFileType: ecs.FirelensConfigFileType.FILE,
configFileValue: '/my/working/dir/firelens/config'
}
},
logging: new ecs.AwsLogDriver({streamPrefix: 'firelens'}),
memoryReservationMiB: 50,
});

// THEN
expect(stack).to(haveResourceLike('AWS::ECS::TaskDefinition', {
ContainerDefinitions: [
{
Essential: true,
MemoryReservation: 50,
Name: 'log_router',
FirelensConfiguration: {
Type: 'fluentbit',
Options: {
'enable-ecs-log-metadata': 'false',
'config-file-type': 'file',
'config-file-value': '/my/working/dir/firelens/config'
}
},
}
]
}));

test.done();
}
},
};

0 comments on commit f9996f3

Please sign in to comment.