From ac0717d9f3730e1b1ab4c57c914f2f373d60733f Mon Sep 17 00:00:00 2001 From: Khalim Conn-Kowlessar Date: Mon, 17 Jul 2023 15:03:24 +0100 Subject: [PATCH] trying to get domain creation working --- backend/serverless.yml | 2 +- infrastructure/terraform/main.tf | 10 +++++++++- infrastructure/terraform/modules/route53/main.tf | 2 ++ 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/backend/serverless.yml b/backend/serverless.yml index 857f17ae..b4e7d698 100644 --- a/backend/serverless.yml +++ b/backend/serverless.yml @@ -12,6 +12,7 @@ provider: PLAN_TRIGGER_BUCKET: ${env:PLAN_TRIGGER_BUCKET} DOMAIN_NAME: ${env:DOMAIN_NAME} + package: individually: true include: @@ -31,7 +32,6 @@ custom: customDomain: domainName: api.${self:provider.environment.DOMAIN_NAME} createRoute53Record: true - certificateName: '*.dev.hestia.homes' certificateArn: ${ssm:/ssl_certificate_arn} functions: diff --git a/infrastructure/terraform/main.tf b/infrastructure/terraform/main.tf index dfde8f94..f48da21f 100644 --- a/infrastructure/terraform/main.tf +++ b/infrastructure/terraform/main.tf @@ -20,6 +20,12 @@ provider "aws" { region = var.region } +# Additional provider for resources that need to be in us-east-1, specifically the SSL certificate +provider "aws" { + alias = "aws_use1" + region = "us-east-1" +} + # Assuming the secret is already created and the name is "/assessment_model/db_credentials" data "aws_secretsmanager_secret" "db_credentials" { name = "${var.stage}/assessment_model/db_credentials" @@ -89,5 +95,7 @@ module "route53" { source = "./modules/route53" domain_name = var.domain_name api_url_prefix = var.api_url_prefix - + providers = { + aws.aws_use1 = aws.aws_use1 + } } \ No newline at end of file diff --git a/infrastructure/terraform/modules/route53/main.tf b/infrastructure/terraform/modules/route53/main.tf index c82768d7..3bf109bd 100644 --- a/infrastructure/terraform/modules/route53/main.tf +++ b/infrastructure/terraform/modules/route53/main.tf @@ -4,6 +4,7 @@ resource "aws_route53_zone" "my_hosted_zone" { # Request an SSL certificate for the domain resource "aws_acm_certificate" "my_certificate_request" { + provider = aws.aws_use1 domain_name = "*.${var.domain_name}" validation_method = "DNS" @@ -35,6 +36,7 @@ resource "aws_route53_record" "my_validation_record" { } resource "aws_acm_certificate_validation" "my_certificate_validation" { + provider = aws.aws_use1 certificate_arn = aws_acm_certificate.my_certificate_request.arn validation_record_fqdns = [for record in aws_route53_record.my_validation_record: record.fqdn] }