diff --git a/.changeset/plenty-buses-hope.md b/.changeset/plenty-buses-hope.md new file mode 100644 index 0000000000..aea2df4cbc --- /dev/null +++ b/.changeset/plenty-buses-hope.md @@ -0,0 +1,5 @@ +--- +"infrastructure": patch +--- + +Added environment variables that allow strapi to integrate with active campaign diff --git a/apps/infrastructure/src/env/dev/terraform.tfvars b/apps/infrastructure/src/env/dev/terraform.tfvars index b01f1d9408..9ab307ea25 100644 --- a/apps/infrastructure/src/env/dev/terraform.tfvars +++ b/apps/infrastructure/src/env/dev/terraform.tfvars @@ -29,4 +29,5 @@ dns_domain_name_cms = { } } -create_chatbot = true \ No newline at end of file +create_chatbot = true +ac_integration_is_enabled = true \ No newline at end of file diff --git a/apps/infrastructure/src/env/prod/terraform.tfvars b/apps/infrastructure/src/env/prod/terraform.tfvars index 82bf7a303b..aeb66a0cb0 100644 --- a/apps/infrastructure/src/env/prod/terraform.tfvars +++ b/apps/infrastructure/src/env/prod/terraform.tfvars @@ -32,4 +32,5 @@ dns_domain_name_cms = { } } -create_chatbot = true \ No newline at end of file +create_chatbot = true +ac_integration_is_enabled = false \ No newline at end of file diff --git a/apps/infrastructure/src/main.tf b/apps/infrastructure/src/main.tf index b8ffb44dfe..18196ce232 100644 --- a/apps/infrastructure/src/main.tf +++ b/apps/infrastructure/src/main.tf @@ -101,9 +101,12 @@ module "cms" { github_repository = var.github_repository tags = var.tags - dns_domain_name = var.dns_domain_name - dns_domain_name_cms = var.dns_domain_name_cms - hosted_zone_id = module.core.hosted_zone_id + dns_domain_name = var.dns_domain_name + dns_domain_name_cms = var.dns_domain_name_cms + hosted_zone_id = module.core.hosted_zone_id + ac_integration_is_enabled = var.ac_integration_is_enabled + ac_base_url_param = var.ac_integration_is_enabled ? module.active_campaign[0].base_url_param : null + ac_api_key_param = var.ac_integration_is_enabled ? module.active_campaign[0].api_key_param : null } module "chatbot" { @@ -148,6 +151,7 @@ module "cicd" { } module "active_campaign" { + count = var.ac_integration_is_enabled ? 1 : 0 source = "./modules/active_campaign" environment = var.environment @@ -155,4 +159,4 @@ module "active_campaign" { cognito_user_pool = module.website.cognito_user_pool webinar_subscriptions_ddb_stream_arn = module.website.webinar_subscriptions_ddb_stream_arn -} \ No newline at end of file +} diff --git a/apps/infrastructure/src/modules/active_campaign/lambda.tf b/apps/infrastructure/src/modules/active_campaign/lambda.tf index 1eb481488f..3834d82e7e 100644 --- a/apps/infrastructure/src/modules/active_campaign/lambda.tf +++ b/apps/infrastructure/src/modules/active_campaign/lambda.tf @@ -19,8 +19,9 @@ module "lambda_sync" { ignore_source_code_hash = true create_current_version_allowed_triggers = false - timeout = 15 - memory_size = 256 + timeout = 15 + memory_size = 256 + maximum_retry_attempts = 0 event_source_mapping = { sqs = { diff --git a/apps/infrastructure/src/modules/active_campaign/output.tf b/apps/infrastructure/src/modules/active_campaign/output.tf new file mode 100644 index 0000000000..626343b7a3 --- /dev/null +++ b/apps/infrastructure/src/modules/active_campaign/output.tf @@ -0,0 +1,7 @@ +output "base_url_param" { + value = module.active_campaign_base_url.ssm_parameter_arn +} + +output "api_key_param" { + value = module.active_campaign_api_key.ssm_parameter_arn +} \ No newline at end of file diff --git a/apps/infrastructure/src/modules/cms/ecs.tf b/apps/infrastructure/src/modules/cms/ecs.tf index 6bfababb9c..93a9df10a4 100644 --- a/apps/infrastructure/src/modules/cms/ecs.tf +++ b/apps/infrastructure/src/modules/cms/ecs.tf @@ -47,6 +47,10 @@ resource "aws_ecs_task_definition" "cms_task_def" { google_oauth_client_id = module.secret_cms_google_oauth_client_id.ssm_parameter_arn google_oauth_client_secret = module.secret_cms_google_oauth_client_secret.ssm_parameter_arn google_oauth_redirect_uri = format("https://cms.%s/strapi-plugin-sso/google/callback", var.dns_domain_name) + ac_integration_is_enabled = var.ac_integration_is_enabled + ac_base_url = var.ac_integration_is_enabled ? var.ac_base_url_param : module.secret_cms_transfer_token_salt.ssm_parameter_arn + ac_api_key = var.ac_integration_is_enabled ? var.ac_api_key_param : module.secret_cms_transfer_token_salt.ssm_parameter_arn + ac_sender_url = "https://${var.dns_domain_name}" }) } diff --git a/apps/infrastructure/src/modules/cms/iam_policy.tf b/apps/infrastructure/src/modules/cms/iam_policy.tf index 9f3a652d47..01f5b2e1ba 100644 --- a/apps/infrastructure/src/modules/cms/iam_policy.tf +++ b/apps/infrastructure/src/modules/cms/iam_policy.tf @@ -82,7 +82,7 @@ data "aws_iam_policy_document" "ecs_task_execution" { actions = [ "ssm:GetParameters" ] - resources = [ + resources = concat([ module.secret_cms_database_password.ssm_parameter_arn, module.secret_cms_admin_jwt_secret.ssm_parameter_arn, module.secret_cms_app_keys.ssm_parameter_arn, @@ -95,7 +95,9 @@ data "aws_iam_policy_document" "ecs_task_execution" { module.secret_cms_google_gsuite_hd.ssm_parameter_arn, module.secret_cms_google_oauth_client_id.ssm_parameter_arn, module.secret_cms_google_oauth_client_secret.ssm_parameter_arn, - ] + ], + (var.ac_integration_is_enabled ? [var.ac_base_url_param, var.ac_api_key_param] : []) + ) } statement { diff --git a/apps/infrastructure/src/modules/cms/task-definitions/cms_app.json.tpl b/apps/infrastructure/src/modules/cms/task-definitions/cms_app.json.tpl index eaca9b9045..d90bd0e4d7 100644 --- a/apps/infrastructure/src/modules/cms/task-definitions/cms_app.json.tpl +++ b/apps/infrastructure/src/modules/cms/task-definitions/cms_app.json.tpl @@ -91,6 +91,14 @@ { "name": "DEPLOY_WEBSITE_TARGET_BRANCH", "value": "${target_branch}" + }, + { + "name": "ACTIVE_CAMPAIGN_INTEGRATION_IS_ENABLED", + "value": "${ac_integration_is_enabled}" + }, + { + "name": "SENDER_URL", + "value": "${ac_sender_url}" } ], "secrets" : [ @@ -141,7 +149,15 @@ { "name": "GOOGLE_OAUTH_CLIENT_SECRET", "valueFrom": "${google_oauth_client_secret}" - } + }, + { + "name": "AC_BASE_URL", + "valueFrom": "${ac_base_url}" + }, + { + "name": "AC_API_KEY", + "valueFrom": "${ac_api_key}" + } ] } ] diff --git a/apps/infrastructure/src/modules/cms/variables.tf b/apps/infrastructure/src/modules/cms/variables.tf index cb6442fe15..4f624c8943 100644 --- a/apps/infrastructure/src/modules/cms/variables.tf +++ b/apps/infrastructure/src/modules/cms/variables.tf @@ -54,4 +54,23 @@ variable "dns_domain_name_cms" { variable "hosted_zone_id" { type = string description = "The ID of the hosted zone to create the public DNS records in" +} + +## Active Campaign configuration for Strapi +variable "ac_integration_is_enabled" { + type = bool + description = "Enable Active Campaign integration for Strapi" + default = false +} + +variable "ac_base_url_param" { + type = string + description = "Active Campaign base URL SSM parameter ARN" + default = null +} + +variable "ac_api_key_param" { + type = string + description = "Active Campaign API key SSM parameter ARN" + default = null } \ No newline at end of file diff --git a/apps/infrastructure/src/variables.tf b/apps/infrastructure/src/variables.tf index 15c03bceb7..b20094e9b2 100644 --- a/apps/infrastructure/src/variables.tf +++ b/apps/infrastructure/src/variables.tf @@ -138,4 +138,13 @@ variable "chatbot_ecs_monitoring" { image_uri = "ghcr.io/langfuse/langfuse:sha-9375250" port = 3000 } +} + +################################################################################ +# Active Campaign integration +################################################################################ +variable "ac_integration_is_enabled" { + type = bool + description = "Defines if Active Campaign integration should be enabled" + default = false } \ No newline at end of file