s3 frontend and backend in copilot for the pipeline #3703
-
Hello, can anybody guide me in this situation? My scenario: My current deployment is done with two GitHub actions, a backend deploys action and then a frontend deploys action. Now I feel like incorporating copilot and using the pipeline functionality too, but I don't want to create a service with an Nginx to serve my frontend, I would like to take advantage of the pipeline to deploy the backend and then deploy the frontend as a dependency, but since it is not a copilot service I can't set that dependency and get it to work, like:
I thought about using a scheduled job disabled to create a front job and use it in the pipeline definition with a Dockerfile that would copy the files to the S3 bucket but I got the following error: File [infrastructure/front-specific-feature.params.json] does not exist in artifact [BuildOutput], but in fact, I think it would not be a solution because if it failed, my frontend version would be out of sync with the backend version. I don't know if this can be achieved with pipeline anyway. Someone can guide me on how to realize this using copilot if it is possible? many thanks! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Hi @rxmatch ! That's a really cool use case that totally makes sense. MitigationThis isn't an ideal solution, but please let me know what you think. Is it possible to leverage the stages:
- name: testing
deployemnts:
api:
test_commands:
- aws s3 cp webapp/ s3://mybucket/ --recursive # Option 1.
- copilot task run --dockerfile ./s3uploader/Dockerfile --task-role <some role with access to s3> # Option 2. The main downside of Option 1 that I can think of is that you'll have to modify the BuildProjectPolicy outside of Copilot to give permission to upload artifacts to the s3 bucket: copilot-cli/internal/pkg/template/templates/cicd/pipeline_cfn.yml Lines 42 to 46 in eb8ad5a My teammate is currently working on #2755 so that we can specify additional permissions with the pipeline manifest. Option 2 should just work, but you'd need to write a small script that can upload the react app to the s3 bucket. Feature Request[preferred] A CodeBuild actionIn the long run, it sounds like it might be to nice to provide an action that can run stages: yaml
- name: testing
deployments:
api:
frontend:
commands:
- copilot task run --dockerfile ./s3uploader/Dockerfile
depends_on:
- api S3 Deploy ActionAnother alternative is the S3 Deploy Action. stages: yaml
- name: testing
deployments:
api:
frontend:
s3:
from: ./webapp/
to: mybucket
depends_on:
- api I'm not yet clear on where the IAM permissions for the bucket should be specified, I assume it's the pipeline role. |
Beta Was this translation helpful? Give feedback.
Hi @rxmatch !
That's a really cool use case that totally makes sense.
Mitigation
This isn't an ideal solution, but please let me know what you think. Is it possible to leverage the
test_commands
to potentially upload the React app to the s3 bucket?The main downside of Option 1 that I can think of is that you'll have to modify the BuildProjectPolicy outside of Copilot to give permission to upload artifacts to the s3 bucket:
copilot-cli/interna…