I use Fargate with CDK. I want the task to be updated when my source code changes, but it does not work.
Note: I can do it with cli, but I want to do it with cdk. Is there a known solution?
new ecrdeploy.ECRDeployment(this, `EcrDeployment`, {
src: new ecrdeploy.DockerImageName(dockerImageAsset.imageUri),
dest: new ecrdeploy.DockerImageName(
`${accountId}.dkr.ecr.${region}.amazonaws.com/${ecrRepository.repositoryName}:latest`
),
});
const loadBalancedFargateService =
new ecsPatterns.ApplicationLoadBalancedFargateService(
this,
`Example`,
{
cluster,
memoryLimitMiB: 512,
desiredCount: 1,
cpu: 256,
taskImageOptions: {
containerPort: 3310,
containerName: `container`,
image: ecs.ContainerImage.fromEcrRepository(ecrRepository),
environment: {
...
},
},
taskSubnets: {
subnets: props.vpc.privateSubnets,
},
loadBalancerName: `loadBalancer`,
redirectHTTP: true,
publicLoadBalancer: true,
domainName: props.domainName,
domainZone: hostedZone,
certificate: certificate,
assignPublicIp: true,
circuitBreaker: {
rollback: true,
},
}
);