The AWS::Amplify::App resource creates Apps in the Amplify Console. An App is a collection of branches.
To use awscc_amplify_app to create a basic Amplify App:
resource "awscc_amplify_app" "example" {
name = "app"
// replace with your repo URL - must also ensure Amplify has permissions to access the repo
// GitHub instructions: https://docs.aws.amazon.com/amplify/latest/userguide/setting-up-GitHub-access.html
repository = "https://github.com/example/app"
# The default build_spec added by the Amplify Console for React.
build_spec = <<-EOT
version: 0.1
frontend:
phases:
preBuild:
commands:
- yarn install
build:
commands:
- yarn run build
artifacts:
baseDirectory: build
files:
- '**/*'
cache:
paths:
- node_modules/**/*
EOT
# The default rewrites and redirects added by the Amplify Console.
custom_rules = [
{
source = "/<*>"
status = "404"
target = "/index.html"
},
]
environment_variables = [
{
name = "Environment"
value = "PROD"
},
]
tags = [
{
key = "Modified By"
value = "AWSCC"
}
]
}
When creating a new Amplify app with the repository
argument, you also need
to set oauth_token
or access_token
for authentication. For GitHub, see this
AWS documentation and set access_token
as follows:
resource "awscc_amplify_app" "example" {
name = "app"
repository = "https://github.com/example/app"
# GitHub personal access token
access_token = "..."
tags = [
{
key = "Modified By"
value = "AWSCC"
}
]
}
You can omit access_token
if you import an existing Amplify App created by the Amplify Console (using OAuth for authentication).
resource "awscc_amplify_app" "example" {
name = "app"
auto_branch_creation_config = {
# Enable auto branch creation
enable_auto_branch_creation = true
# Enable auto build for the created branch.
enable_auto_build = true
# The default patterns added by the Amplify Console.
auto_branch_creation_patterns = [
"*",
"*/**",
]
}
tags = [
{
key = "Modified By"
value = "AWSCC"
}
]
}
resource "awscc_amplify_app" "example" {
name = "app"
basic_auth_config = {
enable_basic_auth = true
username = "your-username"
password = "your-password"
}
tags = [
{
key = "Modified By"
value = "AWSCC"
}
]
}
resource "awscc_amplify_app" "example" {
name = "app"
custom_rules = [
{
# Reverse Proxy Rewrite for API requests
# https://docs.aws.amazon.com/amplify/latest/userguide/redirects.html#reverse-proxy-rewrite
source = "/api/<*>"
status = "200"
target = "https://api.example.com/api/<*>"
},
{
# Redirects for Single Page Web Apps (SPA)
# https://docs.aws.amazon.com/amplify/latest/userguide/redirects.html#redirects-for-single-page-web-apps-spa
source = "</^[^.]+$|\\.(?!(css|gif|ico|jpg|js|png|txt|svg|woff|ttf|map|json)$)([^.]+$)/>"
status = "200"
target = "/index.html"
},
]
tags = [
{
key = "Modified By"
value = "AWSCC"
}
]
}
name
(String)access_token
(String)auto_branch_creation_config
(Attributes) (see below for nested schema)basic_auth_config
(Attributes) (see below for nested schema)build_spec
(String)custom_headers
(String)custom_rules
(Attributes List) (see below for nested schema)description
(String)enable_branch_auto_deletion
(Boolean)environment_variables
(Attributes List) (see below for nested schema)iam_service_role
(String)oauth_token
(String)platform
(String)repository
(String)tags
(Attributes List) (see below for nested schema)app_id
(String)app_name
(String)arn
(String)default_domain
(String)id
(String) Uniquely identifies the resource.auto_branch_creation_config
Optional:
auto_branch_creation_patterns
(List of String)basic_auth_config
(Attributes) (see below for nested schema)build_spec
(String)enable_auto_branch_creation
(Boolean)enable_auto_build
(Boolean)enable_performance_mode
(Boolean)enable_pull_request_preview
(Boolean)environment_variables
(Attributes List) (see below for nested schema)framework
(String)pull_request_environment_name
(String)stage
(String)auto_branch_creation_config.basic_auth_config
Optional:
enable_basic_auth
(Boolean)password
(String)username
(String)auto_branch_creation_config.environment_variables
Required:
name
(String)value
(String)basic_auth_config
Optional:
enable_basic_auth
(Boolean)password
(String)username
(String)custom_rules
Required:
source
(String)target
(String)Optional:
condition
(String)status
(String)environment_variables
Required:
name
(String)value
(String)tags
Required:
key
(String)value
(String)Import is supported using the following syntax:
$ terraform import awscc_amplify_app.example <resource ID>