Pricing question - is each S3 bucket object billed...
# getting-started
m
Pricing question - is each S3 bucket object billed as a separate resource....? or is the S3 bucket itself billed as a single resource? The dashboard shows that we'll be getting billed for 500+ resources in a development stack with a single S3 bucket and not much else in it. I want to confirm that is correct.
m
If you manage the bucket objects with Pulumi (e.g., with
aws.s3.BucketObject
), they yes, they are counted. But if you only manage the bucket itself, then it'd just be the one resource. In cases where you don't need Pulumi to manage these resources (e.g., if you're managing a static website with hundreds or thousands of files), we have a component you can use to sync them to a bucket so you don't have to deal with having to write that machinery yourself: https://www.pulumi.com/registry/packages/synced-folder/
In most cases this is what I use, and our static-website templates use it also: https://www.pulumi.com/templates/static-website/
m
That makes a lot of sense; I was using this guide -> https://www.pulumi.com/registry/packages/aws/how-to-guides/s3-website/ Which led to the situation in question. I'll use the ones you linked instead, thank you!
m
You bet, best of luck!
m
interesting! this object implementation: https://www.pulumi.com/registry/packages/synced-folder/ in this template (static-website-aws-typescript): https://github.com/pulumi/templates/blob/ed5e07a027b7a3a215d4488631408d513ead6886/static-website-aws-typescript/index.ts is producing one object per file. I checked for weird exceptions or deviations from template and nada - do you have any advice?
m
Did you set
managedObjects
to
false
? (The default implementation also uses
BucketObject
.) https://www.pulumi.com/registry/packages/synced-folder/#managed-and-unmanaged-file-objects
m
no I did not! it wasnt in the template, let me try it
m
You may need to
destroy
and
up
again, as the component doens't handle switching seamlessly between these. (There's a note about this at the end of that section.)
l
Also, check out the aws-static-website provider, which does all this too. Maybe its implementation will give you some ideas (or maybe it's the tool you need!) https://www.pulumi.com/registry/packages/aws-static-website/
m
worked out perfectly 😄 thank you cnunciato and tenwit!!
last question, given the following index.ts code:
Copy code
const bucketFolder = new synced_folder.S3BucketFolder("bucket-folder", {
    path: path,
    bucketName: bucket.bucket,
    acl: "public-read",
    managedObjects: false
}, { dependsOn: [ownershipControls, publicAccessBlock]});
and the following stack:
Copy code
├─ synced-folder:index:S3BucketFolder                      bucket-folder
    │  └─ command:local:Command                                bucket-folder-sync-command
How does one actually invoke the command - programmatically or via CLI? having some issues trying to divine that from https://www.pulumi.com/registry/packages/command/api-docs/local/command/
l
Commands are run whenever they are created, updated or deleted. Changes to
triggers
also triggers execution: https://www.pulumi.com/registry/packages/command/api-docs/local/command/#triggers_nodejs
So you can, for example, have a rerun property on a ComponentResource that wraps your local.Command, and any time you change it (e.g. it could be a number and you incrememt it), that'll force a run. More often, you might use the id or arn property of a resource: any time that changes (because it's created or replaced) then the Command would run (to initialize the new resource).
m
These are correct, but the idea with this particular component (synced-folder) is that you shouldn't need to "do" anything beyond, say, changing the contents of one of the files that belong to whatever folder you're syncing to S3, and then run `pulumi up`; the
aws s3 sync
command is invoked implicitly (and only when necessary) by the synced-folder component.