agreeable-machine-73141
05/20/2020, 6:43 AMOutput<string>
variable? I retrieve the region as type Output<string>
which I want to use as prefix in the bucket name. I want to either convert it to string
or use the Output<string>
directly in the bucket creation. I tried the apply
and interpolate
syntax but I can’t figure out how to use correctly.
const region = pulumi.output(aws.getRegion()).name;
`const devDataBucket = new aws.s3.Bucket(${region}-dev-data
);`
Appreciate the help!victorious-gigabyte-4729
05/20/2020, 7:22 AMOutput<T>.get(): T
/**
* Retrieves the underlying value of this dependency.
*
* This function is only callable in code that runs in the cloud post-deployment. At this
* point all Output values will be known and can be safely retrieved. During pulumi deployment
* or preview execution this must not be called (and will throw). This is because doing so
* would allow Output values to flow into Resources while losing the data that would allow
* the dependency graph to be changed.
*/
agreeable-machine-73141
05/20/2020, 8:57 AMPulumi.dev.yaml
config in the s3 bucket name during creation of pulumi stack. In pulumi/aws v1.x package, we could retrieve it as a string using just aws.getRegion().name
How do I retrieve and use this value in the latest version?busy-magazine-48939
05/20/2020, 9:14 AMimport * as pulumi from '@pulumi/pulumi';
import * as aws from '@pulumi/aws';
import { interpolate } from '@pulumi/pulumi';
const region = pulumi.output(aws.getRegion({}, { async: true})).name;
const prefix = interpolate`${region}-dev-data`
const devDataBucket = new aws.s3.Bucket('devDataBucket', {
bucket: prefix
});
${region}-dev-data
is quite generic and can easily overlap with someone else bucket.agreeable-machine-73141
05/20/2020, 12:00 PMimport * as pulumi from '@pulumi/pulumi';
import * as aws from '@pulumi/aws';
import { interpolate } from '@pulumi/pulumi';
const region = pulumi.output(aws.getRegion({}, { async: true})).name;
const prefix = interpolate`${region}-dev-data`
const devDataBucket = prefix.apply(p => {
return new aws.s3.Bucket(p, {
bucket: p
})
});
The prefix has other qualifiers. I provided a simplified code snippet here.