我正在尝试在刚刚可用的地区(雅加达)部署我的服务。但是看起来Codepipeline是不可用的,所以我必须在最近的地区(新加坡)创建Codepipeline,并将它部署到雅加达地区。这也是我第一次在Terraform建立Codepipeline,所以我不确定我做得对不对。
所有这些基础设施的默认区域是在“雅加达”地区。我将排除部署部分,因为没有部署问题就会出现。
resource "aws_codepipeline" "pipeline" {
name = local.service_name
role_arn = var.codepipeline_role_arn
artifact_store {
type = "S3"
region = var.codepipeline_region
location = var.codepipeline_artifact_bucket_name
}
stage {
name = "Source"
action {
name = "Source"
category = "Source"
owner = "AWS"
provider = "CodeStarSourceConnection"
version = "1"
output_artifacts = ["SourceArtifact"]
region = var.codepipeline_region
configuration = {
ConnectionArn = var.codestar_connection
FullRepositoryId = "${var.team_name}/${local.repo_name}"
BranchName = local.repo_branch
OutputArtifactFormat = "CODEBUILD_CLONE_REF" // NOTE: Full clone
}
}
}
stage {
name = "Build"
action {
name = "Build"
category = "Build"
owner = "AWS"
provider = "CodeBuild"
version = "1"
input_artifacts = ["SourceArtifact"]
output_artifacts = ["BuildArtifact"]
run_order = 1
region = var.codepipeline_region
configuration = {
"ProjectName" = local.service_name
}
}
}
tags = {
Name = "${local.service_name}-pipeline"
Environment = local.env
}
}上面是我创建的Terraform配置,但是它给了我一个如下错误:
│ Error: region cannot be set for a single-region CodePipeline如果我试图移除根块上的区域,Terraform将尝试访问默认区域,即雅加达区域(并且它将失败,因为在雅加达没有Codepipeline )。
│ Error: Error creating CodePipeline: RequestError: send request failed
│ caused by: Post "https://codepipeline.ap-southeast-3.amazonaws.com/": dial tcp: lookup codepipeline.ap-southeast-3.amazonaws.com on 103.86.96.100:53: no such host发布于 2021-12-27 04:58:54
您需要使用不同的区域设置别名提供程序。特别代表:
provider "aws" {
alias = "singapore"
region = "ap-southeast-1"
}然后使用别名将管道部署到该区域:
resource "aws_codepipeline" "pipeline" {
provider = aws.singapore
name = local.service_name
role_arn = var.codepipeline_role_arn
# ...
}https://stackoverflow.com/questions/70491650
复制相似问题