get Object
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-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
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.GetObjectArgs;
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.getObject(GetObjectArgs.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(getObjectResult -> getObjectResult.body()))
.build());
}
}
Return
A collection of values returned by getObject. */
Parameters
A collection of arguments for invoking getObject.
Return
A collection of values returned by getObject.
Parameters
Name of the bucket to read the object from. Alternatively, an S3 access point ARN can be specified
Full path to the object inside the bucket
Map of tags assigned to the object.
Specific version ID of the object returned (defaults to latest version)
See also
Return
A collection of values returned by getObject.
Parameters
Builder for com.pulumi.aws.s3.kotlin.inputs.GetObjectPlainArgs.