将ApplicationLoadBalancedFargateService与aws代码管道操作一起使用


// fargate
const ecsService = new patterns.ApplicationLoadBalancedFargateService(this, 'Service', {
cluster: cluster, // Required
publicLoadBalancer: true,
taskImageOptions: {
image: ecs.ContainerImage.fromRegistry('nginx')
}
});
// codepipeline artifact
const sourceOutput = new codepipeline.Artifact();
// pipeline
const pipeline = new codepipeline.Pipeline(this, 'Pipeline');
// pipeline stage: Source
pipeline.addStage({
stageName: 'Source',
actions: [
new codepipeline_actions.EcrSourceAction({
actionName: 'ecr_push',
repository: repository,
output: sourceOutput
})
]
});
// pipeline stage: Deploy
pipeline.addStage({
stageName: 'Deploy',
actions: [
new codepipeline_actions.EcsDeployAction({
actionName: 'Deploy',
input: sourceOutput,
service: ecsService
})
]
});

使用模式ApplicationLoadBalancedFargateService创建fagate服务

但是,codepipeline_actionsEcsDeployAction道具service需要类型ecs.BaseService

如何解决这个问题?回到scrath构建fargae服务?

任何建议都将不胜感激!!

ApplicationLoadBalancedFargateService高级模式具有在实例上公开的service属性。ecsService.service的类型是实现IBaseService接口的FargateService。如果您将代码更改为:,您的代码应该可以工作

pipeline.addStage({
stageName: 'Deploy',
actions: [
new codepipeline_actions.EcsDeployAction({
actionName: 'Deploy',
input: sourceOutput,
service: ecsService.service, // <-
})
]
});

https://docs.aws.amazon.com/cdk/api/latest/docs/@aws-cdk_aws-ecs-patterings.ApplicationLoadBalancedFargateService.html#service

最新更新