Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

aiva2/CCM-5680 IAM Webauth infra #13

Merged
merged 23 commits into from
Aug 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
5ad5b06
CCM-5680 setup terraform components
aidenvaines-bjss Jul 16, 2024
85ee255
CCM-5680 use tool-versions
aidenvaines-bjss Jul 17, 2024
07ff509
Adding CW dns query logs
aidenvaines-bjss Jul 17, 2024
fd9b83d
bumping tf versions
aidenvaines-bjss Jul 17, 2024
b40c7db
Missing variable
aidenvaines-bjss Jul 17, 2024
25f15cc
CCM-5680 adding base amplify terraform
aidenvaines-bjss Jul 18, 2024
202eed5
CCM-5680 adding tfsec and fixing fmt
aidenvaines-bjss Jul 18, 2024
7337983
Merge pull request #8 from NHSDigital/dependabot/pip/scripts/docker/e…
aidenvaines-bjss Jul 23, 2024
4f04524
CCM-5836 adding Pr workflows
aidenvaines-bjss Jul 22, 2024
aa99b78
fixing a singleton resource to allow for multi deployment
aidenvaines-bjss Jul 22, 2024
3239f22
Bump werkzeug in /scripts/docker/examples/python/assets/hello_world
dependabot[bot] Jul 22, 2024
7f7c1bd
Merge pull request #8 from NHSDigital/dependabot/pip/scripts/docker/e…
aidenvaines-bjss Jul 23, 2024
da5973e
CCM-5836 fix tf fmt
aidenvaines-bjss Jul 23, 2024
29b894d
Bootstrap is in internal repo
aidenvaines-bjss Jul 23, 2024
fcf0a92
CCM-5836 tidy
aidenvaines-bjss Jul 23, 2024
b4684b5
CCM-5836 fix branch-ref
aidenvaines-bjss Jul 23, 2024
f1d09c7
CCM-5836 fix branch-ref
aidenvaines-bjss Jul 23, 2024
23eecae
CCM-5836 tidy
aidenvaines-bjss Jul 23, 2024
70915fc
CCM-5836 Drop the cognito bits that dont work and minor fixes
aidenvaines-bjss Aug 1, 2024
6bdabb6
spelling
aidenvaines-bjss Aug 1, 2024
69eb0f6
spelling
aidenvaines-bjss Aug 1, 2024
5ddc24f
CCM-5836 fix git head refs
aidenvaines-bjss Aug 1, 2024
10d5540
CCM-5836 fix git head refs
aidenvaines-bjss Aug 1, 2024
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
4 changes: 2 additions & 2 deletions .github/workflows/pr_create_dynamic_env.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@ jobs:

