This message was deleted.
# general
s
This message was deleted.
e
From the sounds of it I think using the Command provider is probably the right way to do this.
p
OK thanks, I'll give it a stab and report result 👍
Using
local.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:
Copy code
# 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.
e
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?
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].
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.
Your common sense is correct. Triggers is just any value which when changed will trigger the command to run again.
p
Awesome, thanks for clarification