github.com/pulumi/pulumi-aws/sdk/v6@v6.32.0/go/aws/cloudfront/cachePolicy.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 cloudfront 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 // ## Example Usage 16 // 17 // Use the `cloudfront.CachePolicy` resource to create a cache policy for CloudFront. 18 // 19 // <!--Start PulumiCodeChooser --> 20 // ```go 21 // package main 22 // 23 // import ( 24 // 25 // "github.com/pulumi/pulumi-aws/sdk/v6/go/aws/cloudfront" 26 // "github.com/pulumi/pulumi/sdk/v3/go/pulumi" 27 // 28 // ) 29 // 30 // func main() { 31 // pulumi.Run(func(ctx *pulumi.Context) error { 32 // _, err := cloudfront.NewCachePolicy(ctx, "example", &cloudfront.CachePolicyArgs{ 33 // Name: pulumi.String("example-policy"), 34 // Comment: pulumi.String("test comment"), 35 // DefaultTtl: pulumi.Int(50), 36 // MaxTtl: pulumi.Int(100), 37 // MinTtl: pulumi.Int(1), 38 // ParametersInCacheKeyAndForwardedToOrigin: &cloudfront.CachePolicyParametersInCacheKeyAndForwardedToOriginArgs{ 39 // CookiesConfig: &cloudfront.CachePolicyParametersInCacheKeyAndForwardedToOriginCookiesConfigArgs{ 40 // CookieBehavior: pulumi.String("whitelist"), 41 // Cookies: &cloudfront.CachePolicyParametersInCacheKeyAndForwardedToOriginCookiesConfigCookiesArgs{ 42 // Items: pulumi.StringArray{ 43 // pulumi.String("example"), 44 // }, 45 // }, 46 // }, 47 // HeadersConfig: &cloudfront.CachePolicyParametersInCacheKeyAndForwardedToOriginHeadersConfigArgs{ 48 // HeaderBehavior: pulumi.String("whitelist"), 49 // Headers: &cloudfront.CachePolicyParametersInCacheKeyAndForwardedToOriginHeadersConfigHeadersArgs{ 50 // Items: pulumi.StringArray{ 51 // pulumi.String("example"), 52 // }, 53 // }, 54 // }, 55 // QueryStringsConfig: &cloudfront.CachePolicyParametersInCacheKeyAndForwardedToOriginQueryStringsConfigArgs{ 56 // QueryStringBehavior: pulumi.String("whitelist"), 57 // QueryStrings: &cloudfront.CachePolicyParametersInCacheKeyAndForwardedToOriginQueryStringsConfigQueryStringsArgs{ 58 // Items: pulumi.StringArray{ 59 // pulumi.String("example"), 60 // }, 61 // }, 62 // }, 63 // }, 64 // }) 65 // if err != nil { 66 // return err 67 // } 68 // return nil 69 // }) 70 // } 71 // 72 // ``` 73 // <!--End PulumiCodeChooser --> 74 // 75 // ## Import 76 // 77 // Using `pulumi import`, import CloudFront cache policies using the `id` of the cache policy. For example: 78 // 79 // ```sh 80 // $ pulumi import aws:cloudfront/cachePolicy:CachePolicy policy 658327ea-f89d-4fab-a63d-7e88639e58f6 81 // ``` 82 type CachePolicy struct { 83 pulumi.CustomResourceState 84 85 // Description for the cache policy. 86 Comment pulumi.StringPtrOutput `pulumi:"comment"` 87 // Amount of time, in seconds, that objects are allowed to remain in the CloudFront cache before CloudFront sends a new request to the origin server to check if the object has been updated. 88 DefaultTtl pulumi.IntPtrOutput `pulumi:"defaultTtl"` 89 // Current version of the cache policy. 90 Etag pulumi.StringOutput `pulumi:"etag"` 91 // Maximum amount of time, in seconds, that objects stay in the CloudFront cache before CloudFront sends another request to the origin to see if the object has been updated. 92 MaxTtl pulumi.IntPtrOutput `pulumi:"maxTtl"` 93 // Minimum amount of time, in seconds, that objects should remain in the CloudFront cache before a new request is sent to the origin to check for updates. 94 MinTtl pulumi.IntPtrOutput `pulumi:"minTtl"` 95 // Unique name used to identify the cache policy. 96 Name pulumi.StringOutput `pulumi:"name"` 97 // Configuration for including HTTP headers, cookies, and URL query strings in the cache key. For more information, refer to the Parameters In Cache Key And Forwarded To Origin section. 98 ParametersInCacheKeyAndForwardedToOrigin CachePolicyParametersInCacheKeyAndForwardedToOriginOutput `pulumi:"parametersInCacheKeyAndForwardedToOrigin"` 99 } 100 101 // NewCachePolicy registers a new resource with the given unique name, arguments, and options. 102 func NewCachePolicy(ctx *pulumi.Context, 103 name string, args *CachePolicyArgs, opts ...pulumi.ResourceOption) (*CachePolicy, error) { 104 if args == nil { 105 return nil, errors.New("missing one or more required arguments") 106 } 107 108 if args.ParametersInCacheKeyAndForwardedToOrigin == nil { 109 return nil, errors.New("invalid value for required argument 'ParametersInCacheKeyAndForwardedToOrigin'") 110 } 111 opts = internal.PkgResourceDefaultOpts(opts) 112 var resource CachePolicy 113 err := ctx.RegisterResource("aws:cloudfront/cachePolicy:CachePolicy", name, args, &resource, opts...) 114 if err != nil { 115 return nil, err 116 } 117 return &resource, nil 118 } 119 120 // GetCachePolicy gets an existing CachePolicy resource's state with the given name, ID, and optional 121 // state properties that are used to uniquely qualify the lookup (nil if not required). 122 func GetCachePolicy(ctx *pulumi.Context, 123 name string, id pulumi.IDInput, state *CachePolicyState, opts ...pulumi.ResourceOption) (*CachePolicy, error) { 124 var resource CachePolicy 125 err := ctx.ReadResource("aws:cloudfront/cachePolicy:CachePolicy", name, id, state, &resource, opts...) 126 if err != nil { 127 return nil, err 128 } 129 return &resource, nil 130 } 131 132 // Input properties used for looking up and filtering CachePolicy resources. 133 type cachePolicyState struct { 134 // Description for the cache policy. 135 Comment *string `pulumi:"comment"` 136 // Amount of time, in seconds, that objects are allowed to remain in the CloudFront cache before CloudFront sends a new request to the origin server to check if the object has been updated. 137 DefaultTtl *int `pulumi:"defaultTtl"` 138 // Current version of the cache policy. 139 Etag *string `pulumi:"etag"` 140 // Maximum amount of time, in seconds, that objects stay in the CloudFront cache before CloudFront sends another request to the origin to see if the object has been updated. 141 MaxTtl *int `pulumi:"maxTtl"` 142 // Minimum amount of time, in seconds, that objects should remain in the CloudFront cache before a new request is sent to the origin to check for updates. 143 MinTtl *int `pulumi:"minTtl"` 144 // Unique name used to identify the cache policy. 145 Name *string `pulumi:"name"` 146 // Configuration for including HTTP headers, cookies, and URL query strings in the cache key. For more information, refer to the Parameters In Cache Key And Forwarded To Origin section. 147 ParametersInCacheKeyAndForwardedToOrigin *CachePolicyParametersInCacheKeyAndForwardedToOrigin `pulumi:"parametersInCacheKeyAndForwardedToOrigin"` 148 } 149 150 type CachePolicyState struct { 151 // Description for the cache policy. 152 Comment pulumi.StringPtrInput 153 // Amount of time, in seconds, that objects are allowed to remain in the CloudFront cache before CloudFront sends a new request to the origin server to check if the object has been updated. 154 DefaultTtl pulumi.IntPtrInput 155 // Current version of the cache policy. 156 Etag pulumi.StringPtrInput 157 // Maximum amount of time, in seconds, that objects stay in the CloudFront cache before CloudFront sends another request to the origin to see if the object has been updated. 158 MaxTtl pulumi.IntPtrInput 159 // Minimum amount of time, in seconds, that objects should remain in the CloudFront cache before a new request is sent to the origin to check for updates. 160 MinTtl pulumi.IntPtrInput 161 // Unique name used to identify the cache policy. 162 Name pulumi.StringPtrInput 163 // Configuration for including HTTP headers, cookies, and URL query strings in the cache key. For more information, refer to the Parameters In Cache Key And Forwarded To Origin section. 164 ParametersInCacheKeyAndForwardedToOrigin CachePolicyParametersInCacheKeyAndForwardedToOriginPtrInput 165 } 166 167 func (CachePolicyState) ElementType() reflect.Type { 168 return reflect.TypeOf((*cachePolicyState)(nil)).Elem() 169 } 170 171 type cachePolicyArgs struct { 172 // Description for the cache policy. 173 Comment *string `pulumi:"comment"` 174 // Amount of time, in seconds, that objects are allowed to remain in the CloudFront cache before CloudFront sends a new request to the origin server to check if the object has been updated. 175 DefaultTtl *int `pulumi:"defaultTtl"` 176 // Maximum amount of time, in seconds, that objects stay in the CloudFront cache before CloudFront sends another request to the origin to see if the object has been updated. 177 MaxTtl *int `pulumi:"maxTtl"` 178 // Minimum amount of time, in seconds, that objects should remain in the CloudFront cache before a new request is sent to the origin to check for updates. 179 MinTtl *int `pulumi:"minTtl"` 180 // Unique name used to identify the cache policy. 181 Name *string `pulumi:"name"` 182 // Configuration for including HTTP headers, cookies, and URL query strings in the cache key. For more information, refer to the Parameters In Cache Key And Forwarded To Origin section. 183 ParametersInCacheKeyAndForwardedToOrigin CachePolicyParametersInCacheKeyAndForwardedToOrigin `pulumi:"parametersInCacheKeyAndForwardedToOrigin"` 184 } 185 186 // The set of arguments for constructing a CachePolicy resource. 187 type CachePolicyArgs struct { 188 // Description for the cache policy. 189 Comment pulumi.StringPtrInput 190 // Amount of time, in seconds, that objects are allowed to remain in the CloudFront cache before CloudFront sends a new request to the origin server to check if the object has been updated. 191 DefaultTtl pulumi.IntPtrInput 192 // Maximum amount of time, in seconds, that objects stay in the CloudFront cache before CloudFront sends another request to the origin to see if the object has been updated. 193 MaxTtl pulumi.IntPtrInput 194 // Minimum amount of time, in seconds, that objects should remain in the CloudFront cache before a new request is sent to the origin to check for updates. 195 MinTtl pulumi.IntPtrInput 196 // Unique name used to identify the cache policy. 197 Name pulumi.StringPtrInput 198 // Configuration for including HTTP headers, cookies, and URL query strings in the cache key. For more information, refer to the Parameters In Cache Key And Forwarded To Origin section. 199 ParametersInCacheKeyAndForwardedToOrigin CachePolicyParametersInCacheKeyAndForwardedToOriginInput 200 } 201 202 func (CachePolicyArgs) ElementType() reflect.Type { 203 return reflect.TypeOf((*cachePolicyArgs)(nil)).Elem() 204 } 205 206 type CachePolicyInput interface { 207 pulumi.Input 208 209 ToCachePolicyOutput() CachePolicyOutput 210 ToCachePolicyOutputWithContext(ctx context.Context) CachePolicyOutput 211 } 212 213 func (*CachePolicy) ElementType() reflect.Type { 214 return reflect.TypeOf((**CachePolicy)(nil)).Elem() 215 } 216 217 func (i *CachePolicy) ToCachePolicyOutput() CachePolicyOutput { 218 return i.ToCachePolicyOutputWithContext(context.Background()) 219 } 220 221 func (i *CachePolicy) ToCachePolicyOutputWithContext(ctx context.Context) CachePolicyOutput { 222 return pulumi.ToOutputWithContext(ctx, i).(CachePolicyOutput) 223 } 224 225 // CachePolicyArrayInput is an input type that accepts CachePolicyArray and CachePolicyArrayOutput values. 226 // You can construct a concrete instance of `CachePolicyArrayInput` via: 227 // 228 // CachePolicyArray{ CachePolicyArgs{...} } 229 type CachePolicyArrayInput interface { 230 pulumi.Input 231 232 ToCachePolicyArrayOutput() CachePolicyArrayOutput 233 ToCachePolicyArrayOutputWithContext(context.Context) CachePolicyArrayOutput 234 } 235 236 type CachePolicyArray []CachePolicyInput 237 238 func (CachePolicyArray) ElementType() reflect.Type { 239 return reflect.TypeOf((*[]*CachePolicy)(nil)).Elem() 240 } 241 242 func (i CachePolicyArray) ToCachePolicyArrayOutput() CachePolicyArrayOutput { 243 return i.ToCachePolicyArrayOutputWithContext(context.Background()) 244 } 245 246 func (i CachePolicyArray) ToCachePolicyArrayOutputWithContext(ctx context.Context) CachePolicyArrayOutput { 247 return pulumi.ToOutputWithContext(ctx, i).(CachePolicyArrayOutput) 248 } 249 250 // CachePolicyMapInput is an input type that accepts CachePolicyMap and CachePolicyMapOutput values. 251 // You can construct a concrete instance of `CachePolicyMapInput` via: 252 // 253 // CachePolicyMap{ "key": CachePolicyArgs{...} } 254 type CachePolicyMapInput interface { 255 pulumi.Input 256 257 ToCachePolicyMapOutput() CachePolicyMapOutput 258 ToCachePolicyMapOutputWithContext(context.Context) CachePolicyMapOutput 259 } 260 261 type CachePolicyMap map[string]CachePolicyInput 262 263 func (CachePolicyMap) ElementType() reflect.Type { 264 return reflect.TypeOf((*map[string]*CachePolicy)(nil)).Elem() 265 } 266 267 func (i CachePolicyMap) ToCachePolicyMapOutput() CachePolicyMapOutput { 268 return i.ToCachePolicyMapOutputWithContext(context.Background()) 269 } 270 271 func (i CachePolicyMap) ToCachePolicyMapOutputWithContext(ctx context.Context) CachePolicyMapOutput { 272 return pulumi.ToOutputWithContext(ctx, i).(CachePolicyMapOutput) 273 } 274 275 type CachePolicyOutput struct{ *pulumi.OutputState } 276 277 func (CachePolicyOutput) ElementType() reflect.Type { 278 return reflect.TypeOf((**CachePolicy)(nil)).Elem() 279 } 280 281 func (o CachePolicyOutput) ToCachePolicyOutput() CachePolicyOutput { 282 return o 283 } 284 285 func (o CachePolicyOutput) ToCachePolicyOutputWithContext(ctx context.Context) CachePolicyOutput { 286 return o 287 } 288 289 // Description for the cache policy. 290 func (o CachePolicyOutput) Comment() pulumi.StringPtrOutput { 291 return o.ApplyT(func(v *CachePolicy) pulumi.StringPtrOutput { return v.Comment }).(pulumi.StringPtrOutput) 292 } 293 294 // Amount of time, in seconds, that objects are allowed to remain in the CloudFront cache before CloudFront sends a new request to the origin server to check if the object has been updated. 295 func (o CachePolicyOutput) DefaultTtl() pulumi.IntPtrOutput { 296 return o.ApplyT(func(v *CachePolicy) pulumi.IntPtrOutput { return v.DefaultTtl }).(pulumi.IntPtrOutput) 297 } 298 299 // Current version of the cache policy. 300 func (o CachePolicyOutput) Etag() pulumi.StringOutput { 301 return o.ApplyT(func(v *CachePolicy) pulumi.StringOutput { return v.Etag }).(pulumi.StringOutput) 302 } 303 304 // Maximum amount of time, in seconds, that objects stay in the CloudFront cache before CloudFront sends another request to the origin to see if the object has been updated. 305 func (o CachePolicyOutput) MaxTtl() pulumi.IntPtrOutput { 306 return o.ApplyT(func(v *CachePolicy) pulumi.IntPtrOutput { return v.MaxTtl }).(pulumi.IntPtrOutput) 307 } 308 309 // Minimum amount of time, in seconds, that objects should remain in the CloudFront cache before a new request is sent to the origin to check for updates. 310 func (o CachePolicyOutput) MinTtl() pulumi.IntPtrOutput { 311 return o.ApplyT(func(v *CachePolicy) pulumi.IntPtrOutput { return v.MinTtl }).(pulumi.IntPtrOutput) 312 } 313 314 // Unique name used to identify the cache policy. 315 func (o CachePolicyOutput) Name() pulumi.StringOutput { 316 return o.ApplyT(func(v *CachePolicy) pulumi.StringOutput { return v.Name }).(pulumi.StringOutput) 317 } 318 319 // Configuration for including HTTP headers, cookies, and URL query strings in the cache key. For more information, refer to the Parameters In Cache Key And Forwarded To Origin section. 320 func (o CachePolicyOutput) ParametersInCacheKeyAndForwardedToOrigin() CachePolicyParametersInCacheKeyAndForwardedToOriginOutput { 321 return o.ApplyT(func(v *CachePolicy) CachePolicyParametersInCacheKeyAndForwardedToOriginOutput { 322 return v.ParametersInCacheKeyAndForwardedToOrigin 323 }).(CachePolicyParametersInCacheKeyAndForwardedToOriginOutput) 324 } 325 326 type CachePolicyArrayOutput struct{ *pulumi.OutputState } 327 328 func (CachePolicyArrayOutput) ElementType() reflect.Type { 329 return reflect.TypeOf((*[]*CachePolicy)(nil)).Elem() 330 } 331 332 func (o CachePolicyArrayOutput) ToCachePolicyArrayOutput() CachePolicyArrayOutput { 333 return o 334 } 335 336 func (o CachePolicyArrayOutput) ToCachePolicyArrayOutputWithContext(ctx context.Context) CachePolicyArrayOutput { 337 return o 338 } 339 340 func (o CachePolicyArrayOutput) Index(i pulumi.IntInput) CachePolicyOutput { 341 return pulumi.All(o, i).ApplyT(func(vs []interface{}) *CachePolicy { 342 return vs[0].([]*CachePolicy)[vs[1].(int)] 343 }).(CachePolicyOutput) 344 } 345 346 type CachePolicyMapOutput struct{ *pulumi.OutputState } 347 348 func (CachePolicyMapOutput) ElementType() reflect.Type { 349 return reflect.TypeOf((*map[string]*CachePolicy)(nil)).Elem() 350 } 351 352 func (o CachePolicyMapOutput) ToCachePolicyMapOutput() CachePolicyMapOutput { 353 return o 354 } 355 356 func (o CachePolicyMapOutput) ToCachePolicyMapOutputWithContext(ctx context.Context) CachePolicyMapOutput { 357 return o 358 } 359 360 func (o CachePolicyMapOutput) MapIndex(k pulumi.StringInput) CachePolicyOutput { 361 return pulumi.All(o, k).ApplyT(func(vs []interface{}) *CachePolicy { 362 return vs[0].(map[string]*CachePolicy)[vs[1].(string)] 363 }).(CachePolicyOutput) 364 } 365 366 func init() { 367 pulumi.RegisterInputType(reflect.TypeOf((*CachePolicyInput)(nil)).Elem(), &CachePolicy{}) 368 pulumi.RegisterInputType(reflect.TypeOf((*CachePolicyArrayInput)(nil)).Elem(), CachePolicyArray{}) 369 pulumi.RegisterInputType(reflect.TypeOf((*CachePolicyMapInput)(nil)).Elem(), CachePolicyMap{}) 370 pulumi.RegisterOutputType(CachePolicyOutput{}) 371 pulumi.RegisterOutputType(CachePolicyArrayOutput{}) 372 pulumi.RegisterOutputType(CachePolicyMapOutput{}) 373 }