GetBucketObject
The S3 object data source allows access to the metadata and optionally (see below) content of an object stored inside S3 bucket.
Note: The content of an object (
bodyfield) is available only for objects which have a human-readableContent-Type(text/*andapplication/json). This is to prevent printing unsafe characters and potentially downloading large amount of data which would be thrown away in favour of metadata.
Example Usage
using Pulumi;
using Aws = Pulumi.Aws;
class MyStack : Stack
{
public MyStack()
{
var bootstrapScript = Output.Create(Aws.S3.GetBucketObject.InvokeAsync(new Aws.S3.GetBucketObjectArgs
{
Bucket = "ourcorp-deploy-config",
Key = "ec2-bootstrap-script.sh",
}));
var example = new Aws.Ec2.Instance("example", new Aws.Ec2.InstanceArgs
{
Ami = "ami-2757f631",
InstanceType = "t2.micro",
UserData = bootstrapScript.Apply(bootstrapScript => bootstrapScript.Body),
});
}
}
package main
import (
"github.com/pulumi/pulumi-aws/sdk/v2/go/aws/ec2"
"github.com/pulumi/pulumi-aws/sdk/v2/go/aws/s3"
"github.com/pulumi/pulumi/sdk/v2/go/pulumi"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
bootstrapScript, err := s3.LookupBucketObject(ctx, &s3.LookupBucketObjectArgs{
Bucket: "ourcorp-deploy-config",
Key: "ec2-bootstrap-script.sh",
}, nil)
if err != nil {
return err
}
_, err = ec2.NewInstance(ctx, "example", &ec2.InstanceArgs{
Ami: pulumi.String("ami-2757f631"),
InstanceType: pulumi.String("t2.micro"),
UserData: pulumi.String(bootstrapScript.Body),
})
if err != nil {
return err
}
return nil
})
}import pulumi
import pulumi_aws as aws
bootstrap_script = aws.s3.get_bucket_object(bucket="ourcorp-deploy-config",
key="ec2-bootstrap-script.sh")
example = aws.ec2.Instance("example",
ami="ami-2757f631",
instance_type="t2.micro",
user_data=bootstrap_script.body)import * as pulumi from "@pulumi/pulumi";
import * as aws from "@pulumi/aws";
const bootstrapScript = pulumi.output(aws.s3.getBucketObject({
bucket: "ourcorp-deploy-config",
key: "ec2-bootstrap-script.sh",
}, { async: true }));
const example = new aws.ec2.Instance("example", {
ami: "ami-2757f631",
instanceType: "t2.micro",
userData: bootstrapScript.body,
});Using GetBucketObject
function getBucketObject(args: GetBucketObjectArgs, opts?: InvokeOptions): Promise<GetBucketObjectResult>function get_bucket_object(bucket=None, key=None, range=None, tags=None, version_id=None, opts=None)func LookupBucketObject(ctx *Context, args *LookupBucketObjectArgs, opts ...InvokeOption) (*LookupBucketObjectResult, error)Note: This function is named
LookupBucketObjectin the Go SDK.
public static class GetBucketObject {
public static Task<GetBucketObjectResult> InvokeAsync(GetBucketObjectArgs args, InvokeOptions? opts = null)
}The following arguments are supported:
- Bucket string
The name of the bucket to read the object from. Alternatively, an S3 access point ARN can be specified
- Key string
The full path to the object inside the bucket
- Range string
- Dictionary<string, string>
A map of tags assigned to the object.
- Version
Id string Specific version ID of the object returned (defaults to latest version)
- Bucket string
The name of the bucket to read the object from. Alternatively, an S3 access point ARN can be specified
- Key string
The full path to the object inside the bucket
- Range string
- map[string]string
A map of tags assigned to the object.
- Version
Id string Specific version ID of the object returned (defaults to latest version)
- bucket string
The name of the bucket to read the object from. Alternatively, an S3 access point ARN can be specified
- key string
The full path to the object inside the bucket
- range string
- {[key: string]: string}
A map of tags assigned to the object.
- version
Id string Specific version ID of the object returned (defaults to latest version)
- bucket str
The name of the bucket to read the object from. Alternatively, an S3 access point ARN can be specified
- key str
The full path to the object inside the bucket
- range str
- Dict[str, str]
A map of tags assigned to the object.
- version_
id str Specific version ID of the object returned (defaults to latest version)
GetBucketObject Result
The following output properties are available:
- Body string
Object data (see limitations above to understand cases in which this field is actually available)
- Bucket string
- Cache
Control string Specifies caching behavior along the request/reply chain.
- Content
Disposition string Specifies presentational information for the object.
- Content
Encoding string Specifies 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.
- Content
Language string The language the content is in.
- Content
Length int Size of the body in bytes.
- Content
Type string A standard MIME type describing the format of the object data.
- Etag string
ETag generated for the object (an MD5 sum of the object content in case it’s not encrypted)
- Expiration string
If the object expiration is configured (see object lifecycle management), 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.
- Expires string
The date and time at which the object is no longer cacheable.
- Id string
The provider-assigned unique ID for this managed resource.
- Key string
- Last
Modified string Last modified date of the object in RFC1123 format (e.g.
Mon, 02 Jan 2006 15:04:05 MST)- Metadata Dictionary<string, string>
A map of metadata stored with the object in S3
- Object
Lock stringLegal Hold Status Indicates whether this object has an active legal hold. This field is only returned if you have permission to view an object’s legal hold status.
- Object
Lock stringMode The object lock retention mode currently in place for this object.
- Object
Lock stringRetain Until Date The date and time when this object’s object lock will expire.
- Server
Side stringEncryption 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.
- Sse
Kms stringKey Id If present, specifies the ID of the Key Management Service (KMS) master encryption key that was used for the object.
- Storage
Class string Storage class information of the object. Available for all objects except for
Standardstorage class objects.- Dictionary<string, string>
A map of tags assigned to the object.
- Version
Id string The latest version ID of the object returned.
- Website
Redirect stringLocation 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.
- Range string
- Body string
Object data (see limitations above to understand cases in which this field is actually available)
- Bucket string
- Cache
Control string Specifies caching behavior along the request/reply chain.
- Content
Disposition string Specifies presentational information for the object.
- Content
Encoding string Specifies 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.
- Content
Language string The language the content is in.
- Content
Length int Size of the body in bytes.
- Content
Type string A standard MIME type describing the format of the object data.
- Etag string
ETag generated for the object (an MD5 sum of the object content in case it’s not encrypted)
- Expiration string
If the object expiration is configured (see object lifecycle management), 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.
- Expires string
The date and time at which the object is no longer cacheable.
- Id string
The provider-assigned unique ID for this managed resource.
- Key string
- Last
Modified string Last modified date of the object in RFC1123 format (e.g.
Mon, 02 Jan 2006 15:04:05 MST)- Metadata map[string]string
A map of metadata stored with the object in S3
- Object
Lock stringLegal Hold Status Indicates whether this object has an active legal hold. This field is only returned if you have permission to view an object’s legal hold status.
- Object
Lock stringMode The object lock retention mode currently in place for this object.
- Object
Lock stringRetain Until Date The date and time when this object’s object lock will expire.
- Server
Side stringEncryption 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.
- Sse
Kms stringKey Id If present, specifies the ID of the Key Management Service (KMS) master encryption key that was used for the object.
- Storage
Class string Storage class information of the object. Available for all objects except for
Standardstorage class objects.- map[string]string
A map of tags assigned to the object.
- Version
Id string The latest version ID of the object returned.
- Website
Redirect stringLocation 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.
- Range string
- body string
Object data (see limitations above to understand cases in which this field is actually available)
- bucket string
- cache
Control string Specifies caching behavior along the request/reply chain.
- content
Disposition string Specifies presentational information for the object.
- content
Encoding string Specifies 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.
- content
Language string The language the content is in.
- content
Length number Size of the body in bytes.
- content
Type string A standard MIME type describing the format of the object data.
- etag string
ETag generated for the object (an MD5 sum of the object content in case it’s not encrypted)
- expiration string
If the object expiration is configured (see object lifecycle management), 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.
- expires string
The date and time at which the object is no longer cacheable.
- id string
The provider-assigned unique ID for this managed resource.
- key string
- last
Modified string Last modified date of the object in RFC1123 format (e.g.
Mon, 02 Jan 2006 15:04:05 MST)- metadata {[key: string]: string}
A map of metadata stored with the object in S3
- object
Lock stringLegal Hold Status Indicates whether this object has an active legal hold. This field is only returned if you have permission to view an object’s legal hold status.
- object
Lock stringMode The object lock retention mode currently in place for this object.
- object
Lock stringRetain Until Date The date and time when this object’s object lock will expire.
- server
Side stringEncryption 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.
- sse
Kms stringKey Id If present, specifies the ID of the Key Management Service (KMS) master encryption key that was used for the object.
- storage
Class string Storage class information of the object. Available for all objects except for
Standardstorage class objects.- {[key: string]: string}
A map of tags assigned to the object.
- version
Id string The latest version ID of the object returned.
- website
Redirect stringLocation 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.
- range string
- body str
Object data (see limitations above to understand cases in which this field is actually available)
- bucket str
- cache_
control str Specifies caching behavior along the request/reply chain.
- content_
disposition str Specifies presentational information for the object.
- content_
encoding str Specifies 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.
- content_
language str The language the content is in.
- content_
length float Size of the body in bytes.
- content_
type str A standard MIME type describing the format of the object data.
- etag str
ETag generated for the object (an MD5 sum of the object content in case it’s not encrypted)
- expiration str
If the object expiration is configured (see object lifecycle management), 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.
- expires str
The date and time at which the object is no longer cacheable.
- id str
The provider-assigned unique ID for this managed resource.
- key str
- last_
modified str Last modified date of the object in RFC1123 format (e.g.
Mon, 02 Jan 2006 15:04:05 MST)- metadata Dict[str, str]
A map of metadata stored with the object in S3
- object_
lock_ strlegal_ hold_ status Indicates whether this object has an active legal hold. This field is only returned if you have permission to view an object’s legal hold status.
- object_
lock_ strmode The object lock retention mode currently in place for this object.
- object_
lock_ strretain_ until_ date The date and time when this object’s object lock will expire.
- server_
side_ strencryption 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.
- sse_
kms_ strkey_ id If present, specifies the ID of the Key Management Service (KMS) master encryption key that was used for the object.
- storage_
class str Storage class information of the object. Available for all objects except for
Standardstorage class objects.- Dict[str, str]
A map of tags assigned to the object.
- version_
id str The latest version ID of the object returned.
- website_
redirect_ strlocation 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.
- range str
Package Details
- Repository
- https://github.com/pulumi/pulumi-aws
- License
- Apache-2.0
- Notes
- This Pulumi package is based on the
awsTerraform Provider.