-
Notifications
You must be signed in to change notification settings - Fork 657
Conversation
including additional attributes for latency and geolocation based route53 routing policies.
Terraform will complain if you use the same resource name for aws_route53_records. Make some effort to make them unique by appending a counter to the name.
end | ||
|
||
# TODO(dtan4): change method name... | ||
def name_of(dns_name) | ||
dns_name.gsub(/\.\z/, "") | ||
end | ||
|
||
def module_name_of(record) | ||
normalize_module_name(name_of(record.name) + "-" + record.type) | ||
def module_name_of(record, counter) |
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.
[method_definition_validator]
- Not enough arguments. Did you forget the following arguments? [counter] at lib/terraforming/resource/iam_user.rb#L32
- Not enough arguments. Did you forget the following arguments? [counter] at lib/terraforming/resource/eip.rb#L35
- Not enough arguments. Did you forget the following arguments? [counter] at lib/terraforming/resource/launch_configuration.rb#L48
- Not enough arguments. Did you forget the following arguments? [counter] at lib/terraforming/resource/internet_gateway.rb#L31
- Not enough arguments. Did you forget the following arguments? [counter] at lib/terraforming/resource/alb.rb#L40
- Not enough arguments. Did you forget the following arguments? [counter] at lib/terraforming/resource/elb.rb#L51
- Not enough arguments. Did you forget the following arguments? [counter] at lib/terraforming/resource/network_acl.rb#L32
- Not enough arguments. Did you forget the following arguments? [counter] at lib/terraforming/resource/kms_key.rb#L24
- Not enough arguments. Did you forget the following arguments? [counter] at lib/terraforming/resource/route53_zone.rb#L37
- Not enough arguments. Did you forget the following arguments? [counter] at lib/terraforming/resource/elasti_cache_cluster.rb#L45
- Not enough arguments. Did you forget the following arguments? [counter] at lib/terraforming/resource/elasti_cache_subnet_group.rb#L29
- Not enough arguments. Did you forget the following arguments? [counter] at lib/terraforming/resource/db_security_group.rb#L30
- Not enough arguments. Did you forget the following arguments? [counter] at lib/terraforming/resource/iam_policy_attachment.rb#L32
- Not enough arguments. Did you forget the following arguments? [counter] at lib/terraforming/resource/db_parameter_group.rb#L31
- Not enough arguments. Did you forget the following arguments? [counter] at lib/terraforming/resource/auto_scaling_group.rb#L52
- Not enough arguments. Did you forget the following arguments? [counter] at lib/terraforming/resource/iam_policy.rb#L32
- Not enough arguments. Did you forget the following arguments? [counter] at lib/terraforming/resource/cloud_watch_alarm.rb#L24
- Not enough arguments. Did you forget the following arguments? [counter] at lib/terraforming/resource/nat_gateway.rb#L34
- Not enough arguments. Did you forget the following arguments? [counter] at lib/terraforming/resource/vpc.rb#L32
- Not enough arguments. Did you forget the following arguments? [counter] at lib/terraforming/resource/iam_group_membership.rb#L32
- Not enough arguments. Did you forget the following arguments? [counter] at lib/terraforming/resource/network_interface.rb#L33
- Not enough arguments. Did you forget the following arguments? [counter] at lib/terraforming/resource/iam_instance_profile.rb#L31
- Not enough arguments. Did you forget the following arguments? [counter] at lib/terraforming/resource/efs_file_system.rb#L32
- Not enough arguments. Did you forget the following arguments? [counter] at lib/terraforming/resource/db_subnet_group.rb#L29
- Not enough arguments. Did you forget the following arguments? [counter] at lib/terraforming/resource/s3.rb#L25
- Not enough arguments. Did you forget the following arguments? [counter] at lib/terraforming/resource/security_group.rb#L36
- Not enough arguments. Did you forget the following arguments? [counter] at lib/terraforming/resource/sqs.rb#L25
- Not enough arguments. Did you forget the following arguments? [counter] at lib/terraforming/resource/sqs.rb#L36
- Not enough arguments. Did you forget the following arguments? [counter] at lib/terraforming/resource/redshift.rb#L44
- Not enough arguments. Did you forget the following arguments? [counter] at lib/terraforming/resource/iam_role.rb#L33
- Not enough arguments. Did you forget the following arguments? [counter] at lib/terraforming/resource/ec2.rb#L53
- Not enough arguments. Did you forget the following arguments? [counter] at lib/terraforming/resource/subnet.rb#L32
- Not enough arguments. Did you forget the following arguments? [counter] at lib/terraforming/resource/kms_alias.rb#L24
- Not enough arguments. Did you forget the following arguments? [counter] at lib/terraforming/resource/vpn_gateway.rb#L32
- Not enough arguments. Did you forget the following arguments? [counter] at lib/terraforming/resource/rds.rb#L51
- Not enough arguments. Did you forget the following arguments? [counter] at lib/terraforming/resource/iam_group.rb#L31
- Not enough arguments. Did you forget the following arguments? [counter] at lib/terraforming/resource/route_table.rb#L33
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.
It appears as though each resource type has its own module_name_of()
method, so changing how the route53_record
one works should be independent of the other ones.
record_sets_of(hosted_zone).map { |record| { record: record, zone_id: zone_id_of(hosted_zone) } } | ||
end.flatten | ||
count = {} | ||
dups = to_return.group_by{ |record| module_name_of(record[:record], nil) }.select { |k, v| v.size > 1 }.map(&:first) |
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.
[rubocop]
- Space missing to the left of {.
- Unused block argument -
k
. If it's necessary, use_
or_k
as an argument name to indicate that it won't be used. :ref
dups = to_return.group_by{ |record| module_name_of(record[:record], nil) }.select { |k, v| v.size > 1 }.map(&:first) | ||
to_return.each do |r| | ||
module_name = module_name_of(r[:record], nil) | ||
if dups.include?(module_name) |
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.
[rubocop]
- Use
next
to skip iteration. :ref
to_return.each do |r| | ||
module_name = module_name_of(r[:record], nil) | ||
if dups.include?(module_name) | ||
if count[module_name] |
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.
[rubocop]
- Use the return of the conditional for variable assignment and comparison.
module_name = module_name_of(r[:record], nil) | ||
if dups.include?(module_name) | ||
if count[module_name] | ||
count[module_name] = count[module_name] + 1 |
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.
[rubocop]
- Use 2 (not -19) spaces for indentation. :ref
if dups.include?(module_name) | ||
if count[module_name] | ||
count[module_name] = count[module_name] + 1 | ||
else |
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.
[rubocop]
- Align
else
withif
.
if count[module_name] | ||
count[module_name] = count[module_name] + 1 | ||
else | ||
count[module_name] = 0 |
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.
[rubocop]
- Use 2 (not -19) spaces for indentation. :ref
end | ||
|
||
# TODO(dtan4): change method name... | ||
def name_of(dns_name) | ||
dns_name.gsub(/\.\z/, "") | ||
end | ||
|
||
def module_name_of(record) | ||
normalize_module_name(name_of(record.name) + "-" + record.type) | ||
def module_name_of(record, counter) |
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.
[method_definition_validator]
- Not enough arguments. Did you forget the following arguments? [counter] at lib/terraforming/resource/iam_user.rb#L32
- Not enough arguments. Did you forget the following arguments? [counter] at lib/terraforming/resource/eip.rb#L35
- Not enough arguments. Did you forget the following arguments? [counter] at lib/terraforming/resource/launch_configuration.rb#L48
- Not enough arguments. Did you forget the following arguments? [counter] at lib/terraforming/resource/internet_gateway.rb#L31
- Not enough arguments. Did you forget the following arguments? [counter] at lib/terraforming/resource/alb.rb#L40
- Not enough arguments. Did you forget the following arguments? [counter] at lib/terraforming/resource/elb.rb#L51
- Not enough arguments. Did you forget the following arguments? [counter] at lib/terraforming/resource/network_acl.rb#L32
- Not enough arguments. Did you forget the following arguments? [counter] at lib/terraforming/resource/kms_key.rb#L24
- Not enough arguments. Did you forget the following arguments? [counter] at lib/terraforming/resource/route53_zone.rb#L37
- Not enough arguments. Did you forget the following arguments? [counter] at lib/terraforming/resource/elasti_cache_cluster.rb#L45
- Not enough arguments. Did you forget the following arguments? [counter] at lib/terraforming/resource/elasti_cache_subnet_group.rb#L29
- Not enough arguments. Did you forget the following arguments? [counter] at lib/terraforming/resource/db_security_group.rb#L30
- Not enough arguments. Did you forget the following arguments? [counter] at lib/terraforming/resource/iam_policy_attachment.rb#L32
- Not enough arguments. Did you forget the following arguments? [counter] at lib/terraforming/resource/db_parameter_group.rb#L31
- Not enough arguments. Did you forget the following arguments? [counter] at lib/terraforming/resource/auto_scaling_group.rb#L52
- Not enough arguments. Did you forget the following arguments? [counter] at lib/terraforming/resource/iam_policy.rb#L32
- Not enough arguments. Did you forget the following arguments? [counter] at lib/terraforming/resource/cloud_watch_alarm.rb#L24
- Not enough arguments. Did you forget the following arguments? [counter] at lib/terraforming/resource/nat_gateway.rb#L34
- Not enough arguments. Did you forget the following arguments? [counter] at lib/terraforming/resource/vpc.rb#L32
- Not enough arguments. Did you forget the following arguments? [counter] at lib/terraforming/resource/iam_group_membership.rb#L32
- Not enough arguments. Did you forget the following arguments? [counter] at lib/terraforming/resource/network_interface.rb#L33
- Not enough arguments. Did you forget the following arguments? [counter] at lib/terraforming/resource/iam_instance_profile.rb#L31
- Not enough arguments. Did you forget the following arguments? [counter] at lib/terraforming/resource/efs_file_system.rb#L32
- Not enough arguments. Did you forget the following arguments? [counter] at lib/terraforming/resource/db_subnet_group.rb#L29
- Not enough arguments. Did you forget the following arguments? [counter] at lib/terraforming/resource/s3.rb#L25
- Not enough arguments. Did you forget the following arguments? [counter] at lib/terraforming/resource/security_group.rb#L36
- Not enough arguments. Did you forget the following arguments? [counter] at lib/terraforming/resource/sqs.rb#L25
- Not enough arguments. Did you forget the following arguments? [counter] at lib/terraforming/resource/sqs.rb#L36
- Not enough arguments. Did you forget the following arguments? [counter] at lib/terraforming/resource/redshift.rb#L44
- Not enough arguments. Did you forget the following arguments? [counter] at lib/terraforming/resource/iam_role.rb#L33
- Not enough arguments. Did you forget the following arguments? [counter] at lib/terraforming/resource/ec2.rb#L53
- Not enough arguments. Did you forget the following arguments? [counter] at lib/terraforming/resource/subnet.rb#L32
- Not enough arguments. Did you forget the following arguments? [counter] at lib/terraforming/resource/kms_alias.rb#L24
- Not enough arguments. Did you forget the following arguments? [counter] at lib/terraforming/resource/vpn_gateway.rb#L32
- Not enough arguments. Did you forget the following arguments? [counter] at lib/terraforming/resource/rds.rb#L51
- Not enough arguments. Did you forget the following arguments? [counter] at lib/terraforming/resource/iam_group.rb#L31
- Not enough arguments. Did you forget the following arguments? [counter] at lib/terraforming/resource/route_table.rb#L33
@@ -108,7 +108,9 @@ module Resource | |||
zone_id = "OPQRSTUVWXYZAB" | |||
name = "www.fuga.net" | |||
type = "A" | |||
weight = 10 | |||
weighted_routing_policy { | |||
weight = 10 |
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.
Please use 4-spaces indention, like alias.name
below.
attributes["continent"] = record.geo_location.continent_code if record.geo_location.continent_code | ||
attributes["country"] = record.geo_location.country_code if record.geo_location.country_code | ||
attributes["subdivision"] = record.geo_location.subdivision_code if record.geo_location.subdivision_code | ||
end |
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.
Please add empty lines before if
and after end
.
attributes["region"] = record.region if record.region
if record.geo_location
# ...
end
attributes["set_identifier"] = record.set_identifier if record.set_identifier
Is there any case where the resource names were duplicated? |
Thanks for adding this @mioi ! |
end | ||
|
||
# TODO(dtan4): change method name... | ||
def name_of(dns_name) | ||
dns_name.gsub(/\.\z/, "") | ||
end | ||
|
||
def module_name_of(record) | ||
normalize_module_name(name_of(record.name) + "-" + record.type) | ||
def module_name_of(record, counter) |
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.
[method_definition_validator]
- Not enough arguments. Did you forget the following arguments? [counter] at lib/terraforming/resource/iam_user.rb#L32
- Not enough arguments. Did you forget the following arguments? [counter] at lib/terraforming/resource/eip.rb#L35
- Not enough arguments. Did you forget the following arguments? [counter] at lib/terraforming/resource/launch_configuration.rb#L48
- Not enough arguments. Did you forget the following arguments? [counter] at lib/terraforming/resource/internet_gateway.rb#L31
- Not enough arguments. Did you forget the following arguments? [counter] at lib/terraforming/resource/alb.rb#L40
- Not enough arguments. Did you forget the following arguments? [counter] at lib/terraforming/resource/elb.rb#L51
- Not enough arguments. Did you forget the following arguments? [counter] at lib/terraforming/resource/network_acl.rb#L32
- Not enough arguments. Did you forget the following arguments? [counter] at lib/terraforming/resource/kms_key.rb#L24
- Not enough arguments. Did you forget the following arguments? [counter] at lib/terraforming/resource/route53_zone.rb#L37
- Not enough arguments. Did you forget the following arguments? [counter] at lib/terraforming/resource/elasti_cache_cluster.rb#L45
- Not enough arguments. Did you forget the following arguments? [counter] at lib/terraforming/resource/elasti_cache_subnet_group.rb#L29
- Not enough arguments. Did you forget the following arguments? [counter] at lib/terraforming/resource/db_security_group.rb#L30
- Not enough arguments. Did you forget the following arguments? [counter] at lib/terraforming/resource/iam_policy_attachment.rb#L32
- Not enough arguments. Did you forget the following arguments? [counter] at lib/terraforming/resource/db_parameter_group.rb#L31
- Not enough arguments. Did you forget the following arguments? [counter] at lib/terraforming/resource/auto_scaling_group.rb#L52
- Not enough arguments. Did you forget the following arguments? [counter] at lib/terraforming/resource/iam_policy.rb#L32
- Not enough arguments. Did you forget the following arguments? [counter] at lib/terraforming/resource/cloud_watch_alarm.rb#L24
- Not enough arguments. Did you forget the following arguments? [counter] at lib/terraforming/resource/nat_gateway.rb#L34
- Not enough arguments. Did you forget the following arguments? [counter] at lib/terraforming/resource/vpc.rb#L32
- Not enough arguments. Did you forget the following arguments? [counter] at lib/terraforming/resource/iam_group_membership.rb#L32
- Not enough arguments. Did you forget the following arguments? [counter] at lib/terraforming/resource/network_interface.rb#L33
- Not enough arguments. Did you forget the following arguments? [counter] at lib/terraforming/resource/iam_instance_profile.rb#L31
- Not enough arguments. Did you forget the following arguments? [counter] at lib/terraforming/resource/efs_file_system.rb#L32
- Not enough arguments. Did you forget the following arguments? [counter] at lib/terraforming/resource/db_subnet_group.rb#L29
- Not enough arguments. Did you forget the following arguments? [counter] at lib/terraforming/resource/s3.rb#L25
- Not enough arguments. Did you forget the following arguments? [counter] at lib/terraforming/resource/security_group.rb#L36
- Not enough arguments. Did you forget the following arguments? [counter] at lib/terraforming/resource/sqs.rb#L25
- Not enough arguments. Did you forget the following arguments? [counter] at lib/terraforming/resource/sqs.rb#L36
- Not enough arguments. Did you forget the following arguments? [counter] at lib/terraforming/resource/redshift.rb#L44
- Not enough arguments. Did you forget the following arguments? [counter] at lib/terraforming/resource/iam_role.rb#L33
- Not enough arguments. Did you forget the following arguments? [counter] at lib/terraforming/resource/ec2.rb#L53
- Not enough arguments. Did you forget the following arguments? [counter] at lib/terraforming/resource/subnet.rb#L32
- Not enough arguments. Did you forget the following arguments? [counter] at lib/terraforming/resource/kms_alias.rb#L24
- Not enough arguments. Did you forget the following arguments? [counter] at lib/terraforming/resource/vpn_gateway.rb#L32
- Not enough arguments. Did you forget the following arguments? [counter] at lib/terraforming/resource/rds.rb#L51
- Not enough arguments. Did you forget the following arguments? [counter] at lib/terraforming/resource/iam_group.rb#L31
- Not enough arguments. Did you forget the following arguments? [counter] at lib/terraforming/resource/route_table.rb#L33
@dtan4 in response to "Is there any case where the resource names were duplicated?": Yes. When there are Route53 records with the same |
Thanks, I see. LGTM 👍 Thanks ❗️ |
Released as v0.13.1. |
This PR is for a couple of changes for resources of
aws_route53_record
type:weight
should be wrapped in aweighted_routing_policy {}
block.