Skip to content

Commit

Permalink
code changes to fix unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
markgov committed May 3, 2024
1 parent 70ba4e6 commit fec7d2d
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 28 deletions.
52 changes: 26 additions & 26 deletions main.tf
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
provider "aws" {
alias = "core-vpc"
region = "eu-west-2"
assume_role {
role_arn = "arn:aws:iam::${var.environment_management.account_ids[var.provider_name]}:role/member-delegation-${local.vpc_name}-${var.app_name}"
}
}
# provider "aws" {
# alias = "core-vpc"
# region = "eu-west-2"
# assume_role {
# role_arn = "arn:aws:iam::${var.environment_management.account_ids[var.provider_name]}:role/member-delegation-${local.vpc_name}-${var.app_name}"
# }
# }


resource "aws_acm_certificate" "certificate" {
Expand All @@ -18,24 +18,24 @@ resource "aws_acm_certificate" "certificate" {
}


# resource "aws_route53_record" "cert_validation" {
# provider = aws.core-network-services
# depends_on = [ aws_acm_certificate.certificate ]
# for_each = {
# for val in aws_acm_certificate.certificate.domain_validation_options : val.domain_name => {
# name = val.resource_record_name
# record = val.resource_record_value
# type = val.resource_record_type
# }
# }
# zone_id = var.fqdn
# name = each.value.name
# records = [each.value.record]
# type = var.record_type
# }
resource "aws_route53_record" "cert_validation" {
provider = aws.core-vpc
depends_on = [ aws_acm_certificate.certificate ]
for_each = {
for val in aws_acm_certificate.certificate.domain_validation_options : val.domain_name => {
name = val.resource_record_name
record = val.resource_record_value
type = val.resource_record_type
}
}
zone_id = var.fqdn
name = each.value.name
records = [each.value.record]
type = var.record_type
}


# resource "aws_acm_certificate_validation" "example" {
# certificate_arn = aws_acm_certificate.certificate.arn
# validation_record_fqdns = [for record in aws_route53_record.cert_validation : record.fqdn]
# }
resource "aws_acm_certificate_validation" "example" {
certificate_arn = aws_acm_certificate.certificate.arn
validation_record_fqdns = [for record in aws_route53_record.cert_validation : record.fqdn]
}
2 changes: 1 addition & 1 deletion test/module_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import (
func TestCertificateCreation(t *testing.T) {
t.Parallel()

fqdn := "platforms-test.modernisation-platform.service.justice.gov.uk"
fqdn := "modernisation-platform.service.justice.gov.uk"
recordType := "CNAME"
terraformDir := "./unit-test"

Expand Down
2 changes: 1 addition & 1 deletion test/unit-test/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
module "cert_module" {
source = "../../"
providers = {
aws.core-network-services = aws.core-network-services
aws.core-vpc = aws.core-vpc

}
aws_account_id = local.environment_management.account_ids
Expand Down
14 changes: 14 additions & 0 deletions test/unit-test/variables.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
variable "fqdn" {
description = "The fully qualified domain name (FQDN) for which the DNS record should be created"
type = string
}

variable "record_type" {
description = "The type of DNS record to create (e.g., CNAME, A, etc.)"
type = string
}

variable "environment" {
type = string

}

0 comments on commit fec7d2d

Please sign in to comment.