Skip to content

Commit a2fa2e0

Browse files
authored
Merge pull request #64 from pablo19sc/main
DNS configuration (Alias record creation) + Access Log support
2 parents abccac5 + 8f16d61 commit a2fa2e0

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+939
-833
lines changed

.header.md

Lines changed: 111 additions & 251 deletions
Large diffs are not rendered by default.

CODEOWNERS

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
* @aws-ia/aws-ia
1+
* @aws-ia/aws-ia

README.md

Lines changed: 126 additions & 256 deletions
Large diffs are not rendered by default.

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
v0.2.0
1+
v1.0.0

data.tf

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,18 @@ locals {
1212
sn_identifier_provided = contains(keys(var.service_network), "identifier")
1313
# Checking if Service Network auth policy should be created
1414
sn_auth_policy = (try(var.service_network.auth_type, "NONE") == "AWS_IAM") && (contains(keys(var.service_network), "auth_policy"))
15-
15+
# Checking the access log destinations for the service network
16+
sn_access_log_cloudwatch = contains(keys(var.service_network), "access_log_cloudwatch")
17+
sn_access_log_s3 = contains(keys(var.service_network), "access_log_s3")
18+
sn_access_log_firehose = contains(keys(var.service_network), "access_log_firehose")
1619

1720
# ---------- VPC Lattice Service variables ---------
1821
# Service Association - if Service Network is created or passed
1922
create_service_association = local.create_service_network || local.sn_identifier_provided
23+
# Checking if a global Private Hosted Zone has been defined
24+
global_phz = contains(keys(var.dns_configuration), "hosted_zone_id")
25+
# Obtaining a map of VPC Lattice services that require the creation of DNS configuration
26+
services_with_dns_config = local.global_phz ? var.services : { for k, v in var.services : k => v if contains(keys(v), "hosted_zone_id") }
2027

2128
# ---------- VPC Lattice Target Groups ----------
2229
# We create a map of target group IDs
@@ -43,7 +50,7 @@ locals {
4350
# Sanitizes tags for aws provider
4451
module "tags" {
4552
source = "aws-ia/label/aws"
46-
version = "0.0.5"
53+
version = "0.0.6"
4754

4855
tags = var.tags
4956
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# Amazon VPC Lattice - Example: DNS configuration
2+
3+
This example shows how you can use the VPC Lattice module to configure DNS resolution (creation of Alias records) when creation VPC Lattice services with custom domain names. This example creates the following:
4+
5+
* Two Amazon Route 53 private hosted zones, and one VPC (needed for the configuration of the hosted zone as *private*).
6+
* Eight VPC Lattice services with basic configuration (without listeners or targets).
7+
* When configured, the custom domain name provided in each service's definition will create an Alias record either in the *global* Private Hosted Zone (defined in `var.dns_configuration.private_hosted_zone_id`) or in the *specific* PHZ (defined in the attribute `private_hosted_zone_id` under the service's configuration in `var.services`).
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
<!-- BEGIN_TF_DOCS -->
2+
# Amazon VPC Lattice - Example: DNS configuration
3+
4+
This example shows how you can use the VPC Lattice module to configure DNS resolution (creation of Alias records) when creation VPC Lattice services with custom domain names. This example creates the following:
5+
6+
* Two Amazon Route 53 private hosted zones, and one VPC (needed for the configuration of the hosted zone as *private*).
7+
* Eight VPC Lattice services with basic configuration (without listeners or targets).
8+
* When configured, the custom domain name provided in each service's definition will create an Alias record either in the *global* Private Hosted Zone (defined in `var.dns_configuration.private_hosted_zone_id`) or in the *specific* PHZ (defined in the attribute `private_hosted_zone_id` under the service's configuration in `var.services`).
9+
10+
## Requirements
11+
12+
| Name | Version |
13+
|------|---------|
14+
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.3.0 |
15+
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 4.66.0 |
16+
17+
## Providers
18+
19+
| Name | Version |
20+
|------|---------|
21+
| <a name="provider_aws"></a> [aws](#provider\_aws) | >= 4.66.0 |
22+
23+
## Modules
24+
25+
| Name | Source | Version |
26+
|------|--------|---------|
27+
| <a name="module_dns_resolution_example1"></a> [dns\_resolution\_example1](#module\_dns\_resolution\_example1) | ../.. | n/a |
28+
| <a name="module_dns_resolution_example3"></a> [dns\_resolution\_example3](#module\_dns\_resolution\_example3) | ../.. | n/a |
29+
30+
## Resources
31+
32+
| Name | Type |
33+
|------|------|
34+
| [aws_route53_zone.global_private_hosted_zone](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/route53_zone) | resource |
35+
| [aws_route53_zone.specific_private_hosted_zone](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/route53_zone) | resource |
36+
| [aws_vpc.vpc](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/vpc) | resource |
37+
| [aws_vpclattice_service.service2](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/vpclattice_service) | resource |
38+
| [aws_vpclattice_service.service4](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/vpclattice_service) | resource |
39+
| [aws_vpclattice_service.service6](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/vpclattice_service) | resource |
40+
41+
## Inputs
42+
43+
| Name | Description | Type | Default | Required |
44+
|------|-------------|------|---------|:--------:|
45+
| <a name="input_aws_region"></a> [aws\_region](#input\_aws\_region) | AWS Region to use. | `string` | `"eu-west-1"` | no |
46+
47+
## Outputs
48+
49+
No outputs.
50+
<!-- END_TF_DOCS -->

examples/dns_configuration/main.tf

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
# --- examples/dns_configuration/main.tf ---
2+
3+
# Private Hosted Zones
4+
resource "aws_route53_zone" "global_private_hosted_zone" {
5+
name = "global.com"
6+
7+
vpc {
8+
vpc_id = aws_vpc.vpc.id
9+
}
10+
}
11+
12+
resource "aws_route53_zone" "specific_private_hosted_zone" {
13+
name = "specific.com"
14+
15+
vpc {
16+
vpc_id = aws_vpc.vpc.id
17+
}
18+
}
19+
20+
resource "aws_vpc" "vpc" {
21+
cidr_block = "10.0.0.0/24"
22+
}
23+
24+
module "dns_resolution_example1" {
25+
source = "../.."
26+
27+
dns_configuration = {
28+
hosted_zone_id = aws_route53_zone.global_private_hosted_zone.id
29+
}
30+
31+
services = {
32+
# EXAMPLE 1: VPC Lattice service created by the module and Alias record created in the "global" PHZ
33+
service1 = {
34+
name = "service1"
35+
auth_type = "NONE"
36+
custom_domain_name = "service1.global.com"
37+
}
38+
39+
# EXAMPLE 2: VPC Lattice service created outside the module and Alias record created in the "global" PHZ
40+
service2 = {
41+
identifier = aws_vpclattice_service.service2.arn
42+
}
43+
44+
# EXAMPLE 3: VPC Lattice service created by the module and Alias record created in the "specific" PHZ
45+
service3 = {
46+
name = "service3"
47+
auth_type = "NONE"
48+
custom_domain_name = "service3.specific.com"
49+
hosted_zone_id = aws_route53_zone.specific_private_hosted_zone.id
50+
}
51+
52+
# EXAMPLE 4: VPC Lattice service created outside the module and Alias record created in the "specific" PHZ
53+
service4 = {
54+
identifier = aws_vpclattice_service.service4.arn
55+
hosted_zone_id = aws_route53_zone.specific_private_hosted_zone.id
56+
}
57+
}
58+
}
59+
60+
resource "aws_vpclattice_service" "service2" {
61+
name = "service2"
62+
auth_type = "NONE"
63+
custom_domain_name = "service2.global.com"
64+
}
65+
66+
resource "aws_vpclattice_service" "service4" {
67+
name = "service4"
68+
auth_type = "NONE"
69+
custom_domain_name = "service4.global.com"
70+
}
71+
72+
module "dns_resolution_example3" {
73+
source = "../.."
74+
75+
services = {
76+
# EXAMPLE 5: VPC Lattice service created by the module (no Alias record created)
77+
service5 = {
78+
name = "service7"
79+
auth_type = "NONE"
80+
}
81+
82+
# EXAMPLE 5: VPC Lattice service created outside the module and Alias record created in the "specific" PHZ
83+
service6 = {
84+
identifier = aws_vpclattice_service.service6.arn
85+
hosted_zone_id = aws_route53_zone.specific_private_hosted_zone.id
86+
}
87+
}
88+
}
89+
90+
resource "aws_vpclattice_service" "service6" {
91+
name = "service8"
92+
auth_type = "NONE"
93+
custom_domain_name = "service6.specific.com"
94+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# --- examples/dns_configuration/outputs.tf ---

examples/vpc_associations/providers.tf renamed to examples/dns_configuration/providers.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# --- examples/vpc_associations/providers.tf ---
1+
# --- examples/dns_configuration/providers.tf ---
22

33
terraform {
44
required_version = ">= 1.3.0"

0 commit comments

Comments
 (0)