github.com/pulumi/pulumi-aws/sdk/v6@v6.32.0/go/aws/cloudfront/getCachePolicy.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 "github.com/pulumi/pulumi-aws/sdk/v6/go/aws/internal" 11 "github.com/pulumi/pulumi/sdk/v3/go/pulumi" 12 ) 13 14 // Use this data source to retrieve information about a CloudFront cache policy. 15 // 16 // ## Example Usage 17 // 18 // ### Basic Usage 19 // 20 // <!--Start PulumiCodeChooser --> 21 // ```go 22 // package main 23 // 24 // import ( 25 // 26 // "github.com/pulumi/pulumi-aws/sdk/v6/go/aws/cloudfront" 27 // "github.com/pulumi/pulumi/sdk/v3/go/pulumi" 28 // 29 // ) 30 // 31 // func main() { 32 // pulumi.Run(func(ctx *pulumi.Context) error { 33 // _, err := cloudfront.LookupCachePolicy(ctx, &cloudfront.LookupCachePolicyArgs{ 34 // Name: pulumi.StringRef("example-policy"), 35 // }, nil) 36 // if err != nil { 37 // return err 38 // } 39 // return nil 40 // }) 41 // } 42 // 43 // ``` 44 // <!--End PulumiCodeChooser --> 45 // 46 // ### AWS-Managed Policies 47 // 48 // AWS managed cache policy names are prefixed with `Managed-`: 49 // 50 // <!--Start PulumiCodeChooser --> 51 // ```go 52 // package main 53 // 54 // import ( 55 // 56 // "github.com/pulumi/pulumi-aws/sdk/v6/go/aws/cloudfront" 57 // "github.com/pulumi/pulumi/sdk/v3/go/pulumi" 58 // 59 // ) 60 // 61 // func main() { 62 // pulumi.Run(func(ctx *pulumi.Context) error { 63 // _, err := cloudfront.LookupCachePolicy(ctx, &cloudfront.LookupCachePolicyArgs{ 64 // Name: pulumi.StringRef("Managed-CachingOptimized"), 65 // }, nil) 66 // if err != nil { 67 // return err 68 // } 69 // return nil 70 // }) 71 // } 72 // 73 // ``` 74 // <!--End PulumiCodeChooser --> 75 func LookupCachePolicy(ctx *pulumi.Context, args *LookupCachePolicyArgs, opts ...pulumi.InvokeOption) (*LookupCachePolicyResult, error) { 76 opts = internal.PkgInvokeDefaultOpts(opts) 77 var rv LookupCachePolicyResult 78 err := ctx.Invoke("aws:cloudfront/getCachePolicy:getCachePolicy", args, &rv, opts...) 79 if err != nil { 80 return nil, err 81 } 82 return &rv, nil 83 } 84 85 // A collection of arguments for invoking getCachePolicy. 86 type LookupCachePolicyArgs struct { 87 // Identifier for the cache policy. 88 Id *string `pulumi:"id"` 89 // Unique name to identify the cache policy. 90 Name *string `pulumi:"name"` 91 } 92 93 // A collection of values returned by getCachePolicy. 94 type LookupCachePolicyResult struct { 95 // Comment to describe the cache policy. 96 Comment string `pulumi:"comment"` 97 // Default amount of time, in seconds, that you want objects to stay in the CloudFront cache before CloudFront sends another request to the origin to see if the object has been updated. 98 DefaultTtl int `pulumi:"defaultTtl"` 99 // Current version of the cache policy. 100 Etag string `pulumi:"etag"` 101 Id *string `pulumi:"id"` 102 // 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. 103 MaxTtl int `pulumi:"maxTtl"` 104 // Minimum amount of time, in seconds, that you want objects to stay in the CloudFront cache before CloudFront sends another request to the origin to see if the object has been updated. 105 MinTtl int `pulumi:"minTtl"` 106 Name *string `pulumi:"name"` 107 // The HTTP headers, cookies, and URL query strings to include in the cache key. See Parameters In Cache Key And Forwarded To Origin for more information. 108 ParametersInCacheKeyAndForwardedToOrigins []GetCachePolicyParametersInCacheKeyAndForwardedToOrigin `pulumi:"parametersInCacheKeyAndForwardedToOrigins"` 109 } 110 111 func LookupCachePolicyOutput(ctx *pulumi.Context, args LookupCachePolicyOutputArgs, opts ...pulumi.InvokeOption) LookupCachePolicyResultOutput { 112 return pulumi.ToOutputWithContext(context.Background(), args). 113 ApplyT(func(v interface{}) (LookupCachePolicyResult, error) { 114 args := v.(LookupCachePolicyArgs) 115 r, err := LookupCachePolicy(ctx, &args, opts...) 116 var s LookupCachePolicyResult 117 if r != nil { 118 s = *r 119 } 120 return s, err 121 }).(LookupCachePolicyResultOutput) 122 } 123 124 // A collection of arguments for invoking getCachePolicy. 125 type LookupCachePolicyOutputArgs struct { 126 // Identifier for the cache policy. 127 Id pulumi.StringPtrInput `pulumi:"id"` 128 // Unique name to identify the cache policy. 129 Name pulumi.StringPtrInput `pulumi:"name"` 130 } 131 132 func (LookupCachePolicyOutputArgs) ElementType() reflect.Type { 133 return reflect.TypeOf((*LookupCachePolicyArgs)(nil)).Elem() 134 } 135 136 // A collection of values returned by getCachePolicy. 137 type LookupCachePolicyResultOutput struct{ *pulumi.OutputState } 138 139 func (LookupCachePolicyResultOutput) ElementType() reflect.Type { 140 return reflect.TypeOf((*LookupCachePolicyResult)(nil)).Elem() 141 } 142 143 func (o LookupCachePolicyResultOutput) ToLookupCachePolicyResultOutput() LookupCachePolicyResultOutput { 144 return o 145 } 146 147 func (o LookupCachePolicyResultOutput) ToLookupCachePolicyResultOutputWithContext(ctx context.Context) LookupCachePolicyResultOutput { 148 return o 149 } 150 151 // Comment to describe the cache policy. 152 func (o LookupCachePolicyResultOutput) Comment() pulumi.StringOutput { 153 return o.ApplyT(func(v LookupCachePolicyResult) string { return v.Comment }).(pulumi.StringOutput) 154 } 155 156 // Default amount of time, in seconds, that you want objects to stay in the CloudFront cache before CloudFront sends another request to the origin to see if the object has been updated. 157 func (o LookupCachePolicyResultOutput) DefaultTtl() pulumi.IntOutput { 158 return o.ApplyT(func(v LookupCachePolicyResult) int { return v.DefaultTtl }).(pulumi.IntOutput) 159 } 160 161 // Current version of the cache policy. 162 func (o LookupCachePolicyResultOutput) Etag() pulumi.StringOutput { 163 return o.ApplyT(func(v LookupCachePolicyResult) string { return v.Etag }).(pulumi.StringOutput) 164 } 165 166 func (o LookupCachePolicyResultOutput) Id() pulumi.StringPtrOutput { 167 return o.ApplyT(func(v LookupCachePolicyResult) *string { return v.Id }).(pulumi.StringPtrOutput) 168 } 169 170 // 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. 171 func (o LookupCachePolicyResultOutput) MaxTtl() pulumi.IntOutput { 172 return o.ApplyT(func(v LookupCachePolicyResult) int { return v.MaxTtl }).(pulumi.IntOutput) 173 } 174 175 // Minimum amount of time, in seconds, that you want objects to stay in the CloudFront cache before CloudFront sends another request to the origin to see if the object has been updated. 176 func (o LookupCachePolicyResultOutput) MinTtl() pulumi.IntOutput { 177 return o.ApplyT(func(v LookupCachePolicyResult) int { return v.MinTtl }).(pulumi.IntOutput) 178 } 179 180 func (o LookupCachePolicyResultOutput) Name() pulumi.StringPtrOutput { 181 return o.ApplyT(func(v LookupCachePolicyResult) *string { return v.Name }).(pulumi.StringPtrOutput) 182 } 183 184 // The HTTP headers, cookies, and URL query strings to include in the cache key. See Parameters In Cache Key And Forwarded To Origin for more information. 185 func (o LookupCachePolicyResultOutput) ParametersInCacheKeyAndForwardedToOrigins() GetCachePolicyParametersInCacheKeyAndForwardedToOriginArrayOutput { 186 return o.ApplyT(func(v LookupCachePolicyResult) []GetCachePolicyParametersInCacheKeyAndForwardedToOrigin { 187 return v.ParametersInCacheKeyAndForwardedToOrigins 188 }).(GetCachePolicyParametersInCacheKeyAndForwardedToOriginArrayOutput) 189 } 190 191 func init() { 192 pulumi.RegisterOutputType(LookupCachePolicyResultOutput{}) 193 }