Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 38 additions & 0 deletions .github/workflows/pull-request-ephemeral-deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: Deploy Sandbox Environment

on:
pull_request:
types: [opened, synchronize, reopened]
branches: [ "**" ]

jobs:
get-tg-versions:
permissions:
contents: read
uses: launchbynttdata/launch-workflows/.github/workflows/reusable-terragrunt-versions.yml@0.1.7

build-matrix:
permissions:
contents: read
uses: launchbynttdata/launch-workflows/.github/workflows/reusable-github-matrix-tg.yml@0.1.7
with:
platform_environment: sandbox

call-terragrunt-deploy:
needs: [get-tg-versions, build-matrix]
permissions:
contents: read
id-token: write
strategy:
fail-fast: false
matrix: ${{ fromJson(needs.build-matrix.outputs.matrix) }}

uses: launchbynttdata/launch-workflows/.github/workflows/reusable-terragrunt-deploy-ephemeral.yml@feature/tg-deploy-without-gh-environment
with:
git_branch: ${{ github.head_ref }}
assume_role_arn: "arn:aws:iam::020127659860:role/github-actions-deploy-role"
tf_version: ${{ needs.get-tg-versions.outputs.tf_version }}
tg_version: ${{ needs.get-tg-versions.outputs.tg_version }}
region: ${{ matrix.terragrunt_environment.region }}
env_id: ${{ matrix.terragrunt_environment.instance }}
secrets: inherit
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ name: Deploy Sandbox Environment

on:
pull_request:
types: [closed]
branches: [ "**" ]

jobs:
Expand All @@ -26,11 +27,12 @@ jobs:
fail-fast: false
matrix: ${{ fromJson(needs.build-matrix.outputs.matrix) }}

