github.com/pulumi/pulumi-aws/sdk/v6@v6.32.0/go/aws/s3/getBucketObject.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 s3 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 // > **NOTE:** The `s3.BucketObject` data source is DEPRECATED and will be removed in a future version! Use `s3.BucketObjectv2` instead, where new features and fixes will be added. 15 // 16 // The S3 object data source allows access to the metadata and 17 // _optionally_ (see below) content of an object stored inside S3 bucket. 18 // 19 // > **Note:** The content of an object (`body` field) is available only for objects which have a human-readable `Content-Type` (`text/*` and `application/json`). This is to prevent printing unsafe characters and potentially downloading large amount of data which would be thrown away in favour of metadata. 20 // 21 // ## Example Usage 22 // 23 // The following example retrieves a text object (which must have a `Content-Type` 24 // value starting with `text/`) and uses it as the `userData` for an EC2 instance: 25 // 26 // <!--Start PulumiCodeChooser --> 27 // ```go 28 // package main 29 // 30 // import ( 31 // 32 // "github.com/pulumi/pulumi-aws/sdk/v6/go/aws/ec2" 33 // "github.com/pulumi/pulumi-aws/sdk/v6/go/aws/s3" 34 // "github.com/pulumi/pulumi/sdk/v3/go/pulumi" 35 // 36 // ) 37 // 38 // func main() { 39 // pulumi.Run(func(ctx *pulumi.Context) error { 40 // bootstrapScript, err := s3.LookupBucketObject(ctx, &s3.LookupBucketObjectArgs{ 41 // Bucket: "ourcorp-deploy-config", 42 // Key: "ec2-bootstrap-script.sh", 43 // }, nil) 44 // if err != nil { 45 // return err 46 // } 47 // _, err = ec2.NewInstance(ctx, "example", &ec2.InstanceArgs{ 48 // InstanceType: pulumi.String(ec2.InstanceType_T2_Micro), 49 // Ami: pulumi.String("ami-2757f631"), 50 // UserData: pulumi.String(bootstrapScript.Body), 51 // }) 52 // if err != nil { 53 // return err 54 // } 55 // return nil 56 // }) 57 // } 58 // 59 // ``` 60 // <!--End PulumiCodeChooser --> 61 // 62 // The following, more-complex example retrieves only the metadata for a zip 63 // file stored in S3, which is then used to pass the most recent `versionId` 64 // to AWS Lambda for use as a function implementation. More information about 65 // Lambda functions is available in the documentation for 66 // `lambda.Function`. 67 // 68 // <!--Start PulumiCodeChooser --> 69 // ```go 70 // package main 71 // 72 // import ( 73 // 74 // "github.com/pulumi/pulumi-aws/sdk/v6/go/aws" 75 // "github.com/pulumi/pulumi-aws/sdk/v6/go/aws/lambda" 76 // "github.com/pulumi/pulumi-aws/sdk/v6/go/aws/s3" 77 // "github.com/pulumi/pulumi/sdk/v3/go/pulumi" 78 // 79 // ) 80 // 81 // func main() { 82 // pulumi.Run(func(ctx *pulumi.Context) error { 83 // lambda, err := s3.LookupBucketObject(ctx, &s3.LookupBucketObjectArgs{ 84 // Bucket: "ourcorp-lambda-functions", 85 // Key: "hello-world.zip", 86 // }, nil) 87 // if err != nil { 88 // return err 89 // } 90 // _, err = lambda.NewFunction(ctx, "test_lambda", &lambda.FunctionArgs{ 91 // S3Bucket: pulumi.String(lambda.Id), 92 // S3Key: pulumi.String(lambda.Key), 93 // S3ObjectVersion: pulumi.String(lambda.VersionId), 94 // Name: pulumi.String("lambda_function_name"), 95 // Role: pulumi.Any(iamForLambda.Arn), 96 // Handler: pulumi.String("exports.test"), 97 // }) 98 // if err != nil { 99 // return err 100 // } 101 // return nil 102 // }) 103 // } 104 // 105 // ``` 106 // <!--End PulumiCodeChooser --> 107 func LookupBucketObject(ctx *pulumi.Context, args *LookupBucketObjectArgs, opts ...pulumi.InvokeOption) (*LookupBucketObjectResult, error) { 108 opts = internal.PkgInvokeDefaultOpts(opts) 109 var rv LookupBucketObjectResult 110 err := ctx.Invoke("aws:s3/getBucketObject:getBucketObject", args, &rv, opts...) 111 if err != nil { 112 return nil, err 113 } 114 return &rv, nil 115 } 116 117 // A collection of arguments for invoking getBucketObject. 118 type LookupBucketObjectArgs struct { 119 // Name of the bucket to read the object from. Alternatively, an [S3 access point](https://docs.aws.amazon.com/AmazonS3/latest/dev/using-access-points.html) ARN can be specified 120 // 121 // Deprecated: Use the s3.BucketObjectv2 data source instead 122 Bucket string `pulumi:"bucket"` 123 // Full path to the object inside the bucket 124 Key string `pulumi:"key"` 125 Range *string `pulumi:"range"` 126 // Map of tags assigned to the object. 127 Tags map[string]string `pulumi:"tags"` 128 // Specific version ID of the object returned (defaults to latest version) 129 VersionId *string `pulumi:"versionId"` 130 } 131 132 // A collection of values returned by getBucketObject. 133 type LookupBucketObjectResult struct { 134 Arn string `pulumi:"arn"` 135 // Object data (see **limitations above** to understand cases in which this field is actually available) 136 Body string `pulumi:"body"` 137 // Deprecated: Use the s3.BucketObjectv2 data source instead 138 Bucket string `pulumi:"bucket"` 139 // (Optional) Whether or not to use [Amazon S3 Bucket Keys](https://docs.aws.amazon.com/AmazonS3/latest/dev/bucket-key.html) for SSE-KMS. 140 BucketKeyEnabled bool `pulumi:"bucketKeyEnabled"` 141 // Caching behavior along the request/reply chain. 142 CacheControl string `pulumi:"cacheControl"` 143 // Presentational information for the object. 144 ContentDisposition string `pulumi:"contentDisposition"` 145 // What content encodings have been applied to the object and thus what decoding mechanisms must be applied to obtain the media-type referenced by the Content-Type header field. 146 ContentEncoding string `pulumi:"contentEncoding"` 147 // Language the content is in. 148 ContentLanguage string `pulumi:"contentLanguage"` 149 // Size of the body in bytes. 150 ContentLength int `pulumi:"contentLength"` 151 // Standard MIME type describing the format of the object data. 152 ContentType string `pulumi:"contentType"` 153 // [ETag](https://en.wikipedia.org/wiki/HTTP_ETag) generated for the object (an MD5 sum of the object content in case it's not encrypted) 154 Etag string `pulumi:"etag"` 155 // If the object expiration is configured (see [object lifecycle management](http://docs.aws.amazon.com/AmazonS3/latest/dev/object-lifecycle-mgmt.html)), the field includes this header. It includes the expiry-date and rule-id key value pairs providing object expiration information. The value of the rule-id is URL encoded. 156 Expiration string `pulumi:"expiration"` 157 // Date and time at which the object is no longer cacheable. 158 Expires string `pulumi:"expires"` 159 // The provider-assigned unique ID for this managed resource. 160 Id string `pulumi:"id"` 161 Key string `pulumi:"key"` 162 // Last modified date of the object in RFC1123 format (e.g., `Mon, 02 Jan 2006 15:04:05 MST`) 163 LastModified string `pulumi:"lastModified"` 164 // Map of metadata stored with the object in S3. Keys are always returned in lowercase. 165 Metadata map[string]string `pulumi:"metadata"` 166 // Indicates whether this object has an active [legal hold](https://docs.aws.amazon.com/AmazonS3/latest/dev/object-lock-overview.html#object-lock-legal-holds). This field is only returned if you have permission to view an object's legal hold status. 167 ObjectLockLegalHoldStatus string `pulumi:"objectLockLegalHoldStatus"` 168 // Object lock [retention mode](https://docs.aws.amazon.com/AmazonS3/latest/dev/object-lock-overview.html#object-lock-retention-modes) currently in place for this object. 169 ObjectLockMode string `pulumi:"objectLockMode"` 170 // The date and time when this object's object lock will expire. 171 ObjectLockRetainUntilDate string `pulumi:"objectLockRetainUntilDate"` 172 Range *string `pulumi:"range"` 173 // If the object is stored using server-side encryption (KMS or Amazon S3-managed encryption key), this field includes the chosen encryption and algorithm used. 174 ServerSideEncryption string `pulumi:"serverSideEncryption"` 175 // If present, specifies the ID of the Key Management Service (KMS) master encryption key that was used for the object. 176 SseKmsKeyId string `pulumi:"sseKmsKeyId"` 177 // [Storage class](http://docs.aws.amazon.com/AmazonS3/latest/dev/storage-class-intro.html) information of the object. Available for all objects except for `Standard` storage class objects. 178 StorageClass string `pulumi:"storageClass"` 179 // Map of tags assigned to the object. 180 Tags map[string]string `pulumi:"tags"` 181 // Latest version ID of the object returned. 182 VersionId string `pulumi:"versionId"` 183 // If the bucket is configured as a website, redirects requests for this object to another object in the same bucket or to an external URL. Amazon S3 stores the value of this header in the object metadata. 184 WebsiteRedirectLocation string `pulumi:"websiteRedirectLocation"` 185 } 186 187 func LookupBucketObjectOutput(ctx *pulumi.Context, args LookupBucketObjectOutputArgs, opts ...pulumi.InvokeOption) LookupBucketObjectResultOutput { 188 return pulumi.ToOutputWithContext(context.Background(), args). 189 ApplyT(func(v interface{}) (LookupBucketObjectResult, error) { 190 args := v.(LookupBucketObjectArgs) 191 r, err := LookupBucketObject(ctx, &args, opts...) 192 var s LookupBucketObjectResult 193 if r != nil { 194 s = *r 195 } 196 return s, err 197 }).(LookupBucketObjectResultOutput) 198 } 199 200 // A collection of arguments for invoking getBucketObject. 201 type LookupBucketObjectOutputArgs struct { 202 // Name of the bucket to read the object from. Alternatively, an [S3 access point](https://docs.aws.amazon.com/AmazonS3/latest/dev/using-access-points.html) ARN can be specified 203 // 204 // Deprecated: Use the s3.BucketObjectv2 data source instead 205 Bucket pulumi.StringInput `pulumi:"bucket"` 206 // Full path to the object inside the bucket 207 Key pulumi.StringInput `pulumi:"key"` 208 Range pulumi.StringPtrInput `pulumi:"range"` 209 // Map of tags assigned to the object. 210 Tags pulumi.StringMapInput `pulumi:"tags"` 211 // Specific version ID of the object returned (defaults to latest version) 212 VersionId pulumi.StringPtrInput `pulumi:"versionId"` 213 } 214 215 func (LookupBucketObjectOutputArgs) ElementType() reflect.Type { 216 return reflect.TypeOf((*LookupBucketObjectArgs)(nil)).Elem() 217 } 218 219 // A collection of values returned by getBucketObject. 220 type LookupBucketObjectResultOutput struct{ *pulumi.OutputState } 221 222 func (LookupBucketObjectResultOutput) ElementType() reflect.Type { 223 return reflect.TypeOf((*LookupBucketObjectResult)(nil)).Elem() 224 } 225 226 func (o LookupBucketObjectResultOutput) ToLookupBucketObjectResultOutput() LookupBucketObjectResultOutput { 227 return o 228 } 229 230 func (o LookupBucketObjectResultOutput) ToLookupBucketObjectResultOutputWithContext(ctx context.Context) LookupBucketObjectResultOutput { 231 return o 232 } 233 234 func (o LookupBucketObjectResultOutput) Arn() pulumi.StringOutput { 235 return o.ApplyT(func(v LookupBucketObjectResult) string { return v.Arn }).(pulumi.StringOutput) 236 } 237 238 // Object data (see **limitations above** to understand cases in which this field is actually available) 239 func (o LookupBucketObjectResultOutput) Body() pulumi.StringOutput { 240 return o.ApplyT(func(v LookupBucketObjectResult) string { return v.Body }).(pulumi.StringOutput) 241 } 242 243 // Deprecated: Use the s3.BucketObjectv2 data source instead 244 func (o LookupBucketObjectResultOutput) Bucket() pulumi.StringOutput { 245 return o.ApplyT(func(v LookupBucketObjectResult) string { return v.Bucket }).(pulumi.StringOutput) 246 } 247 248 // (Optional) Whether or not to use [Amazon S3 Bucket Keys](https://docs.aws.amazon.com/AmazonS3/latest/dev/bucket-key.html) for SSE-KMS. 249 func (o LookupBucketObjectResultOutput) BucketKeyEnabled() pulumi.BoolOutput { 250 return o.ApplyT(func(v LookupBucketObjectResult) bool { return v.BucketKeyEnabled }).(pulumi.BoolOutput) 251 } 252 253 // Caching behavior along the request/reply chain. 254 func (o LookupBucketObjectResultOutput) CacheControl() pulumi.StringOutput { 255 return o.ApplyT(func(v LookupBucketObjectResult) string { return v.CacheControl }).(pulumi.StringOutput) 256 } 257 258 // Presentational information for the object. 259 func (o LookupBucketObjectResultOutput) ContentDisposition() pulumi.StringOutput { 260 return o.ApplyT(func(v LookupBucketObjectResult) string { return v.ContentDisposition }).(pulumi.StringOutput) 261 } 262 263 // What content encodings have been applied to the object and thus what decoding mechanisms must be applied to obtain the media-type referenced by the Content-Type header field. 264 func (o LookupBucketObjectResultOutput) ContentEncoding() pulumi.StringOutput { 265 return o.ApplyT(func(v LookupBucketObjectResult) string { return v.ContentEncoding }).(pulumi.StringOutput) 266 } 267 268 // Language the content is in. 269 func (o LookupBucketObjectResultOutput) ContentLanguage() pulumi.StringOutput { 270 return o.ApplyT(func(v LookupBucketObjectResult) string { return v.ContentLanguage }).(pulumi.StringOutput) 271 } 272 273 // Size of the body in bytes. 274 func (o LookupBucketObjectResultOutput) ContentLength() pulumi.IntOutput { 275 return o.ApplyT(func(v LookupBucketObjectResult) int { return v.ContentLength }).(pulumi.IntOutput) 276 } 277 278 // Standard MIME type describing the format of the object data. 279 func (o LookupBucketObjectResultOutput) ContentType() pulumi.StringOutput { 280 return o.ApplyT(func(v LookupBucketObjectResult) string { return v.ContentType }).(pulumi.StringOutput) 281 } 282 283 // [ETag](https://en.wikipedia.org/wiki/HTTP_ETag) generated for the object (an MD5 sum of the object content in case it's not encrypted) 284 func (o LookupBucketObjectResultOutput) Etag() pulumi.StringOutput { 285 return o.ApplyT(func(v LookupBucketObjectResult) string { return v.Etag }).(pulumi.StringOutput) 286 } 287 288 // If the object expiration is configured (see [object lifecycle management](http://docs.aws.amazon.com/AmazonS3/latest/dev/object-lifecycle-mgmt.html)), the field includes this header. It includes the expiry-date and rule-id key value pairs providing object expiration information. The value of the rule-id is URL encoded. 289 func (o LookupBucketObjectResultOutput) Expiration() pulumi.StringOutput { 290 return o.ApplyT(func(v LookupBucketObjectResult) string { return v.Expiration }).(pulumi.StringOutput) 291 } 292 293 // Date and time at which the object is no longer cacheable. 294 func (o LookupBucketObjectResultOutput) Expires() pulumi.StringOutput { 295 return o.ApplyT(func(v LookupBucketObjectResult) string { return v.Expires }).(pulumi.StringOutput) 296 } 297 298 // The provider-assigned unique ID for this managed resource. 299 func (o LookupBucketObjectResultOutput) Id() pulumi.StringOutput { 300 return o.ApplyT(func(v LookupBucketObjectResult) string { return v.Id }).(pulumi.StringOutput) 301 } 302 303 func (o LookupBucketObjectResultOutput) Key() pulumi.StringOutput { 304 return o.ApplyT(func(v LookupBucketObjectResult) string { return v.Key }).(pulumi.StringOutput) 305 } 306 307 // Last modified date of the object in RFC1123 format (e.g., `Mon, 02 Jan 2006 15:04:05 MST`) 308 func (o LookupBucketObjectResultOutput) LastModified() pulumi.StringOutput { 309 return o.ApplyT(func(v LookupBucketObjectResult) string { return v.LastModified }).(pulumi.StringOutput) 310 } 311 312 // Map of metadata stored with the object in S3. Keys are always returned in lowercase. 313 func (o LookupBucketObjectResultOutput) Metadata() pulumi.StringMapOutput { 314 return o.ApplyT(func(v LookupBucketObjectResult) map[string]string { return v.Metadata }).(pulumi.StringMapOutput) 315 } 316 317 // Indicates whether this object has an active [legal hold](https://docs.aws.amazon.com/AmazonS3/latest/dev/object-lock-overview.html#object-lock-legal-holds). This field is only returned if you have permission to view an object's legal hold status. 318 func (o LookupBucketObjectResultOutput) ObjectLockLegalHoldStatus() pulumi.StringOutput { 319 return o.ApplyT(func(v LookupBucketObjectResult) string { return v.ObjectLockLegalHoldStatus }).(pulumi.StringOutput) 320 } 321 322 // Object lock [retention mode](https://docs.aws.amazon.com/AmazonS3/latest/dev/object-lock-overview.html#object-lock-retention-modes) currently in place for this object. 323 func (o LookupBucketObjectResultOutput) ObjectLockMode() pulumi.StringOutput { 324 return o.ApplyT(func(v LookupBucketObjectResult) string { return v.ObjectLockMode }).(pulumi.StringOutput) 325 } 326 327 // The date and time when this object's object lock will expire. 328 func (o LookupBucketObjectResultOutput) ObjectLockRetainUntilDate() pulumi.StringOutput { 329 return o.ApplyT(func(v LookupBucketObjectResult) string { return v.ObjectLockRetainUntilDate }).(pulumi.StringOutput) 330 } 331 332 func (o LookupBucketObjectResultOutput) Range() pulumi.StringPtrOutput { 333 return o.ApplyT(func(v LookupBucketObjectResult) *string { return v.Range }).(pulumi.StringPtrOutput) 334 } 335 336 // If the object is stored using server-side encryption (KMS or Amazon S3-managed encryption key), this field includes the chosen encryption and algorithm used. 337 func (o LookupBucketObjectResultOutput) ServerSideEncryption() pulumi.StringOutput { 338 return o.ApplyT(func(v LookupBucketObjectResult) string { return v.ServerSideEncryption }).(pulumi.StringOutput) 339 } 340 341 // If present, specifies the ID of the Key Management Service (KMS) master encryption key that was used for the object. 342 func (o LookupBucketObjectResultOutput) SseKmsKeyId() pulumi.StringOutput { 343 return o.ApplyT(func(v LookupBucketObjectResult) string { return v.SseKmsKeyId }).(pulumi.StringOutput) 344 } 345 346 // [Storage class](http://docs.aws.amazon.com/AmazonS3/latest/dev/storage-class-intro.html) information of the object. Available for all objects except for `Standard` storage class objects. 347 func (o LookupBucketObjectResultOutput) StorageClass() pulumi.StringOutput { 348 return o.ApplyT(func(v LookupBucketObjectResult) string { return v.StorageClass }).(pulumi.StringOutput) 349 } 350 351 // Map of tags assigned to the object. 352 func (o LookupBucketObjectResultOutput) Tags() pulumi.StringMapOutput { 353 return o.ApplyT(func(v LookupBucketObjectResult) map[string]string { return v.Tags }).(pulumi.StringMapOutput) 354 } 355 356 // Latest version ID of the object returned. 357 func (o LookupBucketObjectResultOutput) VersionId() pulumi.StringOutput { 358 return o.ApplyT(func(v LookupBucketObjectResult) string { return v.VersionId }).(pulumi.StringOutput) 359 } 360 361 // If the bucket is configured as a website, redirects requests for this object to another object in the same bucket or to an external URL. Amazon S3 stores the value of this header in the object metadata. 362 func (o LookupBucketObjectResultOutput) WebsiteRedirectLocation() pulumi.StringOutput { 363 return o.ApplyT(func(v LookupBucketObjectResult) string { return v.WebsiteRedirectLocation }).(pulumi.StringOutput) 364 } 365 366 func init() { 367 pulumi.RegisterOutputType(LookupBucketObjectResultOutput{}) 368 }