aws-cdk-lib.aws_ecs.AssetImage
class AssetImage
Language | Type name |
---|---|
![]() | Amazon.CDK.AWS.ECS.AssetImage |
![]() | github.com/aws/aws-cdk-go/awscdk/v2/awsecs#AssetImage |
![]() | software.amazon.awscdk.services.ecs.AssetImage |
![]() | aws_cdk.aws_ecs.AssetImage |
![]() | aws-cdk-lib » aws_ecs » AssetImage |
Extends
Container
An image that will be built from a local directory with a Dockerfile.
Example
import { Construct } from 'constructs';
import { App, Stack } from 'aws-cdk-lib';
import * as ec2 from 'aws-cdk-lib/aws-ec2';
import * as ecs from 'aws-cdk-lib/aws-ecs';
import * as ecsPatterns from 'aws-cdk-lib/aws-ecs-patterns';
import * as cxapi from 'aws-cdk-lib/cx-api';
import * as path from 'path';
class MyStack extends Stack {
constructor(scope: Construct, id: string) {
super(scope, id);
this.node.setContext(cxapi.ECS_REMOVE_DEFAULT_DESIRED_COUNT, true);
const vpc = new ec2.Vpc(this, 'VPC', {
maxAzs: 2,
});
new ecsPatterns.QueueProcessingFargateService(this, 'QueueProcessingService', {
vpc,
memoryLimitMiB: 512,
image: new ecs.AssetImage(path.join(__dirname, '..', 'sqs-reader')),
});
}
}
Initializer
new AssetImage(directory: string, props?: AssetImageProps)
Parameters
- directory
string
— The directory containing the Dockerfile. - props
Asset
Image Props
Constructs a new instance of the AssetImage class.
Methods
Name | Description |
---|---|
bind(scope, containerDefinition) | Called when the image is used by a ContainerDefinition. |
bind(scope, containerDefinition)
public bind(scope: Construct, containerDefinition: ContainerDefinition): ContainerImageConfig
Parameters
- scope
Construct
- containerDefinition
Container
Definition
Returns
Called when the image is used by a ContainerDefinition.