Last active
February 16, 2023 11:27
-
-
Save skorfmann/8da4eb64845e10f5937655520d53ac14 to your computer and use it in GitHub Desktop.
Example for Fargate Task Defintion with ECR Docker Image Asset - https://docs.aws.amazon.com/cdk/api/latest/docs/@aws-cdk_aws-ecr-assets.DockerImageAsset.html
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
import ecs = require('@aws-cdk/aws-ecs'); | |
import { DockerImageAsset } from '@aws-cdk/aws-ecr-assets'; | |
import path = require('path') | |
export interface FooFargateProps { | |
} | |
export class FooFargate extends cdk.Construct { | |
constructor(scope: cdk.Construct, id: string, props: FooFargateProps = {}) { | |
super(scope, id); | |
const taskDefinition = new ecs.FargateTaskDefinition(this, 'FooDefinition', { | |
memoryLimitMiB: 2048, | |
cpu: 1024 | |
}); | |
const asset = new DockerImageAsset(this, 'FooEcrImage', { | |
directory: path.join(__dirname, 'assets'), | |
}); | |
asset.repository.grantPull(taskDefinition.taskRole) | |
const logging = new ecs.AwsLogDriver({ | |
streamPrefix: "foo" | |
}) | |
taskDefinition.addContainer('DefaultContainer', { | |
image: ecs.ContainerImage.fromEcrRepository(asset.repository), | |
memoryReservationMiB: 2048, | |
cpu: 1024, | |
logging | |
}); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment