I am creating a s3 bucket by pulumi typescript and want to use this bucket in EC2 User data for copying an object. Following is my Code for both.
const bucket = new aws.s3.Bucket("bucket-name", {
acl: "private",
});
I uploaded a index.html file And here is the user data of EC2:-
const userData =
`#!/bin/bash
sudo apt update -y
sudo apt install -y apache2 && sudo apt install -y awscli
aws s3 cp s3://`+pulumi.interpolate`${bucket.id}`+`/index.html /var/www/html/index.html
sudo systemctl start apache2`;
I used pulumi.interpolate
${bucket.id}` for calling bucket Id, but when I checked on EC2 for user data then I get following error.
aws s3 cp s3://Calling [toString] on an [Output<T>] is not supported.
To get the value of an Output<T> as an Output<string> consider either:
1: o.apply(v => `prefix${v}suffix`)
2: pulumi.interpolate `prefix${v}suffix`
can anyone help how can I call bucket name in script?