sparse-intern-71089
02/03/2023, 12:48 PMechoing-dinner-19531
02/03/2023, 1:02 PMbland-pharmacist-96854
02/03/2023, 1:04 PMechoing-dinner-19531
02/03/2023, 1:08 PMbland-pharmacist-96854
02/03/2023, 1:09 PMbucket
object 😕 , what about if I want to create the buckets using aws.s3.bucket()
in the for each loop?bland-pharmacist-96854
02/03/2023, 1:10 PMbuckets
type? map? dict?echoing-dinner-19531
02/03/2023, 1:19 PMtype Bucket = {
name: string;
bucket?: aws.s3.Bucket;
};
let buckets : {[key: string]: Bucket } = {
sourceBucket: { name: "emr-source" },
outputBucket: { name: "emr-output" },
emrLogsBucket: { name: "emr-logs" },
emrStudioBucket: { name: "emr-studio" },
};
for (const k in buckets) {
buckets[k].bucket = ...
}
bland-pharmacist-96854
02/03/2023, 1:21 PMechoing-dinner-19531
02/03/2023, 1:21 PM?
bland-pharmacist-96854
02/03/2023, 1:22 PMlet buckets: { [key: string]: aws.s3.Bucket } = {
source:,
output:,
emrLogs:,
emrStudio:,
};
bland-pharmacist-96854
02/03/2023, 1:23 PMbland-pharmacist-96854
02/03/2023, 1:23 PMechoing-dinner-19531
02/03/2023, 1:23 PMlet buckets: { [key: string]: aws.s3.Bucket? } = {
source: undefined,
output: undefined,
emrLogs: undefined,
emrStudio: undefined,
};
bland-pharmacist-96854
02/03/2023, 1:24 PMType 'undefined' is not assignable to type 'Bucket'.ts(2322)
echoing-dinner-19531
02/03/2023, 1:25 PMaws.s3.Bucket?
<- I think ?
works in that location if not then you want aws.s3.Bucket | undefined
bland-pharmacist-96854
02/03/2023, 1:25 PMbland-pharmacist-96854
02/03/2023, 1:26 PMlet buckets: { [key: string]: aws.s3.Bucket | undefined } = {
emrSource: undefined,
emrOutput: undefined,
emrLogs: undefined,
emrStudio: undefined,
};
Object.entries(buckets).forEach(([key, value]) => {
value = new aws.s3.Bucket(key, { forceDestroy: true });
});
this works, thanksbland-pharmacist-96854
02/03/2023, 1:27 PMbland-pharmacist-96854
02/03/2023, 1:27 PMechoing-dinner-19531
02/03/2023, 1:28 PMvalue =
That will assign the variable value, while you probably want buckets[key] =
But otherwise yeh that seems reasonablebland-pharmacist-96854
02/03/2023, 1:36 PMbland-pharmacist-96854
02/03/2023, 1:36 PM