首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >添加存储库分支并配置在使用Terraform的AWS Ampify上构建

添加存储库分支并配置在使用Terraform的AWS Ampify上构建
EN

Stack Overflow用户
提问于 2021-06-25 23:41:20
回答 1查看 188关注 0票数 0

我一直在尝试使用Terraform在AWS Amplify上托管一个web应用程序。我使用了以下代码:

代码语言:javascript
复制
    # Ressource 1: AWS Amplify
resource "aws_amplify_app" "wildrydes-site" {
  name       = "wildrydes-site"
  repository = "https://github.com/userx/wildrydes-site"
  # GitHub personal access token
  access_token = "xxxxxxxxxxx"
 
  # The default rewrites and redirects added by the Amplify Console.
  custom_rule {
    source = "/<*>"
    status = "404"
    target = "/index.html"
  }

  #Auto Branch Creation
    enable_auto_branch_creation = true

  # The default patterns added by the Amplify Console.
  auto_branch_creation_patterns = [
    "*",
    "*/**",
  ]

  auto_branch_creation_config {
    # Enable auto build for the created branch.
    enable_auto_build = true
  }

资源是实际创建的,但我必须手动连接Git存储库中的源代码并添加存储库分支。有人知道我错过了什么吗?谢谢你的帮助。

EN

回答 1

Stack Overflow用户

发布于 2021-09-02 01:42:38

经过多次尝试,这最终对我起作用了。然而,可能不得不剖析其中的原因。

代码语言:javascript
复制
terraform {
  required_providers {
    aws = {
      source  = "hashicorp/aws"
      version = "~> 3.27"
    }
  }

  required_version = ">= 0.14.9"
}

provider "aws" {
  profile = "default"
  region  = "us-west-2"
}

resource "aws_amplify_app" "example" {
  name         = "blah"
  repository   = "repo here"
  access token = "..."


  environment_variables = {
    ENV = "test"
  }

  # The default rewrites and redirects added by the Amplify Console.
  custom_rule {
    source = "/<*>"
    status = "404"
    target = "/index.html"
  }

  #Auto Branch Creation
  enable_auto_branch_creation = true

  # The default patterns added by the Amplify Console.
  auto_branch_creation_patterns = [
    "*",
    "*/**",
  ]

  auto_branch_creation_config {
    # Enable auto build for the created branch.
    enable_auto_build = true
  }
}

resource "aws_amplify_branch" "master" {
  app_id      = aws_amplify_app.example.id
  branch_name = "main"

  stage = "PRODUCTION"

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

https://stackoverflow.com/questions/68133670

复制
相关文章

相似问题

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