Skip to content

Commit

Permalink
Merge branch 'main' into MLPAB-1685
Browse files Browse the repository at this point in the history
  • Loading branch information
acsauk authored Jan 25, 2024
2 parents b0690f6 + 147a17c commit e244af4
Show file tree
Hide file tree
Showing 60 changed files with 276 additions and 345 deletions.
17 changes: 15 additions & 2 deletions .github/workflows/terraform_account_job.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ on:
aws_secret_access_key:
description: 'AWS Secret Access Key'
required: true

env:
TFLINT_VERSION: 0.50.1

jobs:
terraform_account_workflow:
name: "${{ inputs.workspace_name }} account deployment"
Expand Down Expand Up @@ -49,13 +53,22 @@ jobs:
aws-region: eu-west-1
role-duration-seconds: 3600
role-session-name: OPGModernisingLPATerraformGithubAction
- uses: terraform-linters/setup-tflint@v4
name: Setup TFLint
with:
tflint_version: v${{ env.TFLINT_VERSION }}

- name: Lint Terraform
id: tf_lint
- name: Check formatting
id: tf_fmt
run: terraform fmt -check -recursive
working-directory: ./terraform/account
continue-on-error: true

- name: Lint Terraform
id: tf_lint
run: tflint --recursive
working-directory: ./terraform/account

- name: Terraform Init
run: terraform init -input=false
working-directory: ./terraform/account
Expand Down
16 changes: 14 additions & 2 deletions .github/workflows/terraform_environment_job.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,9 @@ permissions:
pull-requests: write
issues: write

env:
TFLINT_VERSION: 0.50.1

jobs:
terraform_environment_workflow:
name: "${{ inputs.workspace_name }} environment deployment"
Expand Down Expand Up @@ -97,13 +100,22 @@ jobs:
- uses: webfactory/ssh-agent@v0.8.0
with:
ssh-private-key: ${{ secrets.ssh_deploy_key }}
- uses: terraform-linters/setup-tflint@v4
name: Setup TFLint
with:
tflint_version: v${{ env.TFLINT_VERSION }}

- name: Lint Terraform
id: tf_lint
- name: Check formatting
id: tf_fmt
run: terraform fmt -check -recursive
working-directory: ./terraform/environment
continue-on-error: true

- name: Lint Terraform
id: tf_lint
run: tflint --recursive
working-directory: ./terraform/environment

- name: Terraform Init
run: terraform init -input=false
working-directory: ./terraform/environment
Expand Down
12 changes: 7 additions & 5 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# See https://pre-commit.com/hooks.html for more hooks
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.3.0
rev: v4.5.0
hooks:
- id: trailing-whitespace # trims trailing whitespace.
- id: end-of-file-fixer # ensures that a file is either empty, or ends with one newline.
Expand All @@ -19,19 +19,21 @@ repos:
args:
- --branch=main
- repo: https://github.com/antonbabenko/pre-commit-terraform
rev: v1.76.0
rev: v1.86.0
hooks:
- id: terraform_fmt
# - id: terraform_validate
# exclude: region/[^/]+$.
- id: terraform_tflint
args:
- --args=--recursive

- repo: https://github.com/dnephin/pre-commit-golang
rev: v0.5.1
hooks:
- id: go-fmt # Runs gofmt
- id: go-imports # Runs gofmt
- id: go-mod-tidy # Tidies up and removes unused requires in go.mod using go mod tidy
- repo: https://github.com/renovatebot/pre-commit-hooks
rev: 32.221.1
rev: 37.150.1
hooks:
- id: renovate-config-validator
- repo: https://github.com/Yelp/detect-secrets
Expand Down
12 changes: 12 additions & 0 deletions terraform/account/region/data_sources.tf
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,15 @@ data "aws_kms_alias" "secrets_manager" {
name = var.secrets_manager_kms_key_alias
provider = aws.region
}

data "aws_region" "current" {
provider = aws.region
}

data "aws_caller_identity" "current" {
provider = aws.region
}

