I'm building a project that puts all of it's files in a 'dist' folder, and running it through CodeBuild. I'm trying to get it to put all of the files and folders in 'dist' into the root of the s3 bucket, but I'm having trouble figuring out how to make that work.
My 'dist' folder looks something like this:
- index.html
- somecssfiles.css
- fonts/
- - some fonts or w/e
- js/
- - some javascript files
I've tried a lot of different stuff, but can't seem to get it to just drop 'dist/*' into the root of the s3 bucket. Here's the current iteration of my artifacts
property in the buildspec.yml file:
artifacts:
files:
- '*'
discard-paths: yes
base-directory: 'dist'
I thought that would probably work, but it ignores the folders. Any help is appreciated, thanks for reading.
I think you're missing a piece - it's not clear but you need to specify the path in your Codebuild template with the following artifacts:
artifacts:
files:
- '**/*'
base-directory: 'dist'
And then ensure that in the "Artifacts" section of your codebuild project, you specify the S3 bucket normally, but add the "optional" name parameter to be /
This sets the output to the root of the S3 directory - see https://docs.aws.amazon.com/codebuild/latest/APIReference/API_ProjectArtifacts.html#CodeBuild-Type-ProjectArtifacts-name
If type is set to S3, this is the name of the output artifact object. If you set the name to be a forward slash ("/"), the artifact is stored in the root of the output bucket.