Open MarcioMeier opened 6 months ago
This is a very useful construct!
I wouldn't call it "S3BucketDeployment" because "deployment" is more related to a "process", not to a "resource", which is what we want to define here (also with its lifecycle managed by CloudFormation).
What do you think of the name "StaticS3Website"?
Also I didn't get why exporting S3Bucket, as this seems an internal class used just to add defaults to the bucket.
We could externalise (this.bucket etc) the instance of the Bucket and the BucketDeployment for further changes if the user needs so.
My suggestion is to create a first PR with only the readme file showing a usage of the lib so we can discuss/refine from the user perspective how we want it to be, what do you think?
@erik-am @sergioflores-j pls take a look at this if possible too!
I already created something similar, so it's definitely useful to have something like this. I will share my version through other channels.
I like the "destroy" retain policy. Makes it easy to clean-up Pull Request deployments, and there's nothing to be lost, because one can always re-deploy static assets! 😃
Would it be useful to remove sources: [Source.asset('./dist')]
?
Feels like this should be configurable. Or maybe at least provide it as a default, which would mean maybe to change the type like this?
type S3BucketDeploymentProps = {
bucketConfig: BucketProps;
deploymentConfig: Omit<BucketDeploymentProps, 'destinationBucket' | 'sources'>;
sources?: BucketDeploymentProps['sources']
};
Also, I had to change destinationBucket: bucket
to destinationBucket: bucket.bucket
because of type errors
You mean "source" should be required, right? I think it shouldn't have a default value as it's very dependent on the build strategy of the user and if he/she forgets to set it, he/she will see "strange" errors like "./dist folder not found" when he/she doesn't have any dist folder in his mind.
Yeah, i guess removing source from here would be better. Agree with the strange './dist' error due to the default value.
I agree, sources
should not have default value.
Problem being solved
Deploying any kind of source code into AWS S3, such as react apps.
Proposal
We create an S3 bucket for the deployment and upload the code from given path to it.
I thought on something like this codesnippet:
It still needs refinement over the default props/polciies, etc..
Further reading:
Out of scope