UNPKG

@pulumi/aws

Version:

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

162 lines 5.83 kB
"use strict"; // *** WARNING: this file was generated by pulumi-language-nodejs. *** // *** Do not edit by hand unless you're certain you know what you are doing! *** Object.defineProperty(exports, "__esModule", { value: true }); exports.getObjectOutput = exports.getObject = void 0; const pulumi = require("@pulumi/pulumi"); const utilities = require("../utilities"); /** * 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` * * `application/yaml` * * 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.getObject({ * 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.getObject({ * bucket: "ourcorp-lambda-functions", * key: "hello-world.zip", * }); * const testLambda = new aws.lambda.Function("test_lambda", { * s3Bucket: lambda.then(lambda => lambda.bucket), * s3Key: lambda.then(lambda => lambda.key), * s3ObjectVersion: lambda.then(lambda => lambda.versionId), * name: "lambda_function_name", * role: iamForLambda.arn, * handler: "exports.test", * }); * ``` */ function getObject(args, opts) { opts = pulumi.mergeOptions(utilities.resourceOptsDefaults(), opts || {}); return pulumi.runtime.invoke("aws:s3/getObject:getObject", { "bucket": args.bucket, "checksumMode": args.checksumMode, "key": args.key, "range": args.range, "region": args.region, "tags": args.tags, "versionId": args.versionId, }, opts); } exports.getObject = getObject; /** * 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` * * `application/yaml` * * 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.getObject({ * 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.getObject({ * bucket: "ourcorp-lambda-functions", * key: "hello-world.zip", * }); * const testLambda = new aws.lambda.Function("test_lambda", { * s3Bucket: lambda.then(lambda => lambda.bucket), * s3Key: lambda.then(lambda => lambda.key), * s3ObjectVersion: lambda.then(lambda => lambda.versionId), * name: "lambda_function_name", * role: iamForLambda.arn, * handler: "exports.test", * }); * ``` */ function getObjectOutput(args, opts) { opts = pulumi.mergeOptions(utilities.resourceOptsDefaults(), opts || {}); return pulumi.runtime.invokeOutput("aws:s3/getObject:getObject", { "bucket": args.bucket, "checksumMode": args.checksumMode, "key": args.key, "range": args.range, "region": args.region, "tags": args.tags, "versionId": args.versionId, }, opts); } exports.getObjectOutput = getObjectOutput; //# sourceMappingURL=getObject.js.map