github.com/pulumi/pulumi-aws/sdk/v6@v6.32.0/go/aws/route53/getTrafficPolicyDocument.go (about) 1 // Code generated by the Pulumi Terraform Bridge (tfgen) Tool DO NOT EDIT. 2 // *** WARNING: Do not edit by hand unless you're certain you know what you are doing! *** 3 4 package route53 5 6 import ( 7 "context" 8 "reflect" 9 10 "github.com/pulumi/pulumi-aws/sdk/v6/go/aws/internal" 11 "github.com/pulumi/pulumi/sdk/v3/go/pulumi" 12 ) 13 14 // Generates an Route53 traffic policy document in JSON format for use with resources that expect policy documents such as `route53.TrafficPolicy`. 15 // 16 // ## Example Usage 17 // 18 // ### Basic Example 19 // 20 // <!--Start PulumiCodeChooser --> 21 // ```go 22 // package main 23 // 24 // import ( 25 // 26 // "fmt" 27 // 28 // "github.com/pulumi/pulumi-aws/sdk/v6/go/aws" 29 // "github.com/pulumi/pulumi-aws/sdk/v6/go/aws/route53" 30 // "github.com/pulumi/pulumi/sdk/v3/go/pulumi" 31 // 32 // ) 33 // 34 // func main() { 35 // pulumi.Run(func(ctx *pulumi.Context) error { 36 // current, err := aws.GetRegion(ctx, nil, nil) 37 // if err != nil { 38 // return err 39 // } 40 // example, err := route53.GetTrafficPolicyDocument(ctx, &route53.GetTrafficPolicyDocumentArgs{ 41 // RecordType: pulumi.StringRef("A"), 42 // StartRule: pulumi.StringRef("site_switch"), 43 // Endpoints: []route53.GetTrafficPolicyDocumentEndpoint{ 44 // { 45 // Id: "my_elb", 46 // Type: pulumi.StringRef("elastic-load-balancer"), 47 // Value: pulumi.StringRef(fmt.Sprintf("elb-111111.%v.elb.amazonaws.com", current.Name)), 48 // }, 49 // { 50 // Id: "site_down_banner", 51 // Type: pulumi.StringRef("s3-website"), 52 // Region: pulumi.StringRef(current.Name), 53 // Value: pulumi.StringRef("www.example.com"), 54 // }, 55 // }, 56 // Rules: []route53.GetTrafficPolicyDocumentRule{ 57 // { 58 // Id: "site_switch", 59 // Type: pulumi.StringRef("failover"), 60 // Primary: { 61 // EndpointReference: pulumi.StringRef("my_elb"), 62 // }, 63 // Secondary: { 64 // EndpointReference: pulumi.StringRef("site_down_banner"), 65 // }, 66 // }, 67 // }, 68 // }, nil) 69 // if err != nil { 70 // return err 71 // } 72 // _, err = route53.NewTrafficPolicy(ctx, "example", &route53.TrafficPolicyArgs{ 73 // Name: pulumi.String("example"), 74 // Comment: pulumi.String("example comment"), 75 // Document: pulumi.String(example.Json), 76 // }) 77 // if err != nil { 78 // return err 79 // } 80 // return nil 81 // }) 82 // } 83 // 84 // ``` 85 // <!--End PulumiCodeChooser --> 86 // 87 // ### Complex Example 88 // 89 // The following example showcases the use of nested rules within the traffic policy document and introduces the `geoproximity` rule type. 90 // 91 // <!--Start PulumiCodeChooser --> 92 // ```go 93 // package main 94 // 95 // import ( 96 // 97 // "github.com/pulumi/pulumi-aws/sdk/v6/go/aws/route53" 98 // "github.com/pulumi/pulumi/sdk/v3/go/pulumi" 99 // 100 // ) 101 // 102 // func main() { 103 // pulumi.Run(func(ctx *pulumi.Context) error { 104 // example, err := route53.GetTrafficPolicyDocument(ctx, &route53.GetTrafficPolicyDocumentArgs{ 105 // RecordType: pulumi.StringRef("A"), 106 // StartRule: pulumi.StringRef("geoproximity_rule"), 107 // Endpoints: []route53.GetTrafficPolicyDocumentEndpoint{ 108 // { 109 // Id: "na_endpoint_a", 110 // Type: pulumi.StringRef("elastic-load-balancer"), 111 // Value: pulumi.StringRef("elb-111111.us-west-1.elb.amazonaws.com"), 112 // }, 113 // { 114 // Id: "na_endpoint_b", 115 // Type: pulumi.StringRef("elastic-load-balancer"), 116 // Value: pulumi.StringRef("elb-222222.us-west-1.elb.amazonaws.com"), 117 // }, 118 // { 119 // Id: "eu_endpoint", 120 // Type: pulumi.StringRef("elastic-load-balancer"), 121 // Value: pulumi.StringRef("elb-333333.eu-west-1.elb.amazonaws.com"), 122 // }, 123 // { 124 // Id: "ap_endpoint", 125 // Type: pulumi.StringRef("elastic-load-balancer"), 126 // Value: pulumi.StringRef("elb-444444.ap-northeast-2.elb.amazonaws.com"), 127 // }, 128 // }, 129 // Rules: pulumi.Array{ 130 // route53.GetTrafficPolicyDocumentRule{ 131 // Id: "na_rule", 132 // Type: pulumi.StringRef("failover"), 133 // Primary: route53.GetTrafficPolicyDocumentRulePrimary{ 134 // EndpointReference: pulumi.StringRef("na_endpoint_a"), 135 // }, 136 // Secondary: route53.GetTrafficPolicyDocumentRuleSecondary{ 137 // EndpointReference: pulumi.StringRef("na_endpoint_b"), 138 // }, 139 // }, 140 // route53.GetTrafficPolicyDocumentRule{ 141 // Id: "geoproximity_rule", 142 // Type: pulumi.StringRef("geoproximity"), 143 // GeoProximityLocations: []route53.GetTrafficPolicyDocumentRuleGeoProximityLocation{ 144 // { 145 // Region: pulumi.StringRef("aws:route53:us-west-1"), 146 // Bias: pulumi.StringRef("10"), 147 // EvaluateTargetHealth: pulumi.BoolRef(true), 148 // RuleReference: pulumi.StringRef("na_rule"), 149 // }, 150 // { 151 // Region: pulumi.StringRef("aws:route53:eu-west-1"), 152 // Bias: pulumi.StringRef("10"), 153 // EvaluateTargetHealth: pulumi.BoolRef(true), 154 // EndpointReference: pulumi.StringRef("eu_endpoint"), 155 // }, 156 // { 157 // Region: pulumi.StringRef("aws:route53:ap-northeast-2"), 158 // Bias: pulumi.StringRef("0"), 159 // EvaluateTargetHealth: pulumi.BoolRef(true), 160 // EndpointReference: pulumi.StringRef("ap_endpoint"), 161 // }, 162 // }, 163 // }, 164 // }, 165 // }, nil) 166 // if err != nil { 167 // return err 168 // } 169 // _, err = route53.NewTrafficPolicy(ctx, "example", &route53.TrafficPolicyArgs{ 170 // Name: pulumi.String("example"), 171 // Comment: pulumi.String("example comment"), 172 // Document: pulumi.String(example.Json), 173 // }) 174 // if err != nil { 175 // return err 176 // } 177 // return nil 178 // }) 179 // } 180 // 181 // ``` 182 // <!--End PulumiCodeChooser --> 183 func GetTrafficPolicyDocument(ctx *pulumi.Context, args *GetTrafficPolicyDocumentArgs, opts ...pulumi.InvokeOption) (*GetTrafficPolicyDocumentResult, error) { 184 opts = internal.PkgInvokeDefaultOpts(opts) 185 var rv GetTrafficPolicyDocumentResult 186 err := ctx.Invoke("aws:route53/getTrafficPolicyDocument:getTrafficPolicyDocument", args, &rv, opts...) 187 if err != nil { 188 return nil, err 189 } 190 return &rv, nil 191 } 192 193 // A collection of arguments for invoking getTrafficPolicyDocument. 194 type GetTrafficPolicyDocumentArgs struct { 195 // Configuration block for the definitions of the endpoints that you want to use in this traffic policy. See below 196 Endpoints []GetTrafficPolicyDocumentEndpoint `pulumi:"endpoints"` 197 // DNS type of all of the resource record sets that Amazon Route 53 will create based on this traffic policy. 198 RecordType *string `pulumi:"recordType"` 199 // Configuration block for definitions of the rules that you want to use in this traffic policy. See below 200 Rules []GetTrafficPolicyDocumentRule `pulumi:"rules"` 201 // An endpoint to be as the starting point for the traffic policy. 202 StartEndpoint *string `pulumi:"startEndpoint"` 203 // A rule to be as the starting point for the traffic policy. 204 StartRule *string `pulumi:"startRule"` 205 // Version of the traffic policy format. 206 Version *string `pulumi:"version"` 207 } 208 209 // A collection of values returned by getTrafficPolicyDocument. 210 type GetTrafficPolicyDocumentResult struct { 211 Endpoints []GetTrafficPolicyDocumentEndpoint `pulumi:"endpoints"` 212 // The provider-assigned unique ID for this managed resource. 213 Id string `pulumi:"id"` 214 // Standard JSON policy document rendered based on the arguments above. 215 Json string `pulumi:"json"` 216 RecordType *string `pulumi:"recordType"` 217 Rules []GetTrafficPolicyDocumentRule `pulumi:"rules"` 218 StartEndpoint *string `pulumi:"startEndpoint"` 219 StartRule *string `pulumi:"startRule"` 220 Version *string `pulumi:"version"` 221 } 222 223 func GetTrafficPolicyDocumentOutput(ctx *pulumi.Context, args GetTrafficPolicyDocumentOutputArgs, opts ...pulumi.InvokeOption) GetTrafficPolicyDocumentResultOutput { 224 return pulumi.ToOutputWithContext(context.Background(), args). 225 ApplyT(func(v interface{}) (GetTrafficPolicyDocumentResult, error) { 226 args := v.(GetTrafficPolicyDocumentArgs) 227 r, err := GetTrafficPolicyDocument(ctx, &args, opts...) 228 var s GetTrafficPolicyDocumentResult 229 if r != nil { 230 s = *r 231 } 232 return s, err 233 }).(GetTrafficPolicyDocumentResultOutput) 234 } 235 236 // A collection of arguments for invoking getTrafficPolicyDocument. 237 type GetTrafficPolicyDocumentOutputArgs struct { 238 // Configuration block for the definitions of the endpoints that you want to use in this traffic policy. See below 239 Endpoints GetTrafficPolicyDocumentEndpointArrayInput `pulumi:"endpoints"` 240 // DNS type of all of the resource record sets that Amazon Route 53 will create based on this traffic policy. 241 RecordType pulumi.StringPtrInput `pulumi:"recordType"` 242 // Configuration block for definitions of the rules that you want to use in this traffic policy. See below 243 Rules GetTrafficPolicyDocumentRuleArrayInput `pulumi:"rules"` 244 // An endpoint to be as the starting point for the traffic policy. 245 StartEndpoint pulumi.StringPtrInput `pulumi:"startEndpoint"` 246 // A rule to be as the starting point for the traffic policy. 247 StartRule pulumi.StringPtrInput `pulumi:"startRule"` 248 // Version of the traffic policy format. 249 Version pulumi.StringPtrInput `pulumi:"version"` 250 } 251 252 func (GetTrafficPolicyDocumentOutputArgs) ElementType() reflect.Type { 253 return reflect.TypeOf((*GetTrafficPolicyDocumentArgs)(nil)).Elem() 254 } 255 256 // A collection of values returned by getTrafficPolicyDocument. 257 type GetTrafficPolicyDocumentResultOutput struct{ *pulumi.OutputState } 258 259 func (GetTrafficPolicyDocumentResultOutput) ElementType() reflect.Type { 260 return reflect.TypeOf((*GetTrafficPolicyDocumentResult)(nil)).Elem() 261 } 262 263 func (o GetTrafficPolicyDocumentResultOutput) ToGetTrafficPolicyDocumentResultOutput() GetTrafficPolicyDocumentResultOutput { 264 return o 265 } 266 267 func (o GetTrafficPolicyDocumentResultOutput) ToGetTrafficPolicyDocumentResultOutputWithContext(ctx context.Context) GetTrafficPolicyDocumentResultOutput { 268 return o 269 } 270 271 func (o GetTrafficPolicyDocumentResultOutput) Endpoints() GetTrafficPolicyDocumentEndpointArrayOutput { 272 return o.ApplyT(func(v GetTrafficPolicyDocumentResult) []GetTrafficPolicyDocumentEndpoint { return v.Endpoints }).(GetTrafficPolicyDocumentEndpointArrayOutput) 273 } 274 275 // The provider-assigned unique ID for this managed resource. 276 func (o GetTrafficPolicyDocumentResultOutput) Id() pulumi.StringOutput { 277 return o.ApplyT(func(v GetTrafficPolicyDocumentResult) string { return v.Id }).(pulumi.StringOutput) 278 } 279 280 // Standard JSON policy document rendered based on the arguments above. 281 func (o GetTrafficPolicyDocumentResultOutput) Json() pulumi.StringOutput { 282 return o.ApplyT(func(v GetTrafficPolicyDocumentResult) string { return v.Json }).(pulumi.StringOutput) 283 } 284 285 func (o GetTrafficPolicyDocumentResultOutput) RecordType() pulumi.StringPtrOutput { 286 return o.ApplyT(func(v GetTrafficPolicyDocumentResult) *string { return v.RecordType }).(pulumi.StringPtrOutput) 287 } 288 289 func (o GetTrafficPolicyDocumentResultOutput) Rules() GetTrafficPolicyDocumentRuleArrayOutput { 290 return o.ApplyT(func(v GetTrafficPolicyDocumentResult) []GetTrafficPolicyDocumentRule { return v.Rules }).(GetTrafficPolicyDocumentRuleArrayOutput) 291 } 292 293 func (o GetTrafficPolicyDocumentResultOutput) StartEndpoint() pulumi.StringPtrOutput { 294 return o.ApplyT(func(v GetTrafficPolicyDocumentResult) *string { return v.StartEndpoint }).(pulumi.StringPtrOutput) 295 } 296 297 func (o GetTrafficPolicyDocumentResultOutput) StartRule() pulumi.StringPtrOutput { 298 return o.ApplyT(func(v GetTrafficPolicyDocumentResult) *string { return v.StartRule }).(pulumi.StringPtrOutput) 299 } 300 301 func (o GetTrafficPolicyDocumentResultOutput) Version() pulumi.StringPtrOutput { 302 return o.ApplyT(func(v GetTrafficPolicyDocumentResult) *string { return v.Version }).(pulumi.StringPtrOutput) 303 } 304 305 func init() { 306 pulumi.RegisterOutputType(GetTrafficPolicyDocumentResultOutput{}) 307 }