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
6 changes: 6 additions & 0 deletions .github/workflows/cicd-3-deploy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,12 @@ jobs:
steps:
- name: "Checkout code"
uses: actions/checkout@v4
- name: "Deploy"
id: deploy
run: |
TF_ENV=dev make terraform-init
TF_ENV=dev make terraform-plan opts="-out=terraform.tfplan"
TF_ENV=dev make terraform-apply opts="-auto-approve terraform.tfplan"
# TODO: More jobs or/and steps here
# success:
# name: "Success notification"
Expand Down
9 changes: 7 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ We will increase appointment attendance and reduce the number of 'did not attend

### GitHub
- As per NHS guidelines, make your GitHub email private by going [here](https://github.com/settings/emails). There is a checkbox named "Keep my email addresses private". Note down your private email from this setting.
- Follow these [instructions](https://nhsd-confluence.digital.nhs.uk/display/CSP/How+to+access+GitHub).
- Follow these [instructions](https://nhsd-confluence.digital.nhs.uk/display/Vacc/Developer+setup%3A+Github).
- Remember to use your private email, noted above, in GitHub config 'user.email'.
- When on the step to create personal access tokens, remember to also tick 'workflow'. This will allow developers to update workflows
- Get your NHS GitHub username added to the VitA team to gain access to the repository
Expand Down Expand Up @@ -88,6 +88,11 @@ From NHS repository template:
```
npx playwright install
```
- **AWS CLI** - Install aws cli for local deployments.
```
brew install awscli
aws configure sso
```

### Local Configuration
1. Create environment variables file .env.local:
Expand Down Expand Up @@ -147,7 +152,7 @@ npm run test
```
- or with interactive developer UI
```
npm run e2e
npm run e2e:ui
```

### Run pre-commit hooks manually
Expand Down
Empty file.
84 changes: 84 additions & 0 deletions infrastructure/environments/dev/.terraform.lock.hcl

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions infrastructure/environments/dev/data.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
data "external" "git_branch" {
program = ["bash", "${path.module}/../../scripts/get_git_branch.sh"]
}
16 changes: 16 additions & 0 deletions infrastructure/environments/dev/locals.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
locals {
region = "eu-west-2"

project_identifier = "vaccinations-app"
project_identifier_shortcode = "vita"

environment = "dev"
git_branch = coalesce(data.external.git_branch.result.output, "na")
deploy_workspace = terraform.workspace == "default" ? "gh" : terraform.workspace

default_tags = {
ManagedBy = "Terraform"
Project = local.project_identifier
Environment = local.environment
}
}
7 changes: 7 additions & 0 deletions infrastructure/environments/dev/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
module "deploy" {
source = "../../modules/deploy_app"

open-next-path = "../../../.open-next"
prefix = "${local.deploy_workspace}-${local.git_branch}-${local.project_identifier_shortcode}"
default_tags = local.default_tags
}
24 changes: 24 additions & 0 deletions infrastructure/environments/dev/provider.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
terraform {
required_providers {
aws = {
source = "hashicorp/aws"
version = ">= 5.92.0"
}
}

backend "s3" {
bucket = "vaccinations-app-tfstate"
key = "terraform.tfstate"
region = "eu-west-2"

use_lockfile = true
encrypt = true
}
}

provider "aws" {
region = local.region
default_tags {
tags = local.default_tags
}
}
Empty file removed infrastructure/modules/.gitkeep
Empty file.
1 change: 1 addition & 0 deletions infrastructure/modules/deploy_app/data.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
data "aws_caller_identity" "current" {}
15 changes: 15 additions & 0 deletions infrastructure/modules/deploy_app/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
module "deploy_app" {
source = "RJPearson94/open-next/aws//modules/tf-aws-open-next-zone"
version = ">= 3.4.0,< 3.5.0"
open_next_version = "v3.5.3"

providers = {
aws.server_function = aws.server_function
aws.iam = aws.iam
aws.dns = aws.dns
aws.global = aws.global
}

prefix = "${var.prefix}-${data.aws_caller_identity.current.account_id}"
folder_path = var.open-next-path
}
28 changes: 28 additions & 0 deletions infrastructure/modules/deploy_app/provider.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
provider "aws" {
alias = "server_function"
default_tags {
tags = var.default_tags
}
}

provider "aws" {
alias = "iam"
default_tags {
tags = var.default_tags
}
}

provider "aws" {
alias = "dns"
default_tags {
tags = var.default_tags
}
}

provider "aws" {
alias = "global"
region = "us-east-1"
default_tags {
tags = var.default_tags
}
}
14 changes: 14 additions & 0 deletions infrastructure/modules/deploy_app/variables.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
variable "prefix" {
type = string
description = "Prefix to be applied to resources created"
}

variable "open-next-path" {
type = string
description = "Relative path to open next output directory"
}

variable "default_tags" {
type = map(string)
description = "Map of default key-value pair of tags to add to resources"
}
5 changes: 5 additions & 0 deletions infrastructure/scripts/get_git_branch.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/bash

RAW_BRANCH_NAME=$(git rev-parse --abbrev-ref HEAD)
BRANCH_NAME=$(echo "$RAW_BRANCH_NAME" | sed 's|/|-|g' | tr '[:upper:]' '[:lower:]')
echo "{\"output\": \"${BRANCH_NAME:0:10}\"}"
Loading