uses: launchbynttdata/launch-workflows/.github/workflows/reusable-terragrunt-deploy.yml@0.1.7
uses: launchbynttdata/launch-workflows/.github/workflows/reusable-terragrunt-destroy-ephemeral.yml@feature/tg-deploy-without-gh-environment
with:
git_branch: ${{ github.head_ref }}
assume_role_arn: "arn:aws:iam::020127659860:role/github-actions-deploy-role"
tf_version: ${{ needs.get-tg-versions.outputs.tf_version }}
tg_version: ${{ needs.get-tg-versions.outputs.tg_version }}
environment: ${{ matrix.terragrunt_environment.environment }}
region: ${{ matrix.terragrunt_environment.region }}
env_id: ${{ matrix.terragrunt_environment.instance }}
secrets: inherit
14 changes: 6 additions & 8 deletions platform/production/us-east-1/000/terraform.tfvars
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
create_package = true
create = true
handler = "app.lambda_handler"
cors = { allow_origins = ["*"] }
source_path = "../../../../../../../src/function/"
name = "platform_sample-useast1-production-000-fn-000"
environment_variables = {
create_package = true
create = true
handler = "app.lambda_handler"
cors = { allow_origins = ["*"] }
source_path = "../../../../../../../src/function/"
environment_variables = {
PAYLOAD = "Primary"
}

4 changes: 2 additions & 2 deletions platform/production/us-east-1/000/terragrunt.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ include "root" {
}

locals {
git_tag = "1.0.3"
git_tag = "1.0.0"
}

terraform {
source = "tfr://terraform.registry.launch.nttdata.com/module_primitive/lambda_function/aws?version=${local.git_tag}"
source = "tfr://terraform.registry.launch.nttdata.com/module_reference/lambda_function/aws?version=${local.git_tag}"
}
13 changes: 6 additions & 7 deletions platform/production/us-east-2/000/terraform.tfvars
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
create_package = true
create = true
handler = "app.lambda_handler"
cors = { allow_origins = ["*"] }
source_path = "../../../../../../../src/function/"
name = "platform_sample-useast2-production-000-fn-000"
environment_variables = {
create_package = true
create = true
handler = "app.lambda_handler"
cors = { allow_origins = ["*"] }
source_path = "../../../../../../../src/function/"
environment_variables = {
PAYLOAD = "Failover"
}
4 changes: 2 additions & 2 deletions platform/production/us-east-2/000/terragrunt.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ include "root" {
}

locals {
git_tag = "1.0.3"
git_tag = "1.0.0"
}

terraform {
source = "tfr://terraform.registry.launch.nttdata.com/module_primitive/lambda_function/aws?version=${local.git_tag}"
source = "tfr://terraform.registry.launch.nttdata.com/module_reference/lambda_function/aws?version=${local.git_tag}"
}
13 changes: 6 additions & 7 deletions platform/sandbox/us-east-2/000/terraform.tfvars
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
create_package = true
create = true
handler = "app.lambda_handler"
cors = { allow_origins = ["*"] }
source_path = "../../../../../../../src/function/"
name = "platform_sample-useast2-sandbox-000-fn-000"
environment_variables = {
create_package = true
create = true
handler = "app.lambda_handler"
cors = { allow_origins = ["*"] }
source_path = "../../../../../../../src/function/"
environment_variables = {
PAYLOAD = "Primary-East"
}
4 changes: 2 additions & 2 deletions platform/sandbox/us-east-2/000/terragrunt.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ include "root" {
}

locals {
git_tag = "1.0.3"
git_tag = "1.0.0"
}

terraform {
source = "tfr://terraform.registry.launch.nttdata.com/module_primitive/lambda_function/aws?version=${local.git_tag}"
source = "tfr://terraform.registry.launch.nttdata.com/module_reference/lambda_function/aws?version=${local.git_tag}"
}
13 changes: 6 additions & 7 deletions platform/sandbox/us-east-2/001/terraform.tfvars
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
create_package = true
create = true
handler = "app.lambda_handler"
cors = { allow_origins = ["*"] }
source_path = "../../../../../../../src/function/"
name = "platform_sample-useast2-sandbox-001-fn-000"
environment_variables = {
create_package = true
create = true
handler = "app.lambda_handler"
cors = { allow_origins = ["*"] }
source_path = "../../../../../../../src/function/"
environment_variables = {
PAYLOAD = "Failover-East"
}
4 changes: 2 additions & 2 deletions platform/sandbox/us-east-2/001/terragrunt.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ include "root" {
}

locals {
git_tag = "1.0.3"
git_tag = "1.0.0"
}

terraform {
source = "tfr://terraform.registry.launch.nttdata.com/module_primitive/lambda_function/aws?version=${local.git_tag}"
source = "tfr://terraform.registry.launch.nttdata.com/module_reference/lambda_function/aws?version=${local.git_tag}"
}
13 changes: 6 additions & 7 deletions platform/sandbox/us-west-2/000/terraform.tfvars
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
create_package = true
create = true
handler = "app.lambda_handler"
cors = { allow_origins = ["*"] }
source_path = "../../../../../../../src/function/"
name = "platform_sample-uswest2-sandbox-000-fn-000"
environment_variables = {
create_package = true
create = true
handler = "app.lambda_handler"
cors = { allow_origins = ["*"] }
source_path = "../../../../../../../src/function/"
environment_variables = {
PAYLOAD = "Primary-West"
}
4 changes: 2 additions & 2 deletions platform/sandbox/us-west-2/000/terragrunt.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ include "root" {
}

locals {
git_tag = "1.0.3"
git_tag = "1.0.0"
}

terraform {
source = "tfr://terraform.registry.launch.nttdata.com/module_primitive/lambda_function/aws?version=${local.git_tag}"
source = "tfr://terraform.registry.launch.nttdata.com/module_reference/lambda_function/aws?version=${local.git_tag}"
}
13 changes: 6 additions & 7 deletions platform/sandbox/us-west-2/001/terraform.tfvars
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
create_package = true
create = true
handler = "app.lambda_handler"
cors = { allow_origins = ["*"] }
source_path = "../../../../../../../src/function/"
name = "platform_sample-uswest2-sandbox-001-fn-000"
environment_variables = {
create_package = true
create = true
handler = "app.lambda_handler"
cors = { allow_origins = ["*"] }
source_path = "../../../../../../../src/function/"
environment_variables = {
PAYLOAD = "Failover-West"
}
4 changes: 2 additions & 2 deletions platform/sandbox/us-west-2/001/terragrunt.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ include "root" {
}

locals {
git_tag = "1.0.3"
git_tag = "1.0.0"
}

terraform {
source = "tfr://terraform.registry.launch.nttdata.com/module_primitive/lambda_function/aws?version=${local.git_tag}"
source = "tfr://terraform.registry.launch.nttdata.com/module_reference/lambda_function/aws?version=${local.git_tag}"
}
47 changes: 32 additions & 15 deletions terragrunt.hcl
Original file line number Diff line number Diff line change
@@ -1,13 +1,25 @@

locals {
naming_prefix = "sample_lambda"
relative_path = path_relative_to_include()
path_parts = split("/", local.relative_path)
account_name = local.path_parts[1]
region = local.path_parts[2]
environment_instance = basename(local.relative_path)
bucket = "${replace(local.naming_prefix, "_", "-")}-${local.region}-${local.account_name}-${local.environment_instance}-tfstate"
dynamodb_table = "${local.naming_prefix}-${local.region}-${local.account_name}-${local.environment_instance}-tflocks"
# After initial apply, changes to these naming values will result in the creation of new state bucket(s) and dynamodb table(s)!
logical_product_family = "sample"
logical_product_service = "lambda"

# Don't modify the locals below this line.
name_dash = replace("${trimspace(local.logical_product_family)}_${trimspace(local.logical_product_service)}", "_", "-")
name_hash = substr(sha256(local.name_dash), 0, 8)
resource_names_strategy = local.account_name == "sandbox" ? "minimal_random_suffix" : "standard"
relative_path = path_relative_to_include()
path_parts = split("/", local.relative_path)
account_name = local.path_parts[1]
region = local.path_parts[2]
environment_instance = basename(local.relative_path)
git_branch = get_env("GIT_BRANCH", "")
current_user = get_env("USER", "")
bucket = "${local.name_dash}-${local.region}-${local.name_hash}-tfstate"
dynamodb_table = "${local.name_dash}-${local.region}-${local.name_hash}-tflocks"
repo_name = basename(abspath("${get_path_to_repo_root()}"))
state_filename_ephemeral = "${local.account_name}/${coalesce(local.git_branch, local.current_user)}/${local.environment_instance}/terraform.tfstate"
state_filename_persist = "${local.account_name}/${coalesce(local.git_branch, local.current_user)}/${local.environment_instance}/terraform.tfstate"
}

# Generate the AWS provider settings
Expand All @@ -21,7 +33,7 @@ provider "aws" {
default_tags {
tags = {
Organization = var.organization_tag
Repository = var.repository_tag
Repository = coalesce(var.repository_tag, "${basename(abspath(dirname(find_in_parent_folders("terragrunt.hcl"))))}")
CommitHash = var.commit_hash_tag
}
}
Expand All @@ -34,22 +46,25 @@ provider "aws" {
default_tags {
tags = {
Organization = var.organization_tag
Repository = var.repository_tag
Repository = coalesce(var.repository_tag, "${basename(abspath(dirname(find_in_parent_folders("terragrunt.hcl"))))}")
CommitHash = var.commit_hash_tag
}
}
}

variable "organization_tag" {
type = string
default = "launchbynttdata"
}

variable "repository_tag" {
type = string
default = ""
}

variable "commit_hash_tag" {
type = string
default = "RUN OUTSIDE PIPELINE"
}

EOF
Expand All @@ -64,15 +79,17 @@ remote_state {
}
config = {
bucket = "${local.bucket}"
key = "terraform.tfstate"
key = local.account_name == "sandbox" ? local.state_filename_ephemeral : local.state_filename_persist
region = "${local.region}"
encrypt = true
dynamodb_table = "${local.dynamodb_table}"
}
}

inputs = {
naming_prefix = local.naming_prefix
environment = local.account_name
region = local.region
}
logical_product_family = local.logical_product_family
logical_product_service = local.logical_product_service
class_env = local.account_name
region = local.region
resource_names_strategy = local.resource_names_strategy
}
Loading