我一直在尝试使用Terraform在AWS Amplify上托管一个web应用程序。我使用了以下代码:
# 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存储库中的源代码并添加存储库分支。有人知道我错过了什么吗?谢谢你的帮助。
发布于 2021-09-02 01:42:38
经过多次尝试,这最终对我起作用了。然而,可能不得不剖析其中的原因。
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"
}https://stackoverflow.com/questions/68133670
复制相似问题