damp-pillow-67781
06/25/2019, 8:38 PM.json
or a .yaml
file, but when calling object.body()
it shows undefined. I wonder is this the proper way to get the content or any other suggestions on how to get that? The code I have now: const latestFile = aws.s3.getBucketObject({
bucket: bucket,
key: `${key}/pod-settings_latest.json`,
});
console.log(`latest file: ${latestFile.body}`);
which have the output as undefined
.white-balloon-205
body
property is only populated when the content-type
is test/*
or application/json
.
See note at https://pulumi.io/reference/pkg/nodejs/pulumi/aws/s3/#getBucketObject.damp-pillow-67781
06/25/2019, 8:52 PMproud-alarm-92546
06/25/2019, 8:53 PMwhite-balloon-205
aws
JS SDK directly.proud-alarm-92546
06/25/2019, 8:53 PMdamp-pillow-67781
06/25/2019, 8:53 PMwhite-balloon-205
getBucketObject
will as well.damp-pillow-67781
06/25/2019, 8:54 PMwhite-balloon-205
import * as pulumi from "@pulumi/pulumi";
import * as aws from "@pulumi/aws";
import * as awssdk from "aws-sdk";
const bucket = new aws.s3.Bucket("my-bucket");
const obj = new aws.s3.BucketObject("o", {
bucket: bucket,
key: "foo.json",
content: '{"foo": "bar"}',
contentType: "application/json",
})
export const contents = pulumi.all([bucket.id, obj.key]).apply(async ([bucketId, key]) => {
// const o = await aws.s3.getBucketObject({
// bucket: bucketId,
// key: key,
// });
const s3 = new awssdk.S3();
const o = await s3.getObject({
Bucket: bucketId,
Key: key,
}).promise();
console.log(JSON.stringify(o));
return (o.Body as Buffer).toString();
});
damp-pillow-67781
06/25/2019, 9:14 PM