首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >Terraform Codepipeline在不同地区的部署

Terraform Codepipeline在不同地区的部署
EN

Stack Overflow用户
提问于 2021-12-27 04:22:46
回答 1查看 413关注 0票数 1

我正在尝试在刚刚可用的地区(雅加达)部署我的服务。但是看起来Codepipeline是不可用的,所以我必须在最近的地区(新加坡)创建Codepipeline,并将它部署到雅加达地区。这也是我第一次在Terraform建立Codepipeline,所以我不确定我做得对不对。

所有这些基础设施的默认区域是在“雅加达”地区。我将排除部署部分,因为没有部署问题就会出现。

代码语言:javascript
运行
复制
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配置,但是它给了我一个如下错误:

代码语言:javascript
运行
复制
│ Error: region cannot be set for a single-region CodePipeline

如果我试图移除根块上的区域,Terraform将尝试访问默认区域,即雅加达区域(并且它将失败,因为在雅加达没有Codepipeline )。

代码语言:javascript
运行
复制
│ 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
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2021-12-27 04:58:54

您需要使用不同的区域设置别名提供程序。特别代表:

代码语言:javascript
运行
复制
provider "aws" {  
    alias  = "singapore"  
    region = "ap-southeast-1"
}

然后使用别名将管道部署到该区域:

代码语言:javascript
运行
复制
resource "aws_codepipeline" "pipeline" {
 
  provider = aws.singapore

  name     = local.service_name
  role_arn = var.codepipeline_role_arn

  # ...
}
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/70491650

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档