Skip to content

Commit

Permalink
refactor example and unit tests (#10)
Browse files Browse the repository at this point in the history
* Update version for example

* update

* update

* update

* update

* update

* update

* update

* update

* update

* update

* update

* update
  • Loading branch information
locus313 authored Jun 23, 2024
1 parent 2d2d94e commit 9afb230
Show file tree
Hide file tree
Showing 6 changed files with 41 additions and 24 deletions.
16 changes: 15 additions & 1 deletion .github/workflows/scheduled-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,16 @@ jobs:
uses: actions/checkout@v4

- name: Set up Go
uses: actions/setup-go@v2
uses: actions/setup-go@v5
with:
go-version: 1.18

- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v4
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: us-west-2

- name: Install Terraform
uses: hashicorp/setup-terraform@v3
Expand All @@ -41,6 +48,13 @@ jobs:
- name: Checkout code
uses: actions/checkout@v4

- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v4
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: us-west-2

- name: Set up Terraform
uses: hashicorp/setup-terraform@v3
with:
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ No modules.
```hcl
module "example-com" {
source = "locus313/aws-route53/module"
version = "1.0.4"
version = "1.0.5"
enabled = true
primary_domain = "example.com"
Expand Down
4 changes: 4 additions & 0 deletions cert.tf
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ resource "aws_acm_certificate" "records_wr" {
provider = aws.acm
domain_name = each.key
validation_method = "DNS"

depends_on = [aws_route53_zone.this]
}

resource "aws_acm_certificate_validation" "records_wr" {
Expand All @@ -12,4 +14,6 @@ resource "aws_acm_certificate_validation" "records_wr" {
provider = aws.acm
certificate_arn = aws_acm_certificate.records_wr[each.key].arn
validation_record_fqdns = [for record in aws_route53_record.records_wr_validation : record.fqdn]

depends_on = [aws_route53_zone.this]
}
4 changes: 2 additions & 2 deletions compliance/features/example.feature
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
Feature: Route 53 Compliance

Scenario: Ensure all A records have the correct TTL
Given I have AWS Route53 Record defined
Given I have aws_route53_record defined
When its type is "A"
Then its ttl must be 3600

Scenario: Ensure all CNAME records have the correct TTL
Given I have AWS Route53 Record defined
Given I have aws_route53_record defined
When its type is "CNAME"
Then its ttl must be 3600
35 changes: 17 additions & 18 deletions example/main.tf
Original file line number Diff line number Diff line change
@@ -1,46 +1,45 @@
module "example-com" {
module "lo5t-dev" {
source = "locus313/aws-route53/module"
version = "1.0.4"
version = "1.0.5"

enabled = true
primary_domain = "example.com"
primary_domain = "lo5t.dev"

records_wr = {
"support.example.com" = "https://example.atlassian.net/servicedesk/customer/portals"
}

records_a = {
"example.com" = ["12.23.45.56"]
"lo5t.dev" = ["12.23.45.56"]
}

records_aaaa = {
"example.com" = ["::ffff:c17:2d38"]
"lo5t.dev" = ["::ffff:c17:2d38"]
}

records_caa = {
"example.com" = ["0 issue \"letsencrypt.org\""]
"lo5t.dev" = ["0 issue \"letsencrypt.org\""]
}

records_cname = {
"calendar.example.com" = ["ghs.googlehosted.com"]
"docs.example.com" = ["ghs.googlehosted.com"]
"ftp.example.com" = ["example.com"]
"mail.example.com" = ["ghs.googlehosted.com"]
"sites.example.com" = ["ghs.googlehosted.com"]
"www.example.com" = ["example.com"]
"calendar.lo5t.dev" = ["ghs.googlehosted.com"]
"docs.lo5t.dev" = ["ghs.googlehosted.com"]
"ftp.lo5t.dev" = ["lo5t.dev"]
"mail.lo5t.dev" = ["ghs.googlehosted.com"]
"sites.lo5t.dev" = ["ghs.googlehosted.com"]
"www.lo5t.dev" = ["lo5t.dev"]
}

records_mx = {
"example.com" = ["10 aspmx.l.google.com","20 alt1.aspmx.l.google.com","30 alt2.aspmx.l.google.com","40 aspmx2.googlemail.com","50 aspmx3.googlemail.com"]
"lo5t.dev" = ["10 aspmx.l.google.com","20 alt1.aspmx.l.google.com","30 alt2.aspmx.l.google.com","40 aspmx2.googlemail.com","50 aspmx3.googlemail.com"]
}

records_txt = {
"example.com" = ["v=spf1 include:_spf.google.com ~all"]
"google._domainkey.example.com" = ["v=DKIM1; k=rsa; p=MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA3gtOkCHXv+kDJBpIkr1lq1Ywd4B8FJGPceSv9s7yhUtCk8pKwifLmSKWNEyOvuK5oxIms+4Vc9Pu46bi/wehi5zJynzhkOrzYXdOX6+m4Nb8NbFWr0zZqsM+pDGmYzRjeczY/+txXnOegcbxL+967bIRisnlH2CRD91h1t0NJwsvvN23T5MAMaeJr726piDdE\"\"C6P2nF1apYbGXp0DZGz/RvtpCGjASjlpejA8I/xLclZOBn4Ir9pk8gajRSG48D21UKJ3d+PFzYEj9X5n1p1i2trjCqkdyCzU+f3vTUxma5F7fQncKYIeRJwVNbmR03IYfGuicCu13hnVP36aT5yuQIDAQAB"]
"lo5t.dev" = ["v=spf1 include:_spf.google.com ~all"]
"google._domainkey.lo5t.dev" = ["v=DKIM1; k=rsa; p=MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA3gtOkCHXv+kDJBpIkr1lq1Ywd4B8FJGPceSv9s7yhUtCk8pKwifLmSKWNEyOvuK5oxIms+4Vc9Pu46bi/wehi5zJynzhkOrzYXdOX6+m4Nb8NbFWr0zZqsM+pDGmYzRjeczY/+txXnOegcbxL+967bIRisnlH2CRD91h1t0NJwsvvN23T5MAMaeJr726piDdE\"\"C6P2nF1apYbGXp0DZGz/RvtpCGjASjlpejA8I/xLclZOBn4Ir9pk8gajRSG48D21UKJ3d+PFzYEj9X5n1p1i2trjCqkdyCzU+f3vTUxma5F7fQncKYIeRJwVNbmR03IYfGuicCu13hnVP36aT5yuQIDAQAB"]
}

records_ns = {
"clusters.example.com" = ["ns-128.awsdns-16.com","ns-1533.awsdns-63.org","ns-1554.awsdns-02.co.uk","ns-956.awsdns-55.net"]
"envs.example.com" = ["ns-1103.awsdns-09.org","ns-1587.awsdns-06.co.uk","ns-378.awsdns-47.com","ns-693.awsdns-22.net"]
"clusters.lo5t.dev" = ["ns-128.awsdns-16.com","ns-1533.awsdns-63.org","ns-1554.awsdns-02.co.uk","ns-956.awsdns-55.net"]
"envs.lo5t.dev" = ["ns-1103.awsdns-09.org","ns-1587.awsdns-06.co.uk","ns-378.awsdns-47.com","ns-693.awsdns-22.net"]
}
}
4 changes: 2 additions & 2 deletions example/outputs.tf
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
output "zone_id" {
description = "Zone ID of Route53 zone"
value = module.example-com[0].this_route53_zone_zone_id
value = module.lo5t-dev.this_route53_zone_zone_id
}

output "name_servers" {
description = "Name servers of Route53 zone"
value = module.example-com[0].this_route53_zone_name_servers
value = module.lo5t-dev.this_route53_zone_name_servers
}

0 comments on commit 9afb230

Please sign in to comment.