Skip to content

Latest commit

 

History

History
135 lines (115 loc) · 12.9 KB

README.md

File metadata and controls

135 lines (115 loc) · 12.9 KB

Masterpoint Logo

terraform-aws-amplify-app

A Terraform module for building simple Amplify apps. This creates the master and develop branches, sets up the domain association, and creates webhooks for both branches.

Usage

module "amplify" {
  source = "git::https://github.com/masterpointio/terraform-aws-amplify-app.git?ref=tags/0.1.0"

  namespace                    = var.namespace
  stage                        = var.stage
  name                         = "mattgowie"
  organization                 = "Gowiem"
  repo                         = "mattgowie.com"
  gh_access_token              = var.gh_access_token
  domain_name                  = "mattgowie.com"
  description                  = "The Personal site of Matt Gowie."
  enable_basic_auth_on_master  = false
  enable_basic_auth_on_develop = true
  basic_auth_username          = var.basic_auth_username
  basic_auth_password          = var.basic_auth_password
  develop_pull_request_preview = true

  custom_rules = [{
    source    = "https://www.mattgowie.com"
    target    = "https://mattgowie.com"
    status    = "301"
    condition = null
  }, {
    source    = "/<*>"
    target    = "/index.html"
    status    = "404"
    condition = null
  }]
}

Credits

  1. @k24d's creation of the Amplify Resources for the AWS Provider!
  2. cloudposse/terraform-null-label

Requirements

Name Version
terraform >= 0.14.0
aws ~> 3.32
local ~> 2.1

Providers

Name Version
aws ~> 3.32

Modules

Name Source Version
develop_branch_label cloudposse/label/null 0.24.1
master_branch_label cloudposse/label/null 0.24.1
this cloudposse/label/null 0.24.1

Resources

Name Type
aws_amplify_app.this resource
aws_amplify_backend_environment.develop resource
aws_amplify_backend_environment.master resource
aws_amplify_branch.develop resource
aws_amplify_branch.master resource
aws_amplify_domain_association.this resource
aws_amplify_webhook.develop resource
aws_amplify_webhook.master resource
aws_iam_role.default resource
aws_iam_policy_document.assume_role data source

Inputs

Name Description Type Default Required
additional_tag_map Additional tags for appending to tags_as_list_of_maps. Not added to tags. map(string) {} no
amplify_service_role_enabled Whether to enable the IAM Service Role for Amplify or not. See https://docs.aws.amazon.com/amplify/latest/userguide/how-to-service-role-amplify-console.html for full details. bool false no
attributes Additional attributes (e.g. 1) list(string) [] no
basic_auth_password The password to use for the basic auth configuration. string n/a yes
basic_auth_username The username to use for the basic auth configuration. string n/a yes
build_spec_content Your build spec file contents. If not provided then it will use the amplify.yml at the root of your project / branch. string "" no
context Single object for setting entire context at once.
See description of individual variables for details.
Leave string and numeric variables as null to use default value.
Individual variable settings (non-null) override settings in context object,
except for attributes, tags, and additional_tag_map, which are merged.
object({
enabled = bool
namespace = string
environment = string
stage = string
name = string
delimiter = string
attributes = list(string)
tags = map(string)
additional_tag_map = map(string)
regex_replace_chars = string
label_order = list(string)
id_length_limit = number
})
{
"additional_tag_map": {},
"attributes": [],
"delimiter": null,
"enabled": true,
"environment": null,
"id_length_limit": null,
"label_order": [],
"name": null,
"namespace": null,
"regex_replace_chars": null,
"stage": null,
"tags": {}
}
no
custom_rules The custom rules to apply to the Amplify App.
list(object({
source = string # Required
target = string # Required
status = any # Use null if not passing
condition = any # Use null if not passing
}))
[] no
delimiter Delimiter to be used between namespace, environment, stage, name and attributes.
Defaults to - (hyphen). Set to "" to use no delimiter at all.
string null no
description The description to associate with the Amplify App. string n/a yes
develop_backend_environment_enabled Whether to create the backend environment for develop or not. bool false no
develop_branch_name The name of the 'develop'-like branch that you'd like to use. string "develop" no
develop_environment_variables Environment variables for the develop branch. map(string) {} no
develop_pull_request_preview Whether to enable preview on PR's into develop. bool true no
domain_name The Custom Domain Name to associate with this Amplify App. string "" no
enable_basic_auth_globally To enable basic auth for all branches or not. bool false no
enable_basic_auth_on_develop To enable basic auth on the develop branch subdomain or not. bool true no
enable_basic_auth_on_master To enable basic auth the root subdomain or not. bool false no
enabled Set to false to prevent the module from creating any resources bool null no
environment Environment, e.g. 'uw2', 'us-west-2', OR 'prod', 'staging', 'dev', 'UAT' string null no
gh_access_token Personal Access token for 3rd party source control system for an Amplify App, used to create webhook and read-only deploy key. Token is not stored. string n/a yes
global_environment_variables Environment variables that are set across all branches. map(string) {} no
id_length_limit Limit id to this many characters.
Set to 0 for unlimited length.
Set to null for default, which is 0.
Does not affect id_full.
number null no
label_order The naming order of the id output and Name tag.
Defaults to ["namespace", "environment", "stage", "name", "attributes"].
You can omit any of the 5 elements, but at least one must be present.
list(string) null no
master_backend_environment_enabled Whether to create the backend environment for master or not. bool false no
master_branch_name The name of the 'master'-like branch that you'd like to use. string "master" no
master_environment_variables Environment variables for the master branch. map(string) {} no
name Solution name, e.g. 'app' or 'jenkins' string null no
namespace Namespace, which could be your organization name or abbreviation, e.g. 'eg' or 'cp' string null no
organization The GitHub organization or user where the repo lives. string n/a yes
regex_replace_chars Regex to replace chars with empty string in namespace, environment, stage and name.
If not set, "/[^a-zA-Z0-9-]/" is used to remove all characters other than hyphens, letters and digits.
string null no
repo The name of the repo that the Amplify App will be created around. string n/a yes
stage Stage, e.g. 'prod', 'staging', 'dev', OR 'source', 'build', 'test', 'deploy', 'release' string null no
tags Additional tags (e.g. map('BusinessUnit','XYZ') map(string) {} no

Outputs

Name Description
arn The ARN of the main Amplify resource.
custom_domains List of custom domains that are associated with this resource (if any).
default_domain The amplify domain (non-custom).
develop_webhook_arn The ARN of the develop webhook.
develop_webhook_url The URL of the develop webhook.
domain_association_arn The ARN of the domain association resource.
master_webhook_arn The ARN of the master webhook.
master_webhook_url The URL of the master webhook.