Skip to content

Commit

Permalink
Merge pull request #113 from kloia/feature/aws-amplify
Browse files Browse the repository at this point in the history
Add initial resources for amplify module
  • Loading branch information
bilalunalnet authored Nov 13, 2023
2 parents d08c974 + bccfd69 commit 3698a1d
Show file tree
Hide file tree
Showing 2 changed files with 173 additions and 0 deletions.
62 changes: 62 additions & 0 deletions aws-amplify/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
resource "aws_amplify_app" "this" {
name = var.name
repository = var.repository

build_spec = var.build_spec

environment_variables = var.environment_variables

auto_branch_creation_patterns = var.auto_branch_creation_patterns

enable_auto_branch_creation = try(var.enable_auto_branch_creation, false)
enable_basic_auth = try(var.enable_basic_auth, false)
enable_branch_auto_build = try(var.enable_branch_auto_build, false)
enable_branch_auto_deletion = try(var.enable_branch_auto_deletion, false)

iam_service_role_arn = var.iam_service_role_arn

platform = var.platform

dynamic "custom_rule" {
for_each = var.custom_rules

content {
source = custom_rule.value["source"]
status = custom_rule.value["status"]
target = custom_rule.value["target"]
}
}

tags = var.tags
}

resource "aws_amplify_branch" "this" {
app_id = aws_amplify_app.this.id
branch_name = var.branch_name

framework = var.framework
stage = var.stage

enable_auto_build = var.enable_auto_build
enable_performance_mode = var.enable_performance_mode
enable_pull_request_preview = var.enable_pull_request_preview

tags = var.tags
}

resource "aws_amplify_domain_association" "this" {
app_id = aws_amplify_app.this.id
domain_name = var.domain_name

enable_auto_sub_domain = var.enable_auto_sub_domain

dynamic "sub_domain" {
for_each = var.sub_domains

content {
branch_name = aws_amplify_branch.this.branch_name
prefix = try(sub_domain.value["prefix"], "")
dns_record = try(sub_domain.value["dns_record"], null)
}
}
}
111 changes: 111 additions & 0 deletions aws-amplify/variables.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
variable "name" {
description = "Application repository address connect to"
type = string
}

variable "repository" {
description = "Application repository address connect to"
type = string
}

variable "build_spec" {
description = "Application repository address connect to"
type = string
}

variable "environment_variables" {
type = any
default = {}
}

variable "enable_auto_branch_creation" {
description = "Application repository address connect to"
type = bool
default = false
}

variable "enable_basic_auth" {
description = "Application repository address connect to"
type = bool
default = false
}

variable "enable_branch_auto_build" {
description = "Application repository address connect to"
type = bool
default = false
}

variable "enable_branch_auto_deletion" {
description = "Application repository address connect to"
type = bool
default = false
}

variable "enable_auto_build" {
description = "Application repository address connect to"
type = bool
default = true
}

variable "enable_performance_mode" {
description = "Application repository address connect to"
type = bool
default = false
}

variable "platform" {
description = "Application repository address connect to"
type = string
default = "WEB_COMPUTE"
}

variable "auto_branch_creation_patterns" {
description = "Application repository address connect to"
type = list(any)
default = []
}

variable "iam_service_role_arn" {
description = "Application repository address connect to"
type = string
}

variable "custom_rules" {
type = list(any)
default = []
}

variable "tags" {
type = any
default = []
}

variable "branch_name" {
type = string
default = "main"
}

variable "framework" {
type = string
}
variable "domain_name" {
type = string
}
variable "sub_domains" {
type = list(any)
}

variable "stage" {
type = string
}

variable "enable_pull_request_preview" {
type = bool
default = false
}

variable "enable_auto_sub_domain" {
type = bool
default = false
}

0 comments on commit 3698a1d

Please sign in to comment.