aws-cdk-lib.aws_ecs.AssetImage

class AssetImage

LanguageType name
.NETAmazon.CDK.AWS.ECS.AssetImage
Gogithub.com/aws/aws-cdk-go/awscdk/v2/awsecs#AssetImage
Javasoftware.amazon.awscdk.services.ecs.AssetImage
Pythonaws_cdk.aws_ecs.AssetImage
TypeScript (source)aws-cdk-lib » aws_ecs » AssetImage

Extends ContainerImage

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 AssetImageProps

Constructs a new instance of the AssetImage class.

Methods

NameDescription
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 ContainerDefinition

Returns

  • ContainerImageConfig

Called when the image is used by a ContainerDefinition.