https://pulumi.com logo
#typescript
Title
# typescript
e

elegant-dress-88912

12/23/2020, 11:27 AM
Hello, I'm looking for a way to do a conditional output. Pseudocode below:
Copy code
if (config.createS3Bucket) {
  const s3Bucket = new ...
  export s3BucketName = s3Bucket.name
}
The thing is that typescript wants all `export`'s to be at the top level. What do I do?
p

proud-pizza-80589

12/23/2020, 11:41 AM
Copy code
export let s3BucketName: string;
if(){
  s3Bucketname = s3Bucket.name
}
Will get you an undefined in the export when you do not have a bucket, but that is easy to check later on.
e

elegant-dress-88912

12/23/2020, 11:55 AM
thanks!
also had to declare resource itself on the top level to be able use it in other places