Skip to content

Commit 6021430

Browse files
committed
Refactor
1 parent e3c5e74 commit 6021430

File tree

20 files changed

+174
-136
lines changed

20 files changed

+174
-136
lines changed

azure/templates/post-deploy.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,8 @@ steps:
6161
cd terraform
6262
6363
make init
64-
make apply aws_account_no=${aws_account_no} environment=$workspace
64+
make plan aws_account_no=${aws_account_no} environment=$workspace
65+
# make apply aws_account_no=${aws_account_no} environment=$workspace
6566
6667
AWS_DOMAIN_NAME=$(make -s output name=service_domain_name)
6768
IMMS_DELTA_TABLE_NAME=$(make -s output name=imms_delta_table_name)

terraform/Makefile

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
-include .env
22

3-
interactionId=$(environment)
4-
5-
aws_profile = apim-dev
3+
interactionId = $(ENVIRONMENT)# to change to lower case
4+
environment = $(ENVIRONMENT)
5+
aws_profile = $(AWS_PROFILE)#apim-dev # Leave this here for pipeline
66
tf_cmd = AWS_PROFILE=$(aws_profile) terraform
77

88
project_name = immunisation
99
project_short_name = imms
10-
state_bucket = $(project_name)-$(APIGEE_ENVIRONMENT)-terraform-state-files
10+
state_bucket = $(BUCKET_NAME)#$(project_name)-$(APIGEE_ENVIRONMENT)-terraform-state-files
1111
tf_state= -backend-config="bucket=$(state_bucket)"
1212

1313
tf_vars= -var="project_name=$(project_name)" -var="project_short_name=$(project_short_name)"
@@ -20,11 +20,14 @@ lock-provider:
2020
$(tf_cmd) providers lock -platform=darwin_arm64 -platform=darwin_amd64 -platform=linux_amd64 -platform=windows_amd64
2121

2222
workspace:
23-
$(tf_cmd) workspace new $(environment) || $(tf_cmd) workspace select $(environment) && echo "Switched to workspace/environment: $(environment)"
23+
$(tf_cmd) workspace new $(ENVIRONMENT) || $(tf_cmd) workspace select $(ENVIRONMENT) && echo "Switched to workspace/environment: $(ENVIRONMENT)"
2424

2525
init:
2626
$(tf_cmd) init $(tf_state) -upgrade $(tf_vars)
2727

28+
init-reconfigure:
29+
$(tf_cmd) init $(tf_state) -upgrade $(tf_vars) -reconfigure
30+
2831
plan: workspace
2932
$(tf_cmd) plan $(tf_vars)
3033

@@ -40,7 +43,7 @@ clean:
4043
destroy: workspace
4144
$(tf_cmd) destroy $(tf_vars) -auto-approve
4245
$(tf_cmd) workspace select default
43-
$(tf_cmd) workspace delete $(environment)
46+
$(tf_cmd) workspace delete $(ENVIRONMENT)
4447

4548
output:
4649
$(tf_cmd) output -raw $(name)

terraform/api_gateway/acm_cert.tf

Lines changed: 22 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,33 @@
11
resource "aws_acm_certificate" "service_certificate" {
2-
domain_name = var.api_domain_name
3-
subject_alternative_names = []
4-
validation_method = "DNS"
2+
domain_name = var.api_domain_name
3+
subject_alternative_names = []
4+
validation_method = "DNS"
55

6-
lifecycle {
7-
create_before_destroy = true
8-
}
6+
lifecycle {
7+
create_before_destroy = true
8+
}
99
}
1010

1111
resource "aws_acm_certificate_validation" "service_certificate" {
12-
certificate_arn = aws_acm_certificate.service_certificate.arn
13-
validation_record_fqdns = [for record in aws_route53_record.dns_validation : record.fqdn]
12+
certificate_arn = aws_acm_certificate.service_certificate.arn
13+
validation_record_fqdns = [for record in aws_route53_record.dns_validation : record.fqdn]
14+
depends_on = [aws_acm_certificate.service_certificate, aws_route53_record.dns_validation]
1415
}
1516

1617
resource "aws_route53_record" "dns_validation" {
17-
for_each = {
18-
for dvo in aws_acm_certificate.service_certificate.domain_validation_options : dvo.domain_name => {
19-
name = dvo.resource_record_name
20-
record = dvo.resource_record_value
21-
type = dvo.resource_record_type
22-
}
18+
for_each = {
19+
for dvo in aws_acm_certificate.service_certificate.domain_validation_options : dvo.domain_name => {
20+
name = dvo.resource_record_name
21+
record = dvo.resource_record_value
22+
type = dvo.resource_record_type
2323
}
24+
}
2425

25-
allow_overwrite = true
26-
name = each.value.name
27-
records = [each.value.record]
28-
ttl = 60
29-
type = each.value.type
30-
zone_id = var.zone_id
26+
allow_overwrite = true
27+
name = each.value.name
28+
records = [each.value.record]
29+
ttl = 60
30+
type = each.value.type
31+
zone_id = var.zone_id
32+
depends_on = [aws_acm_certificate.service_certificate]
3133
}

terraform/api_gateway/mtls_cert.tf

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,21 +4,21 @@ locals {
44
}
55

66
data "aws_s3_bucket" "cert_storage" {
7-
bucket = "imms-fhir-${local.config_env}-cert-storage"
7+
bucket = "imms-fhir-${var.config_env}-cert-storage"
88
}
99

1010
data "aws_s3_object" "cert" {
1111
bucket = data.aws_s3_bucket.cert_storage.bucket
12-
key = local.truststore_file_name
12+
key = local.truststore_file_name
1313
}
1414

1515
resource "aws_s3_bucket" "truststore_bucket" {
16-
bucket = "${var.prefix}-truststores"
16+
bucket = "${var.prefix}-truststores"
1717
force_destroy = true
1818
}
1919

2020
resource "aws_s3_object_copy" "copy_cert_from_storage" {
2121
bucket = aws_s3_bucket.truststore_bucket.bucket
2222
key = local.truststore_file_name
23-
source ="${data.aws_s3_object.cert.bucket}/${local.truststore_file_name}"
23+
source = "${data.aws_s3_object.cert.bucket}/${local.truststore_file_name}"
2424
}

terraform/api_gateway/variables.tf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ variable "zone_id" {}
44
variable "api_domain_name" {}
55
variable "environment" {}
66
variable "oas" {}
7+
variable "config_env" {}
78

89
locals {
9-
environment = terraform.workspace == "green" ? "prod" : terraform.workspace == "blue" ? "prod" : terraform.workspace
10-
config_env = local.environment == "prod" ? "prod" : "dev"
10+
environment = terraform.workspace == "green" ? "prod" : terraform.workspace == "blue" ? "prod" : terraform.workspace
1111
}

terraform/configs.tf

Lines changed: 0 additions & 6 deletions
This file was deleted.

terraform/endpoints.tf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,7 @@ module "api_gateway" {
114114
api_domain_name = local.service_domain_name
115115
environment = local.environment
116116
oas = local.oas
117+
config_env = local.config_env
117118
}
118119

119120
resource "aws_lambda_permission" "api_gw" {
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
environment = "int"
2+
sub_environment = "blue"
3+
immunisation_account_id = "084828561157"
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
environment = "int"
2+
sub_environment = "green"
3+
immunisation_account_id = "084828561157"
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
environment = "int"
2+
sub_environment = "blue"
3+
immunisation_account_id = "084828561157"

0 commit comments

Comments
 (0)