Skip to content

Commit 8421669

Browse files
authored
Revert "Add cronjob to run org list sync"
1 parent ce36f44 commit 8421669

11 files changed

Lines changed: 15 additions & 269 deletions

File tree

infra/deployments/forms/forms-admin/main.tf

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ module "forms_admin" {
2525
analytics_enabled = var.forms_admin_settings.analytics_enabled
2626
act_as_user_enabled = var.forms_admin_settings.act_as_user_enabled
2727
enable_mailchimp_sync = var.forms_admin_settings.synchronize_to_mailchimp
28-
enable_organisations_sync = var.forms_admin_settings.synchronize_orgs_from_govuk
2928
deploy_account_id = var.deploy_account_id
3029
describe_none_of_the_above_enabled = var.forms_admin_settings.describe_none_of_the_above_enabled
3130
vpc_id = data.terraform_remote_state.forms_environment.outputs.vpc_id

infra/deployments/forms/inputs.tf

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,6 @@ variable "forms_admin_settings" {
141141
act_as_user_enabled = bool
142142
govuk_app_domain = string
143143
synchronize_to_mailchimp = bool
144-
synchronize_orgs_from_govuk = bool
145144
describe_none_of_the_above_enabled = bool
146145
})
147146
nullable = false

infra/deployments/forms/pipelines/buildspecs/update-orgs-sync-task/update-orgs-sync-task.yml

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

infra/deployments/forms/pipelines/deploy-forms-admin-container.tf

Lines changed: 0 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -251,35 +251,6 @@ resource "aws_codepipeline" "deploy_admin_container" {
251251
}
252252
}
253253

254-
dynamic "action" {
255-
for_each = var.forms_admin_settings.synchronize_orgs_from_govuk ? [1] : []
256-
content {
257-
name = "update-orgs-sync-task-definition"
258-
category = "Build"
259-
owner = "AWS"
260-
provider = "CodeBuild"
261-
version = "1"
262-
run_order = 2
263-
input_artifacts = ["buildspec_source"]
264-
# AWS requires an input artifact; using buildspec_source as a relevant default.
265-
configuration = {
266-
ProjectName = module.update_orgs_sync_task_definition[0].name
267-
EnvironmentVariables = jsonencode([
268-
{
269-
name = "TASK_DEFINITION_NAME"
270-
value = "${var.environment_name}_forms-admin_organisations_sync"
271-
type = "PLAINTEXT"
272-
},
273-
{
274-
name = "IMAGE_URI"
275-
value = "#{variables.container_image_uri}"
276-
type = "PLAINTEXT"
277-
}
278-
])
279-
}
280-
}
281-
}
282-
283254
# It isn't possible to conditionally skip or disable an action in CodePipeline
284255
# but we need to be able to do so because we can't run the end-to-end tests in the user-research
285256
# environment. We don't want to make the end-to-end tests module responsible for skipping itself
@@ -358,19 +329,6 @@ module "update_mailchimp_sync_task_definition" {
358329
codebuild_service_role_arn = data.aws_iam_role.deployer_role.arn
359330
}
360331