data "aws_default_tags" "current" {
provider = aws.region
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ resource "aws_lambda_function" "lambda_function" {
}

vpc_config {
subnet_ids = data.aws_subnet.application.*.id
subnet_ids = data.aws_subnet.application[*].id
security_group_ids = [
data.aws_security_group.lambda_egress.id
]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
variable "ecr_image_uri" {
type = string
description = "URI of ECR image to use for Lambda"
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ terraform {

required_providers {
aws = {
source = "hashicorp/aws"
source = "hashicorp/aws"
version = "~> 5.32.0"
configuration_aliases = [
aws.region,
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ terraform {

required_providers {
aws = {
source = "hashicorp/aws"
source = "hashicorp/aws"
version = "~> 5.32.0"
configuration_aliases = [
aws.region,
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,6 @@ data "aws_region" "current" {
provider = aws.region
}

data "aws_caller_identity" "current" {
provider = aws.region
}

data "aws_default_tags" "current" {
provider = aws.region
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ terraform {

required_providers {
aws = {
source = "hashicorp/aws"
source = "hashicorp/aws"
version = "~> 5.32.0"
configuration_aliases = [
aws.region,
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ terraform {

required_providers {
aws = {
source = "hashicorp/aws"
source = "hashicorp/aws"
version = "~> 5.32.0"
}
}
}
26 changes: 0 additions & 26 deletions terraform/account/region/terraform.tf

This file was deleted.

15 changes: 15 additions & 0 deletions terraform/account/region/versions.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
terraform {
required_version = ">= 1.5.2"

required_providers {
aws = {
source = "hashicorp/aws"
version = "~> 5.32.0"
configuration_aliases = [
aws.region,
aws.management,
aws.global,
]
}
}
}
2 changes: 1 addition & 1 deletion terraform/account/sqs_kms.tf
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ resource "aws_kms_key" "sqs" {
description = "${local.default_tags.application} SQS encryption key"
deletion_window_in_days = 10
enable_key_rotation = true
policy = local.account.account_name == "development" ? data.aws_iam_policy_document.sns_kms_merged.json : data.aws_iam_policy_document.sns_kms.json
policy = local.account.account_name == "development" ? data.aws_iam_policy_document.sqs_kms_merged.json : data.aws_iam_policy_document.sns_kms.json
multi_region = true
provider = aws.eu_west_1
}
Expand Down
24 changes: 0 additions & 24 deletions terraform/account/terraform.tf
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,6 @@ variable "default_role" {
type = string
default = "modernising-lpa-ci"
}
variable "management_role" {
type = string
default = "modernising-lpa-ci"
}

provider "aws" {
alias = "eu_west_1"
Expand Down Expand Up @@ -94,30 +90,10 @@ data "aws_region" "eu_west_1" {
provider = aws.eu_west_1
}

data "aws_caller_identity" "eu_west_1" {
provider = aws.eu_west_1
}

data "aws_default_tags" "eu_west_1" {
provider = aws.eu_west_1
}

data "aws_region" "eu_west_2" {
provider = aws.eu_west_2
}

data "aws_caller_identity" "eu_west_2" {
provider = aws.eu_west_2
}

data "aws_default_tags" "eu_west_2" {
provider = aws.eu_west_2
}

data "aws_region" "global" {
provider = aws.global
}

data "aws_caller_identity" "global" {
provider = aws.global
}
Expand Down
3 changes: 3 additions & 0 deletions terraform/environment/global/data_sources.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
data "aws_default_tags" "current" {
provider = aws.global
}
28 changes: 0 additions & 28 deletions terraform/environment/global/terraform.tf

This file was deleted.

17 changes: 17 additions & 0 deletions terraform/environment/global/versions.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
terraform {
required_version = ">= 1.5.2"

required_providers {
aws = {
source = "hashicorp/aws"
version = "~> 5.32.0"
configuration_aliases = [
aws.global,
]
}
pagerduty = {
source = "PagerDuty/pagerduty"
version = "~> 3.4.0"
}
}
}
5 changes: 0 additions & 5 deletions terraform/environment/parameters.tf
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,3 @@ resource "aws_ssm_parameter" "dns_target_region" {
ignore_changes = [value]
}
}

data "aws_ssm_parameter" "dns_target_region" {
provider = aws.management_global
name = aws_ssm_parameter.dns_target_region.name
}
12 changes: 12 additions & 0 deletions terraform/environment/region/data_sources.tf
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,15 @@ data "aws_iam_role" "sns_failure_feedback" {
name = "SNSFailureFeedback"
provider = aws.global
}

data "aws_region" "current" {
provider = aws.region
}

data "aws_caller_identity" "current" {
provider = aws.region
}

data "aws_default_tags" "current" {
provider = aws.region
}
8 changes: 4 additions & 4 deletions terraform/environment/region/ecs.tf
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ module "app" {
public_access_enabled = var.public_access_enabled
network = {
vpc_id = data.aws_vpc.main.id
application_subnets = data.aws_subnet.application.*.id
public_subnets = data.aws_subnet.public.*.id
application_subnets = data.aws_subnet.application[*].id
public_subnets = data.aws_subnet.public[*].id
}
uploads_s3_bucket = {
bucket_name = module.uploads_s3_bucket.bucket.id
Expand Down Expand Up @@ -78,8 +78,8 @@ module "mock_onelogin" {
redirect_base_url = var.app_env_vars.auth_redirect_base_url
network = {
vpc_id = data.aws_vpc.main.id
application_subnets = data.aws_subnet.application.*.id
public_subnets = data.aws_subnet.public.*.id
application_subnets = data.aws_subnet.application[*].id
public_subnets = data.aws_subnet.public[*].id
}
aws_service_discovery_private_dns_namespace = {
id = aws_service_discovery_private_dns_namespace.mock_one_login.id
Expand Down
1 change: 0 additions & 1 deletion terraform/environment/region/event_received.tf
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ data "aws_ecr_repository" "event_received" {

module "event_received" {
source = "./modules/event_received"
lambda_function_image_ecr_arn = data.aws_ecr_repository.event_received.arn
lambda_function_image_ecr_url = data.aws_ecr_repository.event_received.repository_url
lambda_function_image_tag = var.app_service_container_version
event_bus_name = module.event_bus.event_bus.name
Expand Down
7 changes: 7 additions & 0 deletions terraform/environment/region/modules/app/data_sources.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
data "aws_region" "current" {
provider = aws.region
}

data "aws_default_tags" "current" {
provider = aws.region
}
Loading

0 comments on commit e244af4

Please sign in to comment.