Skip to content

Terraform module for building Amplify Hosting APPs, create as many necessary braches and domain associations.

License

Notifications You must be signed in to change notification settings

brunordias/terraform-aws-amplify-app

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

AWS Amplify Hosting APP Terraform module

Terraform module for building Amplify Hosting APPs, create as many necessary braches and domain associations.

Usage

module "app" {
  source  = "brunordias/amplify-app/aws"
  version = "~> 1.0.0"

  name                     = "myapp"
  description              = "My Amplify APP"
  repository               = "https://gitlab.com/group/blabla" # GitLab or Github repo URL
  access_token             = var.access_token # GitLab or GitHub personal token (use sensitive value in Terraform Cloud)
  
  enable_branch_auto_build = true
  app_environment = {
    NAME = "test" # global envs
  }
  custom_rule = [
    {
      source = "https://www.example.com"
      status = "302"
      target = "https://example.com"
    }
  ]
  domain_management = {
    dev = {
      domain_name = "otherdomain.com"
      sub_domain = [
        {
          prefix      = "dev" # dev.otherdomain.com
          branch_name = "dev"
        }
      ]
    }
    prod = {
      domain_name = "example.com"
      sub_domain = [
        {
          prefix      = ""     # example.com
          branch_name = "main"
        },
        {
          prefix      = "www"  # www.example.com
          branch_name = "main"
        }
      ]
    }
  }
  branches_config = {
    dev = {
      branch_name         = "dev"
      display_name        = "dev"
      enable_basic_auth   = true
      basic_auth_username = "user"
      basic_auth_password = "secret"
      app_environment = {
        REACT_APP_FOO = "foo"   # branch envs
        REACT_APP_BAR = "bar"
      }
    },
    prod = {
      branch_name  = "main"
      display_name = "prod"
      app_environment = {
        REACT_APP_FOO = "foo"
        REACT_APP_BAR = "bar"
      }
    }
  }
}

Bitbucket Requirements

To use Bitbucket as VCS it is necessary to use OAuth for authentication. https://support.atlassian.com/bitbucket-cloud/docs/use-oauth-on-bitbucket-cloud/

...

  repository               = "https://bitbucket.org/foo/bar" # Bitbucket repo URL
  oauth_token              = var.oauth_token # Bitbucket OAuth token (use sensitive value in Terraform Cloud)

...

Requirements

Name Version
terraform >= 1.0.0
aws >= 3.74.0

Providers

Name Version
aws >= 3.74.0

Modules

Name Source Version
branch ./modules/amplify-branch n/a
domain_management ./modules/amplify-domain n/a

Resources

Name Type
aws_amplify_app.this resource
aws_iam_role.this resource
aws_iam_role_policy_attachment.this resource

Inputs

Name Description Type Default Required
access_token The personal access token for a third-party source control system for an Amplify app. string null no
app_environment The environment variables map for an Amplify app. map(any) {} no
basic_auth_password The basic auth password for an Amplify app. string "" no
basic_auth_username The basic auth username for an Amplify app. string "" no
branches_config The configuration for an Amplify Branch. any {} no
build_spec The build specification (build spec) for an Amplify app. string null no
custom_rule The custom rewrite and redirect rules for an Amplify app. any [] no
description The description for an Amplify app. string null no
domain_management The configuration for an Amplify Domain. any {} no
enable_basic_auth Enables basic authorization for an Amplify app. bool false no
enable_branch_auto_build Enables auto-building of branches for the Amplify App. bool true no
name The name for an Amplify app. string n/a yes
oauth_token The OAuth token for a third-party source control system for an Amplify app. string null no
platform Platform or framework for an Amplify app. Valid values: WEB or WEB_DYNAMIC string "WEB" no
repository The repository for an Amplify app. string "" no
service_role Creates IAM Service Role for an Amplify app. bool false no
tags A mapping of tags to assign to all resources. map(any) {} no

Outputs

No outputs.

About

Terraform module for building Amplify Hosting APPs, create as many necessary braches and domain associations.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages