// 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