trying to get domain creation working

This commit is contained in:
Khalim Conn-Kowlessar 2023-07-17 15:03:24 +01:00
parent 9f60639731
commit ac0717d9f3
3 changed files with 12 additions and 2 deletions

View file

@ -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:

View file

@ -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 "<stage>/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
}
}

View file

@ -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]
}