github.com/pulumi/pulumi-aws/sdk/v6@v6.32.0/go/aws/route53/queryLog.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 "errors" 11 "github.com/pulumi/pulumi-aws/sdk/v6/go/aws/internal" 12 "github.com/pulumi/pulumi/sdk/v3/go/pulumi" 13 ) 14 15 // Provides a Route53 query logging configuration resource. 16 // 17 // > **NOTE:** There are restrictions on the configuration of query logging. Notably, 18 // the CloudWatch log group must be in the `us-east-1` region, 19 // a permissive CloudWatch log resource policy must be in place, and 20 // the Route53 hosted zone must be public. 21 // See [Configuring Logging for DNS Queries](https://docs.aws.amazon.com/Route53/latest/DeveloperGuide/query-logs.html?console_help=true#query-logs-configuring) for additional details. 22 // 23 // ## Example Usage 24 // 25 // <!--Start PulumiCodeChooser --> 26 // ```go 27 // package main 28 // 29 // import ( 30 // 31 // "fmt" 32 // 33 // "github.com/pulumi/pulumi-aws/sdk/v6/go/aws/cloudwatch" 34 // "github.com/pulumi/pulumi-aws/sdk/v6/go/aws/iam" 35 // "github.com/pulumi/pulumi-aws/sdk/v6/go/aws/route53" 36 // "github.com/pulumi/pulumi/sdk/v3/go/pulumi" 37 // 38 // ) 39 // 40 // func main() { 41 // pulumi.Run(func(ctx *pulumi.Context) error { 42 // // Example Route53 zone with query logging 43 // exampleCom, err := route53.NewZone(ctx, "example_com", &route53.ZoneArgs{ 44 // Name: pulumi.String("example.com"), 45 // }) 46 // if err != nil { 47 // return err 48 // } 49 // awsRoute53ExampleCom, err := cloudwatch.NewLogGroup(ctx, "aws_route53_example_com", &cloudwatch.LogGroupArgs{ 50 // Name: exampleCom.Name.ApplyT(func(name string) (string, error) { 51 // return fmt.Sprintf("/aws/route53/%v", name), nil 52 // }).(pulumi.StringOutput), 53 // RetentionInDays: pulumi.Int(30), 54 // }) 55 // if err != nil { 56 // return err 57 // } 58 // // Example CloudWatch log resource policy to allow Route53 to write logs 59 // // to any log group under /aws/route53/* 60 // route53_query_logging_policy, err := iam.GetPolicyDocument(ctx, &iam.GetPolicyDocumentArgs{ 61 // Statements: []iam.GetPolicyDocumentStatement{ 62 // { 63 // Actions: []string{ 64 // "logs:CreateLogStream", 65 // "logs:PutLogEvents", 66 // }, 67 // Resources: []string{ 68 // "arn:aws:logs:*:*:log-group:/aws/route53/*", 69 // }, 70 // Principals: []iam.GetPolicyDocumentStatementPrincipal{ 71 // { 72 // Identifiers: []string{ 73 // "route53.amazonaws.com", 74 // }, 75 // Type: "Service", 76 // }, 77 // }, 78 // }, 79 // }, 80 // }, nil) 81 // if err != nil { 82 // return err 83 // } 84 // _, err = cloudwatch.NewLogResourcePolicy(ctx, "route53-query-logging-policy", &cloudwatch.LogResourcePolicyArgs{ 85 // PolicyDocument: pulumi.String(route53_query_logging_policy.Json), 86 // PolicyName: pulumi.String("route53-query-logging-policy"), 87 // }) 88 // if err != nil { 89 // return err 90 // } 91 // _, err = route53.NewQueryLog(ctx, "example_com", &route53.QueryLogArgs{ 92 // CloudwatchLogGroupArn: awsRoute53ExampleCom.Arn, 93 // ZoneId: exampleCom.ZoneId, 94 // }, pulumi.DependsOn([]pulumi.Resource{ 95 // route53_query_logging_policyLogResourcePolicy, 96 // })) 97 // if err != nil { 98 // return err 99 // } 100 // return nil 101 // }) 102 // } 103 // 104 // ``` 105 // <!--End PulumiCodeChooser --> 106 // 107 // ## Import 108 // 109 // Using `pulumi import`, import Route53 query logging configurations using their ID. For example: 110 // 111 // ```sh 112 // $ pulumi import aws:route53/queryLog:QueryLog example_com xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx 113 // ``` 114 type QueryLog struct { 115 pulumi.CustomResourceState 116 117 // The Amazon Resource Name (ARN) of the Query Logging Config. 118 Arn pulumi.StringOutput `pulumi:"arn"` 119 // CloudWatch log group ARN to send query logs. 120 CloudwatchLogGroupArn pulumi.StringOutput `pulumi:"cloudwatchLogGroupArn"` 121 // Route53 hosted zone ID to enable query logs. 122 ZoneId pulumi.StringOutput `pulumi:"zoneId"` 123 } 124 125 // NewQueryLog registers a new resource with the given unique name, arguments, and options. 126 func NewQueryLog(ctx *pulumi.Context, 127 name string, args *QueryLogArgs, opts ...pulumi.ResourceOption) (*QueryLog, error) { 128 if args == nil { 129 return nil, errors.New("missing one or more required arguments") 130 } 131 132 if args.CloudwatchLogGroupArn == nil { 133 return nil, errors.New("invalid value for required argument 'CloudwatchLogGroupArn'") 134 } 135 if args.ZoneId == nil { 136 return nil, errors.New("invalid value for required argument 'ZoneId'") 137 } 138 opts = internal.PkgResourceDefaultOpts(opts) 139 var resource QueryLog 140 err := ctx.RegisterResource("aws:route53/queryLog:QueryLog", name, args, &resource, opts...) 141 if err != nil { 142 return nil, err 143 } 144 return &resource, nil 145 } 146 147 // GetQueryLog gets an existing QueryLog resource's state with the given name, ID, and optional 148 // state properties that are used to uniquely qualify the lookup (nil if not required). 149 func GetQueryLog(ctx *pulumi.Context, 150 name string, id pulumi.IDInput, state *QueryLogState, opts ...pulumi.ResourceOption) (*QueryLog, error) { 151 var resource QueryLog 152 err := ctx.ReadResource("aws:route53/queryLog:QueryLog", name, id, state, &resource, opts...) 153 if err != nil { 154 return nil, err 155 } 156 return &resource, nil 157 } 158 159 // Input properties used for looking up and filtering QueryLog resources. 160 type queryLogState struct { 161 // The Amazon Resource Name (ARN) of the Query Logging Config. 162 Arn *string `pulumi:"arn"` 163 // CloudWatch log group ARN to send query logs. 164 CloudwatchLogGroupArn *string `pulumi:"cloudwatchLogGroupArn"` 165 // Route53 hosted zone ID to enable query logs. 166 ZoneId *string `pulumi:"zoneId"` 167 } 168 169 type QueryLogState struct { 170 // The Amazon Resource Name (ARN) of the Query Logging Config. 171 Arn pulumi.StringPtrInput 172 // CloudWatch log group ARN to send query logs. 173 CloudwatchLogGroupArn pulumi.StringPtrInput 174 // Route53 hosted zone ID to enable query logs. 175 ZoneId pulumi.StringPtrInput 176 } 177 178 func (QueryLogState) ElementType() reflect.Type { 179 return reflect.TypeOf((*queryLogState)(nil)).Elem() 180 } 181 182 type queryLogArgs struct { 183 // CloudWatch log group ARN to send query logs. 184 CloudwatchLogGroupArn string `pulumi:"cloudwatchLogGroupArn"` 185 // Route53 hosted zone ID to enable query logs. 186 ZoneId string `pulumi:"zoneId"` 187 } 188 189 // The set of arguments for constructing a QueryLog resource. 190 type QueryLogArgs struct { 191 // CloudWatch log group ARN to send query logs. 192 CloudwatchLogGroupArn pulumi.StringInput 193 // Route53 hosted zone ID to enable query logs. 194 ZoneId pulumi.StringInput 195 } 196 197 func (QueryLogArgs) ElementType() reflect.Type { 198 return reflect.TypeOf((*queryLogArgs)(nil)).Elem() 199 } 200 201 type QueryLogInput interface { 202 pulumi.Input 203 204 ToQueryLogOutput() QueryLogOutput 205 ToQueryLogOutputWithContext(ctx context.Context) QueryLogOutput 206 } 207 208 func (*QueryLog) ElementType() reflect.Type { 209 return reflect.TypeOf((**QueryLog)(nil)).Elem() 210 } 211 212 func (i *QueryLog) ToQueryLogOutput() QueryLogOutput { 213 return i.ToQueryLogOutputWithContext(context.Background()) 214 } 215 216 func (i *QueryLog) ToQueryLogOutputWithContext(ctx context.Context) QueryLogOutput { 217 return pulumi.ToOutputWithContext(ctx, i).(QueryLogOutput) 218 } 219 220 // QueryLogArrayInput is an input type that accepts QueryLogArray and QueryLogArrayOutput values. 221 // You can construct a concrete instance of `QueryLogArrayInput` via: 222 // 223 // QueryLogArray{ QueryLogArgs{...} } 224 type QueryLogArrayInput interface { 225 pulumi.Input 226 227 ToQueryLogArrayOutput() QueryLogArrayOutput 228 ToQueryLogArrayOutputWithContext(context.Context) QueryLogArrayOutput 229 } 230 231 type QueryLogArray []QueryLogInput 232 233 func (QueryLogArray) ElementType() reflect.Type { 234 return reflect.TypeOf((*[]*QueryLog)(nil)).Elem() 235 } 236 237 func (i QueryLogArray) ToQueryLogArrayOutput() QueryLogArrayOutput { 238 return i.ToQueryLogArrayOutputWithContext(context.Background()) 239 } 240 241 func (i QueryLogArray) ToQueryLogArrayOutputWithContext(ctx context.Context) QueryLogArrayOutput { 242 return pulumi.ToOutputWithContext(ctx, i).(QueryLogArrayOutput) 243 } 244 245 // QueryLogMapInput is an input type that accepts QueryLogMap and QueryLogMapOutput values. 246 // You can construct a concrete instance of `QueryLogMapInput` via: 247 // 248 // QueryLogMap{ "key": QueryLogArgs{...} } 249 type QueryLogMapInput interface { 250 pulumi.Input 251 252 ToQueryLogMapOutput() QueryLogMapOutput 253 ToQueryLogMapOutputWithContext(context.Context) QueryLogMapOutput 254 } 255 256 type QueryLogMap map[string]QueryLogInput 257 258 func (QueryLogMap) ElementType() reflect.Type { 259 return reflect.TypeOf((*map[string]*QueryLog)(nil)).Elem() 260 } 261 262 func (i QueryLogMap) ToQueryLogMapOutput() QueryLogMapOutput { 263 return i.ToQueryLogMapOutputWithContext(context.Background()) 264 } 265 266 func (i QueryLogMap) ToQueryLogMapOutputWithContext(ctx context.Context) QueryLogMapOutput { 267 return pulumi.ToOutputWithContext(ctx, i).(QueryLogMapOutput) 268 } 269 270 type QueryLogOutput struct{ *pulumi.OutputState } 271 272 func (QueryLogOutput) ElementType() reflect.Type { 273 return reflect.TypeOf((**QueryLog)(nil)).Elem() 274 } 275 276 func (o QueryLogOutput) ToQueryLogOutput() QueryLogOutput { 277 return o 278 } 279 280 func (o QueryLogOutput) ToQueryLogOutputWithContext(ctx context.Context) QueryLogOutput { 281 return o 282 } 283 284 // The Amazon Resource Name (ARN) of the Query Logging Config. 285 func (o QueryLogOutput) Arn() pulumi.StringOutput { 286 return o.ApplyT(func(v *QueryLog) pulumi.StringOutput { return v.Arn }).(pulumi.StringOutput) 287 } 288 289 // CloudWatch log group ARN to send query logs. 290 func (o QueryLogOutput) CloudwatchLogGroupArn() pulumi.StringOutput { 291 return o.ApplyT(func(v *QueryLog) pulumi.StringOutput { return v.CloudwatchLogGroupArn }).(pulumi.StringOutput) 292 } 293 294 // Route53 hosted zone ID to enable query logs. 295 func (o QueryLogOutput) ZoneId() pulumi.StringOutput { 296 return o.ApplyT(func(v *QueryLog) pulumi.StringOutput { return v.ZoneId }).(pulumi.StringOutput) 297 } 298 299 type QueryLogArrayOutput struct{ *pulumi.OutputState } 300 301 func (QueryLogArrayOutput) ElementType() reflect.Type { 302 return reflect.TypeOf((*[]*QueryLog)(nil)).Elem() 303 } 304 305 func (o QueryLogArrayOutput) ToQueryLogArrayOutput() QueryLogArrayOutput { 306 return o 307 } 308 309 func (o QueryLogArrayOutput) ToQueryLogArrayOutputWithContext(ctx context.Context) QueryLogArrayOutput { 310 return o 311 } 312 313 func (o QueryLogArrayOutput) Index(i pulumi.IntInput) QueryLogOutput { 314 return pulumi.All(o, i).ApplyT(func(vs []interface{}) *QueryLog { 315 return vs[0].([]*QueryLog)[vs[1].(int)] 316 }).(QueryLogOutput) 317 } 318 319 type QueryLogMapOutput struct{ *pulumi.OutputState } 320 321 func (QueryLogMapOutput) ElementType() reflect.Type { 322 return reflect.TypeOf((*map[string]*QueryLog)(nil)).Elem() 323 } 324 325 func (o QueryLogMapOutput) ToQueryLogMapOutput() QueryLogMapOutput { 326 return o 327 } 328 329 func (o QueryLogMapOutput) ToQueryLogMapOutputWithContext(ctx context.Context) QueryLogMapOutput { 330 return o 331 } 332 333 func (o QueryLogMapOutput) MapIndex(k pulumi.StringInput) QueryLogOutput { 334 return pulumi.All(o, k).ApplyT(func(vs []interface{}) *QueryLog { 335 return vs[0].(map[string]*QueryLog)[vs[1].(string)] 336 }).(QueryLogOutput) 337 } 338 339 func init() { 340 pulumi.RegisterInputType(reflect.TypeOf((*QueryLogInput)(nil)).Elem(), &QueryLog{}) 341 pulumi.RegisterInputType(reflect.TypeOf((*QueryLogArrayInput)(nil)).Elem(), QueryLogArray{}) 342 pulumi.RegisterInputType(reflect.TypeOf((*QueryLogMapInput)(nil)).Elem(), QueryLogMap{}) 343 pulumi.RegisterOutputType(QueryLogOutput{}) 344 pulumi.RegisterOutputType(QueryLogArrayOutput{}) 345 pulumi.RegisterOutputType(QueryLogMapOutput{}) 346 }