【发布时间】:2018-10-07 12:38:55
【问题描述】:
我正在使用 terraform 来提供所需的资源。
我有一个 terraform 代码管道 resource 和 Production stage 读取 imagedefinitions.json 文件以了解要部署哪些图像:
resource "aws_codepipeline" "pipeline" {
stage {
name = "Build"
action {
name = "Build"
category = "Build"
owner = "AWS"
provider = "CodeBuild"
version = "1"
input_artifacts = ["source"]
output_artifacts = ["imagedefinitions"]
configuration {
ProjectName = "${var.project_prefix}-codebuild"
}
}
}
stage {
name = "Production"
action {
name = "Deploy"
category = "Deploy"
owner = "AWS"
provider = "ECS"
input_artifacts = ["imagedefinitions"]
version = "1"
configuration {
ClusterName = "${var.ecs_cluster_name}"
ServiceName = "${var.ecs_service_name}"
FileName = "imagedefinitions.json"
}
}
}
imagedefinitions.json 文件是在构建阶段构建的,来自buildspec.yml:
build:
commands:
- echo Build started on 'date'
- echo Building the Docker image...
- docker build -t $REPOSITORY_URI:latest .
- docker tag $REPOSITORY_URI:latest $REPOSITORY_URI:$IMAGE_TAG
post_build:
commands:
- echo Build completed on 'date'
- echo Pushing the Docker images...
- docker push $REPOSITORY_URI:latest
- docker push $REPOSITORY_URI:$IMAGE_TAG
- echo Writing image definitions file...
- printf '[{"name":"docker-image-name","imageUri":"%s"}]' $REPOSITORY_URI:$IMAGE_TAG > imagedefinitions.json
我不确定该行中图像的名称应该是什么:
- printf '[{"name":"docker-image-name","imageUri":"%s"}]' $REPOSITORY_URI:$IMAGE_TAG > imagedefinitions.json
我得到的错误重复了这一行的“名称”值:
“无效的操作配置AWS ECS容器docker-image-name不存在”
我应该在这里取什么名字?
【问题讨论】:
标签: amazon-web-services deployment terraform amazon-ecs aws-fargate