-
Notifications
You must be signed in to change notification settings - Fork 6
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
Refactoring VPN to use AWS private certificate authority #1522
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -51,45 +51,53 @@ module "gha_vpn" { | |
billing_tag_value = "notification-canada-ca-${var.env}" | ||
} | ||
|
||
resource "aws_acm_certificate" "client_vpn" { | ||
certificate_authority_arn = aws_acmpca_certificate_authority.client_vpn.arn | ||
domain_name = "${var.env}.notification.canada.ca" | ||
|
||
# | ||
# Certificate used for VPN communication | ||
# | ||
resource "tls_private_key" "client_vpn" { | ||
algorithm = "RSA" | ||
rsa_bits = 2048 | ||
} | ||
|
||
resource "tls_self_signed_cert" "client_vpn" { | ||
private_key_pem = tls_private_key.client_vpn.private_key_pem | ||
validity_period_hours = 43800 # 5 years | ||
early_renewal_hours = 672 # Generate new cert if Terraform is run within 4 weeks of expiry | ||
tags = { | ||
Environment = var.env | ||
} | ||
|
||
subject { | ||
common_name = "vpn.${var.env}.notification.canada.ca" | ||
lifecycle { | ||
create_before_destroy = true | ||
} | ||
} | ||
|
||
resource "aws_acmpca_certificate_authority_certificate" "client_vpn" { | ||
certificate_authority_arn = aws_acmpca_certificate_authority.client_vpn.arn | ||
|
||
allowed_uses = [ | ||
"key_encipherment", | ||
"digital_signature", | ||
"server_auth", | ||
"ipsec_end_system", | ||
"ipsec_tunnel", | ||
"any_extended", | ||
"cert_signing", | ||
] | ||
certificate = aws_acmpca_certificate.client_vpn.certificate | ||
certificate_chain = aws_acmpca_certificate.client_vpn.certificate_chain | ||
} | ||
|
||
resource "aws_acm_certificate" "client_vpn" { | ||
private_key = tls_private_key.client_vpn.private_key_pem | ||
certificate_body = tls_self_signed_cert.client_vpn.cert_pem | ||
resource "aws_acmpca_certificate" "client_vpn" { | ||
certificate_authority_arn = aws_acmpca_certificate_authority.client_vpn.arn | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The |
||
certificate_signing_request = aws_acmpca_certificate_authority.client_vpn.certificate_signing_request | ||
signing_algorithm = "SHA512WITHRSA" | ||
|
||
tags = { | ||
Name = "notification-canada-ca" | ||
CostCenter = "notification-canada-ca-${var.env}" | ||
template_arn = "arn:${data.aws_partition.current.partition}:acm-pca:::template/RootCACertificate/V1" | ||
|
||
ben851 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
validity { | ||
type = "YEARS" | ||
value = 5 | ||
} | ||
} | ||
|
||
lifecycle { | ||
create_before_destroy = true | ||
resource "aws_acmpca_certificate_authority" "client_vpn" { | ||
type = "ROOT" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The |
||
|
||
certificate_authority_configuration { | ||
key_algorithm = "RSA_4096" | ||
signing_algorithm = "SHA512WITHRSA" | ||
|
||
subject { | ||
common_name = "notification.canada.ca" | ||
} | ||
} | ||
} | ||
|
||
ben851 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
permanent_deletion_time_in_days = 7 | ||
} | ||
|
||
ben851 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
data "aws_partition" "current" {} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The resource
aws_acmpca_certificate_authority_certificate
is not necessary. Theaws_acm_certificate
resource already handles the certificate issuance and management. Consider removing this resource to avoid redundancy.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not according to all documentation!