// 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_actions EcsDeployAction
道具service
需要类型ecs.BaseService
如何解决此问题?从scrath返回来构建Fargae服务?
任何建议将不胜感激!
答案 0 :(得分:1)
ApplicationLoadBalancedFargateService
更高级别的模式具有实例上公开的service
属性。 ecsService.service
的类型为FargateService
,它实现了IBaseService
接口。如果将代码更改为:
pipeline.addStage({
stageName: 'Deploy',
actions: [
new codepipeline_actions.EcsDeployAction({
actionName: 'Deploy',
input: sourceOutput,
service: ecsService.service, // <-
})
]
});