sparse-intern-71089
08/03/2022, 4:31 PMacoustic-plumber-13001
08/03/2022, 4:33 PMexport const bucket = new aws.s3.Bucket(
This works as expected, in the Pulumi cloud console I can see the exported value:
{
"arn": "arn:aws:s3:::my-awesome-bucket",
....
iam project
// this works correctly
const bucketProject = new pulumi.StackReference('mycompany/bucketproject/testing');
// now need to get the bucket arn as a string
// i've tried about a dozen variations of this, all either resulting in "undefined" or Output<T>
const arnAsString = bucketProject.outputs.apply((bucket) => { bucket.arn });
Thanks for any help!acoustic-plumber-13001
08/03/2022, 4:54 PMbored-oyster-3147
08/03/2022, 5:01 PMacoustic-plumber-13001
08/03/2022, 5:05 PMacoustic-plumber-13001
08/03/2022, 5:11 PM// Would like to produce a string equivalent to: http://${hostname}:${port}/
let url = pulumi.all([hostname, port]).
apply(([hostname, port]) => `http://${hostname}:${port}/`);
Creates a string. What I'm missing I think is that example isn't using an output from another stack?little-cartoon-10569
08/03/2022, 8:27 PMbored-oyster-3147
08/03/2022, 8:29 PMlittle-cartoon-10569
08/03/2022, 8:29 PMlittle-cartoon-10569
08/03/2022, 8:33 PMconst arn: string = stack.require(bucketARN);
Just do this and it will work:
const arn = stack.require(bucketARN);
little-cartoon-10569
08/03/2022, 8:34 PMcolossal-pilot-80454
08/04/2022, 7:33 AMacoustic-plumber-13001
08/05/2022, 7:56 PMbucket.arn
in project2, which is a bit unfortunate. So this works:
project1
// export the bucket's ARN
export const bucketArn = bucket.arn;
project2
// import project1
const project1 = new pulumi.StackReference('myorganization/project1/prod');
// using the bucket ARN. after this, you can use the arn var as you'd expect
const arn = project1.requireOutputValue('bucketArn');
project2 - inside a string value
// if you need to use the bucket ARN to create an actual string, which is pretty common, you can do the following. this happens to be part of an aws.iam.PolicyDocument where we need to list the bucket resource with an /* appended to it:
{
Action: [
's3:GetObject',
],
Effect: 'Allow',
Resource: [pulumi.interpolate`${project1.outputs.bucketArn}/*`],
}
acoustic-plumber-13001
08/05/2022, 7:59 PMdev
and prod
stack in each project...but I'll save that for another day 🙂