UNPKG

@pulumi/aws

Version:

A Pulumi package for creating and managing Amazon Web Services (AWS) cloud resources.

303 lines (302 loc) • 11.6 kB
import * as pulumi from "@pulumi/pulumi"; /** * > **NOTE:** The `aws.s3.BucketObject` data source is DEPRECATED and will be removed in a future version! Use `aws.s3.BucketObjectv2` instead, where new features and fixes will be added. * * 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 (`body` field) is available only for objects which have a human-readable `Content-Type`: * * * `text/*` * * `application/json` * * `application/ld+json` * * `application/x-httpd-php` * * `application/xhtml+xml` * * `application/x-csh` * * `application/x-sh` * * `application/xml` * * `application/atom+xml` * * `application/x-sql` * * This is to prevent printing unsafe characters and potentially downloading large amount of data which would be thrown away in favor of metadata. * * ## Example Usage * * The following example retrieves a text object (which must have a `Content-Type` * value starting with `text/`) and uses it as the `userData` for an EC2 instance: * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as aws from "@pulumi/aws"; * * const bootstrapScript = aws.s3.getBucketObject({ * bucket: "ourcorp-deploy-config", * key: "ec2-bootstrap-script.sh", * }); * const example = new aws.ec2.Instance("example", { * instanceType: aws.ec2.InstanceType.T2_Micro, * ami: "ami-2757f631", * userData: bootstrapScript.then(bootstrapScript => bootstrapScript.body), * }); * ``` * * The following, more-complex example retrieves only the metadata for a zip * file stored in S3, which is then used to pass the most recent `versionId` * to AWS Lambda for use as a function implementation. More information about * Lambda functions is available in the documentation for * `aws.lambda.Function`. * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as aws from "@pulumi/aws"; * * const lambda = aws.s3.getBucketObject({ * bucket: "ourcorp-lambda-functions", * key: "hello-world.zip", * }); * const testLambda = new aws.lambda.Function("test_lambda", { * s3Bucket: lambda.then(lambda => lambda.id), * s3Key: lambda.then(lambda => lambda.key), * s3ObjectVersion: lambda.then(lambda => lambda.versionId), * name: "lambda_function_name", * role: iamForLambda.arn, * handler: "exports.test", * }); * ``` */ export declare function getBucketObject(args: GetBucketObjectArgs, opts?: pulumi.InvokeOptions): Promise<GetBucketObjectResult>; /** * A collection of arguments for invoking getBucketObject. */ export interface GetBucketObjectArgs { /** * 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 * * @deprecated bucket is deprecated. Use the aws.s3.BucketObjectv2 data source instead. */ bucket: string; /** * Full path to the object inside the bucket */ key: string; range?: string; /** * Region where this resource will be [managed](https://docs.aws.amazon.com/general/latest/gr/rande.html#regional-endpoints). Defaults to the Region set in the provider configuration. */ region?: string; /** * Map of tags assigned to the object. */ tags?: { [key: string]: string; }; /** * Specific version ID of the object returned (defaults to latest version) */ versionId?: string; } /** * A collection of values returned by getBucketObject. */ export interface GetBucketObjectResult { readonly arn: string; /** * Object data (see **limitations above** to understand cases in which this field is actually available) */ readonly body: string; /** * @deprecated bucket is deprecated. Use the aws.s3.BucketObjectv2 data source instead. */ readonly bucket: string; /** * (Optional) Whether or not to use [Amazon S3 Bucket Keys](https://docs.aws.amazon.com/AmazonS3/latest/dev/bucket-key.html) for SSE-KMS. */ readonly bucketKeyEnabled: boolean; /** * Caching behavior along the request/reply chain. */ readonly cacheControl: string; /** * Presentational information for the object. */ readonly contentDisposition: string; /** * 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. */ readonly contentEncoding: string; /** * Language the content is in. */ readonly contentLanguage: string; /** * Size of the body in bytes. */ readonly contentLength: number; /** * Standard MIME type describing the format of the object data. */ readonly contentType: string; /** * [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) */ readonly etag: string; /** * 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. */ readonly expiration: string; /** * Date and time at which the object is no longer cacheable. */ readonly expires: string; /** * The provider-assigned unique ID for this managed resource. */ readonly id: string; readonly key: string; /** * Last modified date of the object in RFC1123 format (e.g., `Mon, 02 Jan 2006 15:04:05 MST`) */ readonly lastModified: string; /** * Map of metadata stored with the object in S3. Keys are always returned in lowercase. */ readonly metadata: { [key: string]: string; }; /** * 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. */ readonly objectLockLegalHoldStatus: string; /** * 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. */ readonly objectLockMode: string; /** * The date and time when this object's object lock will expire. */ readonly objectLockRetainUntilDate: string; readonly range?: string; readonly region: string; /** * 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. */ readonly serverSideEncryption: string; /** * If present, specifies the ID of the Key Management Service (KMS) master encryption key that was used for the object. */ readonly sseKmsKeyId: string; /** * [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. */ readonly storageClass: string; /** * Map of tags assigned to the object. */ readonly tags: { [key: string]: string; }; /** * Latest version ID of the object returned. */ readonly versionId: string; /** * 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. */ readonly websiteRedirectLocation: string; } /** * > **NOTE:** The `aws.s3.BucketObject` data source is DEPRECATED and will be removed in a future version! Use `aws.s3.BucketObjectv2` instead, where new features and fixes will be added. * * 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 (`body` field) is available only for objects which have a human-readable `Content-Type`: * * * `text/*` * * `application/json` * * `application/ld+json` * * `application/x-httpd-php` * * `application/xhtml+xml` * * `application/x-csh` * * `application/x-sh` * * `application/xml` * * `application/atom+xml` * * `application/x-sql` * * This is to prevent printing unsafe characters and potentially downloading large amount of data which would be thrown away in favor of metadata. * * ## Example Usage * * The following example retrieves a text object (which must have a `Content-Type` * value starting with `text/`) and uses it as the `userData` for an EC2 instance: * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as aws from "@pulumi/aws"; * * const bootstrapScript = aws.s3.getBucketObject({ * bucket: "ourcorp-deploy-config", * key: "ec2-bootstrap-script.sh", * }); * const example = new aws.ec2.Instance("example", { * instanceType: aws.ec2.InstanceType.T2_Micro, * ami: "ami-2757f631", * userData: bootstrapScript.then(bootstrapScript => bootstrapScript.body), * }); * ``` * * The following, more-complex example retrieves only the metadata for a zip * file stored in S3, which is then used to pass the most recent `versionId` * to AWS Lambda for use as a function implementation. More information about * Lambda functions is available in the documentation for * `aws.lambda.Function`. * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as aws from "@pulumi/aws"; * * const lambda = aws.s3.getBucketObject({ * bucket: "ourcorp-lambda-functions", * key: "hello-world.zip", * }); * const testLambda = new aws.lambda.Function("test_lambda", { * s3Bucket: lambda.then(lambda => lambda.id), * s3Key: lambda.then(lambda => lambda.key), * s3ObjectVersion: lambda.then(lambda => lambda.versionId), * name: "lambda_function_name", * role: iamForLambda.arn, * handler: "exports.test", * }); * ``` */ export declare function getBucketObjectOutput(args: GetBucketObjectOutputArgs, opts?: pulumi.InvokeOutputOptions): pulumi.Output<GetBucketObjectResult>; /** * A collection of arguments for invoking getBucketObject. */ export interface GetBucketObjectOutputArgs { /** * 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 * * @deprecated bucket is deprecated. Use the aws.s3.BucketObjectv2 data source instead. */ bucket: pulumi.Input<string>; /** * Full path to the object inside the bucket */ key: pulumi.Input<string>; range?: pulumi.Input<string>; /** * Region where this resource will be [managed](https://docs.aws.amazon.com/general/latest/gr/rande.html#regional-endpoints). Defaults to the Region set in the provider configuration. */ region?: pulumi.Input<string>; /** * Map of tags assigned to the object. */ tags?: pulumi.Input<{ [key: string]: pulumi.Input<string>; }>; /** * Specific version ID of the object returned (defaults to latest version) */ versionId?: pulumi.Input<string>; }