DISPATCH_EVENT=$(jq -ncM \
--arg infraRepoName "${this_repo_name}" \
--arg releaseVersion "${{ github.ref_name }}" \
--arg releaseVersion "${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}" \
--arg targetEnvironment "pr${{ github.event.number }}" \
--arg targetAccountGroup "nhs-notify-iam-dev" \
--arg targetComponent "branch" \
--arg terraformAction "apply" \
--arg overrides "branch_name=${{ github.ref_name }}" \
--arg overrides "branch_name=${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}" \
'{ "ref": "main",
"inputs": {
"infraRepoName": $infraRepoName,
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/pr_merge.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@ jobs:

DISPATCH_EVENT=$(jq -ncM \
--arg infraRepoName "${this_repo_name}" \
--arg releaseVersion "${{ github.ref_name }}" \
--arg releaseVersion "${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}" \
--arg targetEnvironment "pr${{ github.event.number }}" \
--arg targetAccountGroup "nhs-notify-iam-dev" \
--arg targetComponent "branch" \
--arg terraformAction "destroy" \
--arg overrides "branch_name=${{ github.ref_name }}" \
--arg overrides "branch_name=${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}" \
'{ "ref": "main",
"inputs": {
"infraRepoName": $infraRepoName,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
resource "null_resource" "remove_amplify_branch" {
# Despite destroying the resource, apparently Amplify thinks we want to keep the branch resrouce around
triggers = {
csi = local.csi
amplify_app_id = local.iam.amplify["id"]
amplify_branch_name = module.amplify_branch.name
}

provisioner "local-exec" {
when = destroy
command = "aws amplify delete-branch --app-id ${self.triggers.amplify_app_id} --branch-name ${self.triggers.amplify_branch_name}"
}
}
14 changes: 0 additions & 14 deletions infrastructure/terraform/components/iam/acm_certificate.tf

This file was deleted.

2 changes: 1 addition & 1 deletion infrastructure/terraform/components/iam/amplify_app.tf
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ resource "aws_amplify_app" "main" {

environment_variables = {
USER_POOL_ID = aws_cognito_user_pool.main.id
# HOSTED_LOGIN_DOMAIN = "auth.${var.environment}.${local.acct.dns_zone["name"]}"
# HOSTED_LOGIN_DOMAIN = "auth.${local.acct.dns_zone["name"]}"
NOTIFY_GROUP = var.group
NOTIFY_ENVIRONMENT = var.environment
NOTIFY_DOMAIN_NAME = local.acct.dns_zone["name"]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ data "terraform_remote_state" "acct" {
var.project,
var.aws_account_id,
"eu-west-2",
"main"
var.environment
)

region = "eu-west-2"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
module "amplify_branch" {
source = "../../modules/amp_branch"

name = var.environment
name = "main"
sidnhs marked this conversation as resolved.
Show resolved Hide resolved
aws_account_id = var.aws_account_id
component = var.component
environment = var.environment
Expand All @@ -12,7 +12,8 @@ module "amplify_branch" {
cognito_user_pool_client_id = aws_cognito_user_pool_client.main.user_pool_id
cognito_user_pool_identity_provider_names = aws_cognito_user_pool_client.main.supported_identity_providers
amplify_app_id = aws_amplify_app.main.id
branch = var.environment
branch = "main"
domain_name = local.acct.dns_zone["name"]
subdomain = var.environment
enable_auto_deploy = true
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ resource "aws_amplify_branch" "main" {
app_id = var.amplify_app_id
branch_name = var.branch
display_name = var.name
enable_pull_request_preview = false # PR previews are not supported for public repos
enable_pull_request_preview = false
enable_auto_build = var.enable_auto_deploy

environment_variables = {
USER_POOL_CLIENT_ID = var.cognito_user_pool_client_id
Expand Down
12 changes: 9 additions & 3 deletions infrastructure/terraform/modules/amp_branch/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -61,18 +61,18 @@ variable "name" {
}

variable "cognito_user_pool_client_id" {
description = "Cognito User Pool client ID"
type = string
description = "Cognito User Pool client ID"
}

variable "cognito_user_pool_identity_provider_names" {
description = "A list of Cognito IDP names"
type = list(string)
description = "A list of Cognito IDP names"
}

variable "amplify_app_id" {
description = "Amplify application ID"
type = string
description = "Amplify application ID"
}

variable "branch" {
Expand All @@ -90,3 +90,9 @@ variable "subdomain" {
default = "main"
description = "Subdomain used as the branch alias"
}

variable "enable_auto_deploy" {
type = bool
description = "Enable the auto deployment of the branch code as well as just the resources for it"
default = false
}
46 changes: 0 additions & 46 deletions scripts/terraform/examples/terraform-state-aws-s3/main.tf

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

5 changes: 5 additions & 0 deletions scripts/terraform/terraform.mk
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@
# Custom implementation - implementation of a make target should not exceed 5 lines of effective code.
# In most cases there should be no need to modify the existing make targets.

# TF_ENV ?= dev
# STACK ?= ${stack}
# TERRAFORM_STACK ?= $(or ${STACK}, infrastructure/terraform)
# dir ?= ${TERRAFORM_STACK}

terraform-init: # Initialise Terraform - optional: terraform_dir|dir=[path to a directory where the command will be executed, relative to the project's top-level directory, default is one of the module variables or the example directory, if not set], terraform_opts|opts=[options to pass to the Terraform init command, default is none/empty] @Development
make _terraform cmd="init" \
dir=$(or ${terraform_dir}, ${dir}) \
Expand Down
Loading