Data Source: awsRoute53TrafficPolicyDocument
Generates an Route53 traffic policy document in JSON format for use with resources that expect policy documents such as awsRoute53TrafficPolicy
.
Example Usage
Basic Example
/*Provider bindings are generated by running cdktf get.
See https://cdk.tf/provider-generation for more details.*/
import * as aws from "./.gen/providers/aws";
const dataAwsRegionCurrent = new aws.dataAwsRegion.DataAwsRegion(
this,
"current",
{}
);
const dataAwsRoute53TrafficPolicyDocumentExample =
new aws.dataAwsRoute53TrafficPolicyDocument.DataAwsRoute53TrafficPolicyDocument(
this,
"example",
{
endpoint: [
{
id: "my_elb",
type: "elastic-load-balancer",
value: `elb-111111.\${${dataAwsRegionCurrent.name}}.elb.amazonaws.com`,
},
{
id: "site_down_banner",
region: dataAwsRegionCurrent.name,
type: "s3-website",
value: "www.example.com",
},
],
recordType: "A",
rule: [
{
id: "site_switch",
primary: {
endpointReference: "my_elb",
},
secondary: {
endpointReference: "site_down_banner",
},
type: "failover",
},
],
startRule: "site_switch",
}
);
const awsRoute53TrafficPolicyExample =
new aws.route53TrafficPolicy.Route53TrafficPolicy(this, "example_2", {
comment: "example comment",
document: dataAwsRoute53TrafficPolicyDocumentExample.json,
name: "example",
});
/*This allows the Terraform resource name to match the original name. You can remove the call if you don't need them to match.*/
awsRoute53TrafficPolicyExample.overrideLogicalId("example");
Complex Example
The following example showcases the use of nested rules within the traffic policy document and introduces the geoproximity
rule type.
/*Provider bindings are generated by running cdktf get.
See https://cdk.tf/provider-generation for more details.*/
import * as aws from "./.gen/providers/aws";
const dataAwsRoute53TrafficPolicyDocumentExample =
new aws.dataAwsRoute53TrafficPolicyDocument.DataAwsRoute53TrafficPolicyDocument(
this,
"example",
{
endpoint: [
{
id: "na_endpoint_a",
type: "elastic-load-balancer",
value: "elb-111111.us-west-1.elb.amazonaws.com",
},
{
id: "na_endpoint_b",
type: "elastic-load-balancer",
value: "elb-222222.us-west-1.elb.amazonaws.com",
},
{
id: "eu_endpoint",
type: "elastic-load-balancer",
value: "elb-333333.eu-west-1.elb.amazonaws.com",
},
{
id: "ap_endpoint",
type: "elastic-load-balancer",
value: "elb-444444.ap-northeast-2.elb.amazonaws.com",
},
],
recordType: "A",
rule: [
{
id: "na_rule",
primary: {
endpointReference: "na_endpoint_a",
},
secondary: {
endpointReference: "na_endpoint_b",
},
type: "failover",
},
{
geoProximityLocation: [
{
bias: 10,
evaluateTargetHealth: true,
region: "aws:route53:us-west-1",
ruleReference: "na_rule",
},
{
bias: 10,
endpointReference: "eu_endpoint",
evaluateTargetHealth: true,
region: "aws:route53:eu-west-1",
},
{
bias: 0,
endpointReference: "ap_endpoint",
evaluateTargetHealth: true,
region: "aws:route53:ap-northeast-2",
},
],
id: "geoproximity_rule",
type: "geoproximity",
},
],
startRule: "geoproximity_rule",
}
);
const awsRoute53TrafficPolicyExample =
new aws.route53TrafficPolicy.Route53TrafficPolicy(this, "example_1", {
comment: "example comment",
document: dataAwsRoute53TrafficPolicyDocumentExample.json,
name: "example",
});
/*This allows the Terraform resource name to match the original name. You can remove the call if you don't need them to match.*/
awsRoute53TrafficPolicyExample.overrideLogicalId("example");
Argument Reference
The following arguments are optional:
endpoint
(Optional) - Configuration block for the definitions of the endpoints that you want to use in this traffic policy. See belowrecordType
(Optional) - DNS type of all of the resource record sets that Amazon Route 53 will create based on this traffic policy.rule
(Optional) - Configuration block for definitions of the rules that you want to use in this traffic policy. See belowstartEndpoint
(Optional) - An endpoint to be as the starting point for the traffic policy.startRule
(Optional) - A rule to be as the starting point for the traffic policy.version
(Optional) - Version of the traffic policy format.
endpoint
id
- (Required) ID of an endpoint you want to assign.type
- (Optional) Type of the endpoint. Valid values arevalue
,cloudfront
,elasticLoadBalancer
,s3Website
region
- (Optional) To route traffic to an Amazon S3 bucket that is configured as a website endpoint, specify the region in which you created the bucket forregion
.value
- (Optional) Value of thetype
.
rule
id
- (Required) ID of a rule you want to assign.type
- (Optional) Type of the rule.primary
- (Optional) Configuration block for the settings for the rule or endpoint that you want to route traffic to whenever the corresponding resources are available. Only valid forfailover
type. See belowsecondary
- (Optional) Configuration block for the rule or endpoint that you want to route traffic to whenever the primary resources are not available. Only valid forfailover
type. See belowlocation
- (Optional) Configuration block for when you add a geolocation rule, you configure your traffic policy to route your traffic based on the geographic location of your users. Only valid forgeo
type. See belowgeoProximityLocation
- (Optional) Configuration block for when you add a geoproximity rule, you configure Amazon Route 53 to route traffic to your resources based on the geographic location of your resources. Only valid forgeoproximity
type. See belowregions
- (Optional) Configuration block for when you add a latency rule, you configure your traffic policy to route your traffic based on the latency (the time delay) between your users and the AWS regions where you've created AWS resources such as ELB load balancers and Amazon S3 buckets. Only valid forlatency
type. See belowitems
- (Optional) Configuration block for when you add a multivalue answer rule, you configure your traffic policy to route traffic approximately randomly to your healthy resources. Only valid formultivalue
type. See below
primary
and secondary
endpointReference
- (Optional) References to an endpoint.evaluateTargetHealth
- (Optional) Indicates whether you want Amazon Route 53 to evaluate the health of the endpoint and route traffic only to healthy endpoints.healthCheck
- (Optional) If you want to associate a health check with the endpoint or rule.ruleReference
- (Optional) References to a rule.
location
continent
- (Optional) Value of a continent.country
- (Optional) Value of a country.endpointReference
- (Optional) References to an endpoint.evaluateTargetHealth
- (Optional) Indicates whether you want Amazon Route 53 to evaluate the health of the endpoint and route traffic only to healthy endpoints.healthCheck
- (Optional) If you want to associate a health check with the endpoint or rule.isDefault
- (Optional) Indicates whether this set of values represents the default location.ruleReference
- (Optional) References to a rule.subdivision
- (Optional) Value of a subdivision.
geoProximityLocation
bias
- (Optional) Specify a value forbias
if you want to route more traffic to an endpoint from nearby endpoints (positive values) or route less traffic to an endpoint (negative values).endpointReference
- (Optional) References to an endpoint.evaluateTargetHealth
- (Optional) Indicates whether you want Amazon Route 53 to evaluate the health of the endpoint and route traffic only to healthy endpoints.healthCheck
- (Optional) If you want to associate a health check with the endpoint or rule.latitude
- (Optional) Represents the location south (negative) or north (positive) of the equator. Valid values are -90 degrees to 90 degrees.longitude
- (Optional) Represents the location west (negative) or east (positive) of the prime meridian. Valid values are -180 degrees to 180 degrees.region
- (Optional) If your endpoint is an AWS resource, specify the AWS Region that you created the resource in.ruleReference
- (Optional) References to a rule.
region
endpointReference
- (Optional) References to an endpoint.evaluateTargetHealth
- (Optional) Indicates whether you want Amazon Route 53 to evaluate the health of the endpoint and route traffic only to healthy endpoints.healthCheck
- (Optional) If you want to associate a health check with the endpoint or rule.region
- (Optional) Region code for the AWS Region that you created the resource in.ruleReference
- (Optional) References to a rule.
item
endpointReference
- (Optional) References to an endpoint.healthCheck
- (Optional) If you want to associate a health check with the endpoint or rule.
Attributes Reference
The following attribute is exported:
json
- Standard JSON policy document rendered based on the arguments above.