361-
module "update_orgs_sync_task_definition" {
362-
count = var.forms_admin_settings.synchronize_orgs_from_govuk ? 1 : 0
363-
364-
source = "../../../modules/code-build-build"
365-
project_name = "update_orgs_sync_task_definition_${var.environment_name}"
366-
project_description = "Update orgs-sync task definition with new container image"
367-
environment = var.environment_name
368-
artifact_store_arn = module.artifact_bucket.arn
369-
buildspec = file("${path.root}/buildspecs/update-orgs-sync-task/update-orgs-sync-task.yml")
370-
log_group_name = "codebuild/update_orgs_sync_task_definition_${var.environment_name}"
371-
codebuild_service_role_arn = data.aws_iam_role.deployer_role.arn
372-
}
373-
374332
module "generate_forms_admin_container_image_defs" {
375333
source = "../../../modules/code-build-build"
376334
project_name = "generate_forms_admin_container_image_defs_${var.environment_name}"

infra/deployments/forms/tfvars/dev.tfvars

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,6 @@ forms_admin_settings = {
7979
analytics_enabled = true
8080
act_as_user_enabled = true
8181
govuk_app_domain = "integration.publishing.service.gov.uk"
82-
synchronize_orgs_from_govuk = false
8382
synchronize_to_mailchimp = false
8483
describe_none_of_the_above_enabled = true
8584
}

infra/deployments/forms/tfvars/production.tfvars

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,6 @@ forms_admin_settings = {
136136
act_as_user_enabled = false
137137
govuk_app_domain = "publishing.service.gov.uk"
138138
synchronize_to_mailchimp = true
139-
synchronize_orgs_from_govuk = true
140139
describe_none_of_the_above_enabled = false
141140
}
142141
forms_product_page_settings = {

infra/deployments/forms/tfvars/staging.tfvars

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ forms_admin_settings = {
4444
analytics_enabled = true
4545
act_as_user_enabled = true
4646
govuk_app_domain = "staging.publishing.service.gov.uk"
47-
synchronize_orgs_from_govuk = false
4847
synchronize_to_mailchimp = false
4948
describe_none_of_the_above_enabled = false
5049
}

infra/deployments/forms/tfvars/user-research.tfvars

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@ forms_admin_settings = {
4242
analytics_enabled = false
4343
act_as_user_enabled = false
4444
govuk_app_domain = ""
45-
synchronize_orgs_from_govuk = false
4645
synchronize_to_mailchimp = false
4746
describe_none_of_the_above_enabled = false
4847
}

infra/modules/forms-admin/mailchimp-sync.tf

Lines changed: 15 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ locals {
2121
)
2222
}
2323

24-
resource "aws_ecs_task_definition" "mailchimp_cron_job" {
24+
resource "aws_ecs_task_definition" "cron_job" {
2525
count = var.enable_mailchimp_sync ? 1 : 0
2626

2727
family = "${var.env_name}_forms-admin_mailchimp_sync"
@@ -46,27 +46,27 @@ resource "aws_ecs_task_definition" "mailchimp_cron_job" {
4646
##
4747
# EventBridge
4848
##
49-
resource "aws_cloudwatch_event_rule" "sync_mailchimp_cron_job" {
49+
resource "aws_cloudwatch_event_rule" "sync_cron_job" {
5050
count = var.enable_mailchimp_sync ? 1 : 0
5151

52-
name = "${var.env_name}-forms-admin-mailchimp-sync-cron"
52+
name = "${var.env_name}-forms-admin-sync-cron"
5353
description = "Trigger the forms-admin MailChimp synchronisation on a schedule"
5454
schedule_expression = "cron(30 10 * * ? *)" # 10:30AM daily. In office hours so that we can respond to failures
5555
}
5656

57-
resource "aws_cloudwatch_event_target" "ecs_mailchimp_sync_job" {
57+
resource "aws_cloudwatch_event_target" "ecs_sync_job" {
5858
count = var.enable_mailchimp_sync ? 1 : 0
5959

6060
arn = var.ecs_cluster_arn
61-
rule = aws_cloudwatch_event_rule.sync_mailchimp_cron_job[0].name
62-
role_arn = aws_iam_role.ecs_mailchimp_cron_scheduler[0].arn
61+
rule = aws_cloudwatch_event_rule.sync_cron_job[0].name
62+
role_arn = aws_iam_role.ecs_cron_scheduler[0].arn
6363

6464
ecs_target {
6565
# Construct ARN without revision number to always use the latest revision
6666
# Format: arn:aws:ecs:region:account:task-definition/family
6767
# This ensures the EventBridge rule always uses the latest revision
6868
# which is updated by the forms-admin deployment pipeline
69-
task_definition_arn = "arn:aws:ecs:eu-west-2:${data.aws_caller_identity.current.account_id}:task-definition/${aws_ecs_task_definition.mailchimp_cron_job[0].family}"
69+
task_definition_arn = "arn:aws:ecs:eu-west-2:${data.aws_caller_identity.current.account_id}:task-definition/${aws_ecs_task_definition.cron_job[0].family}"
7070
launch_type = "FARGATE"
7171
platform_version = "1.4.0"
7272

@@ -83,8 +83,8 @@ resource "aws_cloudwatch_event_target" "ecs_mailchimp_sync_job" {
8383
}
8484

8585
## Monitor for failure
86-
resource "aws_cloudwatch_event_rule" "sync_mailchimp_cron_job_failed" {
87-
name = "${var.env_name}-forms-admin-mailchimp-sync-failed"
86+
resource "aws_cloudwatch_event_rule" "sync_cron_job_failed" {
87+
name = "${var.env_name}-forms-admin-sync-failed"
8888
description = "Trigger when the MailChimp sync job has exited with a non-zero exit code"
8989

9090
event_pattern = jsonencode({
@@ -106,8 +106,8 @@ resource "aws_cloudwatch_event_rule" "sync_mailchimp_cron_job_failed" {
106106
})
107107
}
108108

109-
resource "aws_cloudwatch_event_target" "sync_mailchimp_cron_job_alert_message" {
110-
rule = aws_cloudwatch_event_rule.sync_mailchimp_cron_job_failed.name
109+
resource "aws_cloudwatch_event_target" "sync_cron_job_alert_message" {
110+
rule = aws_cloudwatch_event_rule.sync_cron_job_failed.name
111111

112112
# defined in 'environment' module. Sends alarms/errors via ZenDesk
113113
arn = var.zendesk_sns_topic_arn
@@ -134,10 +134,10 @@ resource "aws_cloudwatch_event_target" "sync_mailchimp_cron_job_alert_message" {
134134
##
135135
# IAM
136136
##
137-
resource "aws_iam_role" "ecs_mailchimp_cron_scheduler" {
137+
resource "aws_iam_role" "ecs_cron_scheduler" {
138138
count = var.enable_mailchimp_sync ? 1 : 0
139139

140-
name = "${var.env_name}-forms-admin-mailchimp-ecs-cron-scheduler"
140+
name = "${var.env_name}-forms-admin-ecs-cron-scheduler"
141141

142142
assume_role_policy = jsonencode({
143143
Version = "2012-10-17"
@@ -153,19 +153,9 @@ resource "aws_iam_role" "ecs_mailchimp_cron_scheduler" {
153153
})
154154
}
155155

156-
resource "aws_iam_role_policy_attachment" "ecs_mailchimp_events_policy" {
156+
resource "aws_iam_role_policy_attachment" "ecs_events_policy" {
157157
count = var.enable_mailchimp_sync ? 1 : 0
158158

159159
policy_arn = "arn:aws:iam::aws:policy/service-role/AmazonEC2ContainerServiceEventsRole"
160-
role = aws_iam_role.ecs_mailchimp_cron_scheduler[0].name
161-
}
162-
163-
moved {
164-
from = aws_cloudwatch_event_rule.sync_cron_job_failed
165-
to = aws_cloudwatch_event_rule.sync_mailchimp_cron_job_failed
166-
}
167-
168-
moved {
169-
from = aws_cloudwatch_event_target.sync_cron_job_alert_message
170-
to = aws_cloudwatch_event_target.sync_mailchimp_cron_job_alert_message
160+
role = aws_iam_role.ecs_cron_scheduler[0].name
171161
}

infra/modules/forms-admin/orgs-sync.tf

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

0 commit comments

Comments
 (0)