Skip to content

Commit

Permalink
AWS Route53 hosted zones (#160)
Browse files Browse the repository at this point in the history
  • Loading branch information
sekka1 authored Aug 18, 2021
1 parent 1ec0605 commit a635c3e
Show file tree
Hide file tree
Showing 6 changed files with 786 additions and 0 deletions.
71 changes: 71 additions & 0 deletions terraform-modules/aws/route53/hosted-zone/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
provider "aws" {
region = "us-east-1"
}

resource "aws_kms_key" "this" {
customer_master_key_spec = "ECC_NIST_P256"
deletion_window_in_days = 7
key_usage = "SIGN_VERIFY"
policy = jsonencode({
Statement = [
{
Action = [
"kms:DescribeKey",
"kms:GetPublicKey",
"kms:Sign",
],
Effect = "Allow"
Principal = {
Service = "dnssec-route53.amazonaws.com"
}
Sid = "Allow Route 53 DNSSEC Service",
Resource = "*"
},
{
Action = "kms:CreateGrant",
Effect = "Allow"
Principal = {
Service = "dnssec-route53.amazonaws.com"
}
Sid = "Allow Route 53 DNSSEC Service to CreateGrant",
Resource = "*"
Condition = {
Bool = {
"kms:GrantIsForAWSResource" = "true"
}
}
},
{
Action = "kms:*"
Effect = "Allow"
Principal = {
AWS = "*"
}
Resource = "*"
Sid = "IAM User Permissions"
},
]
Version = "2012-10-17"
})

tags = var.tags
}

resource "aws_route53_zone" "this" {
name = var.domain_name

tags = var.tags
}

resource "aws_route53_key_signing_key" "this" {
hosted_zone_id = aws_route53_zone.this.id
key_management_service_arn = aws_kms_key.this.arn
name = "key"
}

resource "aws_route53_hosted_zone_dnssec" "this" {
depends_on = [
aws_route53_key_signing_key.this
]
hosted_zone_id = aws_route53_key_signing_key.this.hosted_zone_id
}
7 changes: 7 additions & 0 deletions terraform-modules/aws/route53/hosted-zone/outputs.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
output "zone_id" {
value = aws_route53_zone.this.zone_id
}

output "name_servers" {
value = aws_route53_zone.this.name_servers
}
8 changes: 8 additions & 0 deletions terraform-modules/aws/route53/hosted-zone/test/go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
module github.com/ManagedKube/kubernetes-ops

go 1.15

require (
github.com/gruntwork-io/terratest v0.32.24
github.com/stretchr/testify v1.7.0
)
Loading

0 comments on commit a635c3e

Please sign in to comment.