getBucketObject

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/* 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.

Example Usage

The following example retrieves a text object (which must have a Content-Type value starting with text/) and uses it as the user_data for an EC2 instance:

package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.aws.s3.S3Functions;
import com.pulumi.aws.s3.inputs.GetBucketObjectArgs;
import com.pulumi.aws.ec2.Instance;
import com.pulumi.aws.ec2.InstanceArgs;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;
public class App {
public static void main(String[] args) {
Pulumi.run(App::stack);
}
public static void stack(Context ctx) {
final var bootstrapScript = S3Functions.getBucketObject(GetBucketObjectArgs.builder()
.bucket("ourcorp-deploy-config")
.key("ec2-bootstrap-script.sh")
.build());
var example = new Instance("example", InstanceArgs.builder()
.instanceType("t2.micro")
.ami("ami-2757f631")
.userData(bootstrapScript.applyValue(getBucketObjectResult -> getBucketObjectResult.body()))
.build());
}
}

Return

A collection of values returned by getBucketObject. */

Parameters

argument

A collection of arguments for invoking getBucketObject.


suspend fun getBucketObject(bucket: String, key: String, range: String? = null, tags: Map<String, String>? = null, versionId: String? = null): GetBucketObjectResult

Return

A collection of values returned by getBucketObject.

Parameters

bucket

Name of the bucket to read the object from. Alternatively, an S3 access point ARN can be specified

key

Full path to the object inside the bucket

range
tags

Map of tags assigned to the object.

versionId

Specific version ID of the object returned (defaults to latest version)

See also


Return

A collection of values returned by getBucketObject.

Parameters

argument

Builder for com.pulumi.aws.s3.kotlin.inputs.GetBucketObjectPlainArgs.

See also