Manage Route53 records with Boto 3
New in version 2017.7.0.
Create and delete Route53 records. Be aware that this interacts with Amazon’s services, and so may incur charges.
This module uses boto3
, which can be installed via package, or pip.
This module accepts explicit route53 credentials but can also utilize IAM roles assigned to the instance through Instance Profiles. Dynamic credentials are then automatically obtained from AWS API and no further configuration is necessary. More information available here.
If IAM roles are not used you need to specify them either in a pillar file or in the minion’s config file:
route53.keyid: GKTADJGHEIQSXMKKRBJ08H
route53.key: askdjghsdfjkghWupUjasdflkdfklgjsdfjajkghs
It’s also possible to specify key
, keyid
and region
via a profile, either
passed in as a dict, or as a string to pull from pillars or minion config:
myprofile:
keyid: GKTADJGHEIQSXMKKRBJ08H
key: askdjghsdfjkghWupUjasdflkdfklgjsdfjajkghs
region: us-east-1
An exciting new AWS Route 53 Hosted Zone:
boto_route53.hosted_zone_present:
- Name: example.com.
- PrivateZone: true
- VPCs:
- VPCName: MyLittleVPC
VPCRegion: us-east-1
- VPCId: vpc-12345678
- region: us-east-1
- keyid: GKTADJGHEIQSXMKKRBJ08H
- key: askdjghsdfjkghWupUjasdflkdfklgjsdfjajkghs
mycnamerecord:
boto_route53.rr_present:
- Name: test.example.com.
- ResourceRecords:
- my-elb.us-east-1.elb.amazonaws.com.
- DomainName: example.com.
- TTL: 60
- Type: CNAME
- region: us-east-1
- keyid: GKTADJGHEIQSXMKKRBJ08H
- key: askdjghsdfjkghWupUjasdflkdfklgjsdfjajkghs
salt.states.boto3_route53.
hosted_zone_absent
(name, Name=None, PrivateZone=False, region=None, key=None, keyid=None, profile=None)¶Ensure the Route53 Hostes Zone described is absent
salt.states.boto3_route53.
hosted_zone_present
(name, Name=None, PrivateZone=False, CallerReference=None, Comment=None, VPCs=None, region=None, key=None, keyid=None, profile=None)¶Ensure a hosted zone exists with the given attributes.
A list of dicts, each dict composed of a VPCRegion, and either a VPCId or a VPCName. Note that this param is ONLY used if PrivateZone == True
salt.states.boto3_route53.
rr_absent
(name, HostedZoneId=None, DomainName=None, PrivateZone=False, Name=None, Type=None, SetIdentifier=None, region=None, key=None, keyid=None, profile=None)¶Ensure the Route53 record is deleted.
salt.states.boto3_route53.
rr_present
(name, HostedZoneId=None, DomainName=None, PrivateZone=False, Name=None, Type=None, SetIdentifier=None, Weight=None, Region=None, GeoLocation=None, Failover=None, TTL=None, ResourceRecords=None, AliasTarget=None, HealthCheckId=None, TrafficPolicyInstanceId=None, region=None, key=None, keyid=None, profile=None)¶Ensure the Route53 record is present.
Valid for Weighted resource record sets only. Among resource record sets that have the same combination of DNS name and type, a value that determines the proportion of DNS queries that Amazon Route 53 responds to using the current resource record set. Amazon Route 53 calculates the sum of the weights for the resource record sets that have the same combination of DNS name and type. Amazon Route 53 then responds to queries based on the ratio of a resource’s weight to the total.
Note the following:
Geo location resource record sets only. A dict that lets you control how Route 53 responds to DNS queries based on the geographic origin of the query. For example, if you want all queries from Africa to be routed to a web server with an IP address of 192.0.2.111, create a resource record set with a Type of A and a ContinentCode of AF.
ContinentCode
The two-letter code for the continent.
Valid values: AF | AN | AS | EU | OC | NA | SA
Constraint: Specifying ContinentCode with either CountryCode or SubdivisionCode
returns an InvalidInput error.
CountryCode
The two-letter code for the country.
SubdivisionCode
The code for the subdivision, for example, a state in the United States or a
province in Canada.
Notes
*
in the CountryCode element matches all geographic locations that aren’t
specified in other geolocation resource record sets that have the same values for the
Name and Type elements.*
, which handles both queries that come from locations for which you
haven’t created geolocation resource record sets and queries from IP
addresses that aren’t mapped to a location. If you don’t create a *
resource record set, Amazon Route 53 returns a “no answer” response
for queries from those locations.The resource record cache time to live (TTL), in seconds. Note the following:
A list, containing one or more values for the resource record. No single value can exceed 4,000 characters. For details on how to format values for different record types, see Supported DNS Resource Record Types in the Amazon Route 53 Developer Guide.
Note: You can specify more than one value for all record types except CNAME and SOA.
It is also possible to pass “magic” strings as resource record values. This functionality can easily be extended, but for the moment supports the following:
‘magic:ec2_instance_tag:some_tag_name:some_string:some_instance_attr’
This tells salt to lookup an EC2 instance with a tag ‘some_tag_name’ which has the value ‘some_string’ and substitute the ‘some_instance_attr’ attribute of that instance as the resource record value being evaluated.
This should work generally for any EC2 instance tags, as long as the instance attribute being fetched is available to getattr(instance, ‘attribute’) as seen in the code below. Anything else will most likely require this function to be extended to handle it.
The canonical use-case for this (at least at our site) is to query the Name tag (which we always populate with the host’s FQDN) to lookup the public or private IPs bound to the instance, so we can then automgically create Route 53 records for them.
Docs for previous releases are available on readthedocs.org.
Latest Salt release: 2018.3.3
salt.states.boto3_elasticache module