AWS Route 53 Resolver Rule Association

This page shows how to write Terraform and CloudFormation for Route 53 Resolver Rule Association and write them securely.

aws_route53_resolver_rule_association (Terraform)

The Rule Association in Route 53 Resolver can be configured in Terraform with the resource name aws_route53_resolver_rule_association. The following sections describe 4 examples of how to use the resource and its parameters.

Example Usage from GitHub

12-route53.tf#L100
resource "aws_route53_resolver_rule_association" "eu_west1_cloudtuples_fwd" {
  resolver_rule_id = aws_route53_resolver_rule.eu_west1_cloudtuples_fwd.id
  vpc_id           = aws_vpc.vpc1.id
}

# apple.cloudtuple rule
spoke.tf#L31
resource "aws_route53_resolver_rule_association" "example" {
  resolver_rule_id = aws_route53_resolver_rule.sys.id
  vpc_id           = aws_vpc.foo.id
}

//dns route53 zone
route53-resolver.tf#L1
resource "aws_route53_resolver_rule_association" "rule" {
  for_each = toset(var.route53_resolver_rule_associations)

  name             = var.name
  resolver_rule_id = each.key
  vpc_id           = aws_vpc.vpc.id
main.tf#L18
resource "aws_route53_resolver_rule_association" "fwdrule" {
  count            = length(var.associated_vpcs)
  resolver_rule_id = aws_route53_resolver_rule.fwd.id
  vpc_id           = var.associated_vpcs[count.index]
}

Review your Terraform file for AWS best practices

Shisho Cloud, our free checker to make sure your Terraform configuration follows best practices, is available (beta).

Parameters

Explanation in Terraform Registry

Provides a Route53 Resolver rule association.

AWS::Route53Resolver::ResolverRuleAssociation (CloudFormation)

The ResolverRuleAssociation in Route53Resolver can be configured in CloudFormation with the resource name AWS::Route53Resolver::ResolverRuleAssociation. The following sections describe 10 examples of how to use the resource and its parameters.

Example Usage from GitHub

mini_project_singapore.yml#L671
    Type: AWS::Route53Resolver::ResolverRuleAssociation
    Properties:
      ResolverRuleId: !Ref OutboundRule
      VPCId: !Ref AWSVPC

#---------------------- Transit Gateway - VPN ----------------------#
Route53%20(2).yml#L481
    Type: AWS::Route53Resolver::ResolverRuleAssociation
    Properties:
      ResolverRuleId: !Ref OutboundRule
      VPCId: !Ref AWSVPC
demo.yml#L189
    Type: AWS::Route53Resolver::ResolverRuleAssociation
    Properties:
      ResolverRuleId: !GetAtt OutboundResolverRule.ResolverRuleId
      VPCId: !Ref Vpc
  InstanceRole:
    Type: AWS::IAM::Role
vpc.yml#L186
    Type: AWS::Route53Resolver::ResolverRuleAssociation
    Properties:
      Name: !Sub ${pProjectName}-VPC
      ResolverRuleId: !Ref pRuleId
      VPCId: !Ref rVpc
############ Lambda Function get available CIDR ############
route53-endpoints.yml#L110
    Type: "AWS::Route53Resolver::ResolverRuleAssociation"
    Properties:
      Name: stang-r53-resolver-rule-to-swa-association
      ResolverRuleId: !Ref rResolverRule1
      VPCId: !Ref VpcId
Route53ResolverResolverRuleAssociationSpecification.json#L3
    "AWS::Route53Resolver::ResolverRuleAssociation": {
      "Documentation": "http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-route53resolver-resolverruleassociation.html",
      "Attributes": {
        "VPCId": {
          "PrimitiveType": "String"
        },
Route53ResolverResolverRuleAssociationSpecification.json#L3
    "AWS::Route53Resolver::ResolverRuleAssociation": {
      "Documentation": "http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-route53resolver-resolverruleassociation.html",
      "Attributes": {
        "VPCId": {
          "PrimitiveType": "String"
        },
Route53ResolverResolverRuleAssociationSpecification.json#L3
    "AWS::Route53Resolver::ResolverRuleAssociation": {
      "Documentation": "http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-route53resolver-resolverruleassociation.html",
      "Attributes": {
        "VPCId": {
          "PrimitiveType": "String"
        },
Route53ResolverResolverRuleAssociationSpecification.json#L3
    "AWS::Route53Resolver::ResolverRuleAssociation": {
      "Documentation": "http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-route53resolver-resolverruleassociation.html",
      "Attributes": {
        "VPCId": {
          "PrimitiveType": "String"
        },
Route53ResolverResolverRuleAssociationSpecification.json#L3
    "AWS::Route53Resolver::ResolverRuleAssociation": {
      "Documentation": "http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-route53resolver-resolverruleassociation.html",
      "Attributes": {
        "VPCId": {
          "PrimitiveType": "String"
        },

Parameters

Explanation in CloudFormation Registry

In the response to an AssociateResolverRule, DisassociateResolverRule, or ListResolverRuleAssociations request, provides information about an association between a resolver rule and a VPC. The association determines which DNS queries that originate in the VPC are forwarded to your network.

Frequently asked questions

What is AWS Route 53 Resolver Rule Association?

AWS Route 53 Resolver Rule Association is a resource for Route 53 Resolver of Amazon Web Service. Settings can be wrote in Terraform and CloudFormation.

Where can I find the example code for the AWS Route 53 Resolver Rule Association?

For Terraform, the kaysal/cloud-networking, GSA/grace-paas-dns and cbfield/terraform-aws-vpc source code examples are useful. See the Terraform Example section for further details.

For CloudFormation, the yuntreee/CloudFormation, yuntreee/CloudFormation and greenaussie/demo_vpc_endpoints_with_ec2 source code examples are useful. See the CloudFormation Example section for further details.