Skip to content

Commit

Permalink
Add staging environment (#158)
Browse files Browse the repository at this point in the history
* ci: add staging environement on amplify, modify minor prod settings (names)

* ci: update amplify values

* ci: fix for invalid value for stage

* ci: linting
  • Loading branch information
daine authored Jul 28, 2022
1 parent 03a6c5f commit d8cb8f4
Show file tree
Hide file tree
Showing 3 changed files with 117 additions and 6 deletions.
12 changes: 7 additions & 5 deletions infrastructure/terragrunt/aws/app/amplify.tf
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@ resource "aws_amplify_app" "learning_resources" {
# Enable auto build for the created branch.
enable_auto_build = true
enable_pull_request_preview = true
pull_request_environment_name = "pr"
stage = "PULL_REQUEST"
pull_request_environment_name = "rc"
stage = "PRODUCTION"
}
}

Expand All @@ -68,13 +68,15 @@ resource "aws_amplify_branch" "main" {
branch_name = "main"

framework = "NuxtJS"
stage = "BETA"

display_name = "beta"
# Could be one of: PRODUCTION, BETA, DEVELOPMENT, EXPERIMENTAL, PULL_REQUEST
stage = "PRODUCTION"

display_name = "pilot"

enable_pull_request_preview = true

pull_request_environment_name = "PULL_REQUEST"
pull_request_environment_name = "RELEASE"

# environment_variables = {
# }
Expand Down
110 changes: 110 additions & 0 deletions infrastructure/terragrunt/aws/app/amplify_staging.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
resource "aws_amplify_app" "learning_resources_staging" {
name = "Learning Resources (Staging)"
repository = "https://github.com/cds-snc/resources-ressources"

# Github personal access token
# -- needed when setting up amplify or making changes
access_token = var.gh_access_token

build_spec = <<-EOT
version: 1
frontend:
phases:
preBuild:
commands:
- cd app
- cp .contentful.json.sample .contentful.json
- npm install
build:
commands:
- npm run generate
artifacts:
baseDirectory: app/dist
files:
- '**/*'
cache:
paths:
- node_modules/**/*
EOT

# The default rewrites and redirects added by the Amplify Console.
custom_rule {
source = "/<*>"
status = "404"
target = "/index.html"
}

environment_variables = {
ENV = "staging"
DOMAIN_EN = "en.staging.learning-resources.cdssandbox.xyz"
DOMAIN_FR = "fr.staging.learning-resources.cdssandbox.xyz"
contentful_cda_access_token = var.contentful_cda_access_token
GOOGLE_ANALYTICS_ID = "" # Do not collect data
}


enable_auto_branch_creation = true
enable_branch_auto_deletion = true

# The default patterns added by the Amplify Console.
auto_branch_creation_patterns = [
"feature*/",
"release*",
"fix*",
"ci*"
]

auto_branch_creation_config {
# Enable auto build for the created branch.
enable_auto_build = true
enable_pull_request_preview = true
pull_request_environment_name = "pr"
stage = "PULL_REQUEST"
}
}

resource "aws_amplify_branch" "staging" {
app_id = aws_amplify_app.learning_resources_staging.id
branch_name = "staging"

framework = "NuxtJS"

# Could be one of: PRODUCTION, BETA, DEVELOPMENT, EXPERIMENTAL, PULL_REQUEST
stage = "BETA"

display_name = "staging"

enable_pull_request_preview = true

pull_request_environment_name = "PULL_REQUEST"

# environment_variables = {
# }
}

resource "aws_amplify_domain_association" "learning_resources_staging" {
app_id = aws_amplify_app.learning_resources_staging.id
domain_name = "staging.learning-resources.cdssandbox.xyz"

wait_for_verification = false

sub_domain {
branch_name = aws_amplify_branch.staging.branch_name
prefix = ""
}

sub_domain {
branch_name = aws_amplify_branch.staging.branch_name
prefix = "en"
}

sub_domain {
branch_name = aws_amplify_branch.staging.branch_name
prefix = "fr"
}

sub_domain {
branch_name = aws_amplify_branch.staging.branch_name
prefix = "www"
}
}
1 change: 0 additions & 1 deletion infrastructure/terragrunt/env/staging/app/terragrunt.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ inputs = {
domain_name = "learning-resources.cdssandbox.xyz"
app_hosted_zone_id = dependency.hosted_zone.outputs.app_zone_id
app_domain_name = "app.learning-resources.cdssandbox.xyz"

}

include {
Expand Down

0 comments on commit d8cb8f4

Please sign in to comment.