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

[DEV-2049] Add ac env vars to strapi container #1268

Merged
5 changes: 5 additions & 0 deletions .changeset/plenty-buses-hope.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"infrastructure": patch
---

Added environment variables that allow strapi to integrate with active campaign
3 changes: 2 additions & 1 deletion apps/infrastructure/src/env/dev/terraform.tfvars
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,5 @@ dns_domain_name_cms = {
}
}

create_chatbot = true
create_chatbot = true
ac_integration_is_enabled = true
3 changes: 2 additions & 1 deletion apps/infrastructure/src/env/prod/terraform.tfvars
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,5 @@ dns_domain_name_cms = {
}
}

create_chatbot = true
create_chatbot = true
ac_integration_is_enabled = false
12 changes: 8 additions & 4 deletions apps/infrastructure/src/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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" {
Expand Down Expand Up @@ -148,11 +151,12 @@ module "cicd" {
}

module "active_campaign" {
count = var.ac_integration_is_enabled ? 1 : 0
source = "./modules/active_campaign"

environment = var.environment
tags = var.tags

cognito_user_pool = module.website.cognito_user_pool
webinar_subscriptions_ddb_stream_arn = module.website.webinar_subscriptions_ddb_stream_arn
}
}
5 changes: 3 additions & 2 deletions apps/infrastructure/src/modules/active_campaign/lambda.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down
7 changes: 7 additions & 0 deletions apps/infrastructure/src/modules/active_campaign/output.tf
Original file line number Diff line number Diff line change
@@ -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
}
4 changes: 4 additions & 0 deletions apps/infrastructure/src/modules/cms/ecs.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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}"
})
}

Expand Down
6 changes: 4 additions & 2 deletions apps/infrastructure/src/modules/cms/iam_policy.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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" : [
Expand Down Expand Up @@ -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}"
}
]
}
]
19 changes: 19 additions & 0 deletions apps/infrastructure/src/modules/cms/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
9 changes: 9 additions & 0 deletions apps/infrastructure/src/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Loading