How to use the @aws-cdk/aws-ecs.AwsLogDriver function in @aws-cdk/aws-ecs

To help you get started, we’ve selected a few @aws-cdk/aws-ecs examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github duo-labs / cloudmapper / auditor / lib / cloudmapperauditor-stack.js View on Github external
});

    // Define the ECS task
    const cluster = new ecs.Cluster(this, 'Cluster', { vpc });

    const taskDefinition = new ecs.FargateTaskDefinition(this, 'taskDefinition', {});

    taskDefinition.addContainer('cloudmapper-container', {
      image: ecs.ContainerImage.fromAsset('./resources'),
      memoryLimitMiB: 512,
      cpu: 256,
      environment: {
        S3_BUCKET: config['s3_bucket'],
        MINIMUM_ALERT_SEVERITY: config['minimum_alert_severity']
      },
      logging: new ecs.AwsLogDriver({
        streamPrefix: 'cloudmapper',
        logRetention: logs.RetentionDays.TWO_WEEKS
      })
    });

    // Grant the ability to assume the IAM role in any account
    taskDefinition.addToTaskRolePolicy(new iam.PolicyStatement({
      resources: ["arn:aws:iam::*:role/"+config['iam_role']],
      actions: ['sts:AssumeRole']
    }));

    // Grant the ability to read and write the files from the S3 bucket
    taskDefinition.addToTaskRolePolicy(new iam.PolicyStatement({
      resources: ["arn:aws:s3:::"+config['s3_bucket']],
      actions: ['s3:ListBucket']
    }));
github aws-samples / aws-cdk-changelogs-demo / changelogs-md.js View on Github external
return false;
    });

    // Define the follower application.
    const followerDefinition = new ecs.FargateTaskDefinition(this, 'NpmFollowerDefinition', {});

    followerDefinition.addContainer('npm-follower', {
      image: ecs.ContainerImage.fromAsset('./app/npm-follower'),
      memoryMiB: 512,
      cpu: 256,
      environment: {
        CHANGELOGS_TABLE_NAME: props.changelogsTable.tableName,
        DISCOVERED_TOPIC_NAME: props.toCrawlTopic.topicArn
      },
      logging: new ecs.AwsLogDriver({
        streamPrefix: 'npm-follower'
      })
    });

    // Grant this application access to the DynamoDB table and SNS topic
    props.changelogsTable.grantReadWriteData(followerDefinition.taskRole);
    props.toCrawlTopic.grantPublish(followerDefinition.taskRole);

    // Launch the image as a service in Fargate
    this.npmFollower = new ecs.FargateService(this, 'NpmFollower', {
      assignPublicIp: true,
      cluster: props.cluster, // Required
      cpu: '256',
      memoryMiB: '512',
      desiredCount: 1,
      taskDefinition: followerDefinition,
github aws / aws-cdk / packages / @aws-cdk / aws-ecs-patterns / lib / base / scheduled-task-base.ts View on Github external
protected createAWSLogDriver(prefix: string): AwsLogDriver {
    return new AwsLogDriver({ streamPrefix: prefix });
  }
}
github aws / aws-cdk / packages / @aws-cdk / aws-ecs-patterns / lib / base / queue-processing-service-base.ts View on Github external
private createAWSLogDriver(prefix: string): AwsLogDriver {
    return new AwsLogDriver({ streamPrefix: prefix });
  }
}
github aws / aws-cdk / packages / @aws-cdk / aws-ecs-patterns / lib / base / application-load-balanced-service-base.ts View on Github external
protected createAWSLogDriver(prefix: string): AwsLogDriver {
    return new AwsLogDriver({ streamPrefix: prefix });
  }
}
github nathanpeck / screenshot-service / app.3.js View on Github external
cpu: '2048',
      memoryMiB: '4096'
    });

    this.container = this.workerDefinition.addContainer('worker', {
      image: ecs.ContainerImage.fromAsset(this, 'worker-image', {
        directory: './worker'
      }),
      cpu: 2048,
      memoryLimitMiB: 4096,
      environment: {
        QUEUE_URL: props.screenshotQueue.queueUrl,
        TABLE: props.screenshotTable.tableName,
        BUCKET: props.screenshotBucket.bucketName
      },
      logging: new ecs.AwsLogDriver(this, 'worker-logs', {
        streamPrefix: 'worker'
      })
    });

    this.worker = new ecs.FargateService(this, 'worker', {
      cluster: props.cluster,
      desiredCount: 2,
      taskDefinition: this.workerDefinition
    });

    props.screenshotQueue.grantConsumeMessages(this.workerDefinition.taskRole);
    props.screenshotTable.grantReadWriteData(this.workerDefinition.taskRole);
    props.screenshotBucket.grantReadWrite(this.workerDefinition.taskRole);
  }
}
github aws / aws-cdk / packages / @aws-cdk / aws-ecs-patterns / lib / base / network-load-balanced-service-base.ts View on Github external
protected createAWSLogDriver(prefix: string): AwsLogDriver {
    return new AwsLogDriver({ streamPrefix: prefix });
  }
}
github humank / EventStormingWorkShop / deployment / coffeeshop-cdk / lib / coffee-shop-code-pipeline.ts View on Github external
const cluster = new ecs.Cluster(this, 'Cluster', {
            clusterName: 'coffeeshop',
            vpc
        });



        const taskDefinition = new ecs.TaskDefinition(this, 'orders-web-Task', {
            compatibility: ecs.Compatibility.FARGATE,
            memoryMiB: '512',
            cpu: '256',
        });

        taskDefinition.addContainer('defaultContainer', {
            image: ecs.ContainerImage.fromRegistry('amazon/amazon-ecs-sample'),
            logging: new ecs.AwsLogDriver({
                streamPrefix: 'coffeeshop',
            })
        }).addPortMappings({
            containerPort: 8080
        });

        const fargatesvc = new ecsPatterns.ApplicationLoadBalancedFargateService(this, 'AlbSvc', {
            cluster,
            taskDefinition,
        })

        const fargateTaskRole = fargatesvc.service.taskDefinition.taskRole;
        fargateTaskRole.addToPolicy(new iam.PolicyStatement({
            resources: ['*'],
            actions: ['events:*']
        }));