sparse-intern-71089
03/01/2022, 1:17 PMechoing-dinner-19531
03/01/2022, 1:57 PMproud-art-41399
03/01/2022, 2:53 PMproud-art-41399
03/01/2022, 6:29 PMlocal.Command
seems the be the way to go. However, I encountered an issue which I'm not sure is a bug or my bad. Here's the relevant part of Pulumi program:
# Build the web application.
build_command = command.local.Command(
"app-build-command",
create=(
"echo '<!DOCTYPE html><html><body>XXX</body></html>' > /tmp/index.html"
),
environment=pulumi.Output.all(
access_key_id=user_access_key.id,
secret_access_key=user_access_key.secret,
bucket=bucket.id,
).apply(
lambda args: {
"AWS_REGION": aws.config.region,
"AWS_ACCESS_KEY_ID": args["access_key_id"],
"AWS_SECRET_ACCESS_KEY": args["secret_access_key"],
"BUCKET_NAME": args["bucket"],
}
),
triggers=[uuid.uuid4().hex], # XXX: enforce running the command
)
# Create a bucket object for the index document.
aws.s3.BucketObject(
"bucket-index-document",
key="index.html",
bucket=bucket.id,
source=build_command.id.apply(lambda x: pulumi.FileAsset("/tmp/index.html")),
content_type="text/html",
opts=pulumi.ResourceOptions(depends_on=[build_command]),
)
Notice the use of apply
when creating the bucket object. If I leave it out, I get an error that /tmp/index.html
doesn't exist. It seems that specifying depends_on
the command is not enough. Or am I doing something wrong here?
As a side note, I'm also not sure about the usage of triggers
. There's no documentation and looking into the code didn't make me any smarter. But the common sense tells me that if I want the command to always run, I need to supply something that changes every time.echoing-dinner-19531
03/01/2022, 9:51 PMNotice the use ofÂI think that's because it tries to make the FileAsset before the file exists, but because of this you don't need the depends_on=[build_command]. when creating the bucket object. If I leave it out, I get an error thatÂapply
 doesn't exist. It seems that specifyingÂ/tmp/index.html
 the command is not enough. Or am I doing something wrong here?depends_on
As a side note, I'm also not sure about the usage ofÂYour common sense is correct. Triggers is just any value which when changed will trigger the command to run again.. There's no documentation and looking into the code didn't make me any smarter. But the common sense tells me that if I want the command to always run, I need to supply something that changes every time.triggers
proud-art-41399
03/02/2022, 7:26 AM