我正在嘗試在剛剛可用的區域(雅加達)部署我的服務。但看起來 Codepipeline 不可用,所以我必須在最近的地區(新加坡)創建 Codepipeline 并將其部署到雅加達地區。這也是我第一次在 Terraform 中設定 Codepipeline,所以我不確定我是否做得對。
PS 所有這些基礎設施的默認區域都在“雅加達”區域。我將排除部署部分,因為沒有它就會出現問題。
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
uj5u.com熱心網友回復:
您需要設定不同區域的別名提供程式。例如:
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://www.uj5u.com/qukuanlian/394572.html
標籤:亚马逊网络服务 地形 aws-codepipeline
