Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
T
terraform-aws-route53
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Container Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Terraform Modules
terraform-aws-route53
Commits
e87b6262
Unverified
Commit
e87b6262
authored
Jan 15, 2021
by
Anton Babenko
Committed by
GitHub
Jan 15, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: added weighted routing policy (#23)
parent
42244d4d
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
38 additions
and
10 deletions
+38
-10
.gitignore
.gitignore
+1
-0
main.tf
examples/complete/main.tf
+23
-5
main.tf
modules/records/main.tf
+14
-5
No files found.
.gitignore
View file @
e87b6262
...
@@ -2,3 +2,4 @@
...
@@ -2,3 +2,4 @@
terraform.tfstate
terraform.tfstate
*.tfstate*
*.tfstate*
terraform.tfvars
terraform.tfvars
.terraform.lock.hcl
examples/complete/main.tf
View file @
e87b6262
...
@@ -63,6 +63,26 @@ module "records" {
...
@@ -63,6 +63,26 @@ module "records" {
zone_id
=
module
.
cloudfront
.
this_cloudfront_distribution_hosted_zone_id
zone_id
=
module
.
cloudfront
.
this_cloudfront_distribution_hosted_zone_id
}
}
},
},
{
name
=
"test"
type
=
"CNAME"
ttl
=
"5"
records
=
[
"test.example.com."
]
set_identifier
=
"test-primary"
weighted_routing_policy
=
{
weight
=
90
}
},
{
name
=
"test"
type
=
"CNAME"
ttl
=
"5"
records
=
[
"test2.example.com."
]
set_identifier
=
"test-secondary"
weighted_routing_policy
=
{
weight
=
10
}
}
]
]
depends_on
=
[
module
.
zones
]
depends_on
=
[
module
.
zones
]
...
@@ -101,11 +121,9 @@ module "cloudfront" {
...
@@ -101,11 +121,9 @@ module "cloudfront" {
}
}
}
}
cache_behavior
=
{
default_cache_behavior
=
{
default
=
{
target_origin_id
=
"s3_bucket"
target_origin_id
=
"s3_bucket"
viewer_protocol_policy
=
"allow-all"
viewer_protocol_policy
=
"allow-all"
}
}
}
viewer_certificate
=
{
viewer_certificate
=
{
...
...
modules/records/main.tf
View file @
e87b6262
locals
{
locals
{
# convert from list to map with unique keys
# convert from list to map with unique keys
recordsets
=
{
for
rs
in
var
.
records
:
"
${
rs
.
name
}
${
rs
.
type
}
"
=
>
rs
}
recordsets
=
{
for
rs
in
var
.
records
:
join
(
" "
,
compact
(
[
"
${
rs
.
name
}
${
rs
.
type
}
"
,
lookup
(
rs
,
"set_identifier"
,
""
)
]
))
=
>
rs
}
}
}
data
"aws_route53_zone"
"this"
{
data
"aws_route53_zone"
"this"
{
...
@@ -16,10 +16,11 @@ resource "aws_route53_record" "this" {
...
@@ -16,10 +16,11 @@ resource "aws_route53_record" "this" {
zone_id
=
data
.
aws_route53_zone
.
this
[
0
]
.
zone_id
zone_id
=
data
.
aws_route53_zone
.
this
[
0
]
.
zone_id
name
=
each
.
value
.
name
!
=
""
?
"
${
each
.
value
.
name
}
.
${data
.
aws_route53_zone
.
this
[
0
].
name
}
"
:
data
.
aws_route53_zone
.
this
[
0
]
.
name
name
=
each
.
value
.
name
!
=
""
?
"
${
each
.
value
.
name
}
.
${data
.
aws_route53_zone
.
this
[
0
].
name
}
"
:
data
.
aws_route53_zone
.
this
[
0
]
.
name
type
=
each
.
value
.
type
type
=
each
.
value
.
type
ttl
=
lookup
(
each
.
value
,
"ttl"
,
null
)
ttl
=
lookup
(
each
.
value
,
"ttl"
,
null
)
records
=
lookup
(
each
.
value
,
"records"
,
null
)
records
=
lookup
(
each
.
value
,
"records"
,
null
)
set_identifier
=
lookup
(
each
.
value
,
"set_identifier"
,
null
)
dynamic
"alias"
{
dynamic
"alias"
{
for_each
=
length
(
keys
(
lookup
(
each
.
value
,
"alias"
,
{}
)))
==
0
?
[]
:
[
true
]
for_each
=
length
(
keys
(
lookup
(
each
.
value
,
"alias"
,
{}
)))
==
0
?
[]
:
[
true
]
...
@@ -30,4 +31,12 @@ resource "aws_route53_record" "this" {
...
@@ -30,4 +31,12 @@ resource "aws_route53_record" "this" {
evaluate_target_health
=
lookup
(
each
.
value
.
alias
,
"evaluate_target_health"
,
false
)
evaluate_target_health
=
lookup
(
each
.
value
.
alias
,
"evaluate_target_health"
,
false
)
}
}
}
}
dynamic
"weighted_routing_policy"
{
for_each
=
length
(
keys
(
lookup
(
each
.
value
,
"weighted_routing_policy"
,
{}
)))
==
0
?
[]
:
[
true
]
content
{
weight
=
each
.
value
.
weighted_routing_policy
.
weight
}
}
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment