首先,我知道有一个类似的问题(AWS CodePipeline with ECS Blue/Green deployment failed with internal error),但是回答它的人没有提供足够的细节。
根据这个答案:https : //superuser.com/questions/1388058/getting-internal-error-in-aws-code-pipeline-while-deploying-to-ecs ..我已经阅读了aws指南:https: //docs.aws.amazon.com/AmazonECS/latest/developerguide/task_definition_parameters.html#constraints ... 确保所有“必填”字段都在我的taskdef.json中(如下)
至于我的管道(构建)buildSpec ...
- printf '{"ImageURI":"%s"}' $ECR_REPO_URI:demo > imageDetail.json
- echo Build completed on `date`
artifacts:
files:
- imageDetail.json
管道 构建阶段设置很简单,我只是将 BuildArtifact 设置为输出。所以我可以从管道 部署阶段引用 imageDetail.json 。
至于我的管道(部署)AppSpec ...
version: 0.0
Resources:
- TargetService:
Type: AWS::ECS::Service
Properties:
TaskDefinition: <TASK_DEFINITION>
LoadBalancerInfo:
ContainerName: "pipeline_demo"
ContainerPort: 80
PlatformVersion: "LATEST"
管道 部署阶段设置如下: 输入工件:BuildArtifact、SourceArtifact ;然后:
- Amazon ECS 任务定义:SourceArtifact “taskdef.json”
- AWS CodeDeploy AppSpec 文件:SourceArtifact “taskdef.json”
动态更新任务定义镜像:BuildArtifact
- 任务定义中的占位符文本:IMAGE1_NAME
..和taskdef:
{
"family": "devops-platform-ecs-task-def",
"type": "AWS::ECS::TaskDefinition",
"properties": {
"containerDefinitions": [
{
"name": "pipeline_demo",
"image": "<IMAGE1_NAME>",
"cpu": "1024",
"memory": "1024",
"essential": true,
"portMappings": [
{
"hostPort": 0,
"protocol": "tcp",
"containerPort": 80
}
]
}
],
"ExecutionRoleArn": "arn:aws:iam::xxxxxx:role/devops_codepipeline",
"NetworkMode": "null",
"PlacementConstraints": [
"type": "memberOf",
"expression": ""
],
"ProxyConfiguration": {
"type": "APPMESH",
"containerName": "",
"properties": [
{
"name": "",
"value": ""
}
]
},
"RequiresCompatibilities": [
"EC2"
],
"Tags": [
{
"key": "",
"value": ""
}
],
"TaskRoleArn": "",
"Volumes": [
{
"name": "",
"host": {
"sourcePath": ""
},
"dockerVolumeConfiguration": {
"scope": "task",
"autoprovision": true,
"driver": "",
"driverOpts": {
"KeyName": ""
},
"labels": {
"KeyName": ""
}
}
}
]
}
}
任何帮助将非常感激!