-
Notifications
You must be signed in to change notification settings - Fork 18
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: Add prefixStagePaths
parameter to aws-s3
deployments
#1015
Conversation
When might this PR get finished / merged? I'd like to use it for guardian/actions-static-site#19 (comment) Happy to help. Is it just tests which need adding? |
6499dae
to
8fac27d
Compare
bcf6c62
to
0ea0b30
Compare
magenta-lib/src/test/scala/magenta/deployment_type/S3ObjectPrefixParametersTest.scala
Outdated
Show resolved
Hide resolved
magenta-lib/src/test/scala/magenta/deployment_type/S3ObjectPrefixParametersTest.scala
Outdated
Show resolved
Hide resolved
magenta-lib/src/main/scala/magenta/deployment_type/S3ObjectPrefixParameters.scala
Outdated
Show resolved
Hide resolved
bd07952
to
090b25b
Compare
magenta-lib/src/main/scala/magenta/deployment_type/S3ObjectPrefixParameters.scala
Outdated
Show resolved
Hide resolved
prefixStagePaths(pkg, target, reporter) | ||
|
||
if (prefixFromStagePaths.isEmpty) { | ||
S3Upload.prefixGenerator( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It feels a little strange that some of the logic for generating a prefix is in S3Upload.prefixGenerator
and some of it here, should this be consolidated?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
S3Upload.prefixGenerator
is used in a few places. Suggest we further refactor/DRY out in a follow-up PR to keep the diff in this PR to a minimum. WDYT?
def name = "n/a" | ||
} | ||
|
||
class S3ObjectPrefixParametersTest extends AnyFlatSpec with Matchers { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👏 well tested, very nice.
…new `prefixStagePaths` in guardian/riff-raff#1015)
prefixStagePaths
parameter to aws-s3
deploymentsprefixFromStagePaths
parameter to aws-s3
deployments
…new `prefixFromStagePaths` in guardian/riff-raff#1015)
prefixFromStagePaths
parameter to aws-s3
deploymentsprefixStagePaths
parameter to aws-s3
deployments
Co-authored-by: Oliver Barnwell <[email protected]> Co-authored-by: Joe Cowton <[email protected]>
Co-authored-by: Joe Cowton <[email protected]>
Co-authored-by: Oliver Barnwell <[email protected]> Co-authored-by: Joe Cowton <[email protected]>
Co-authored-by: Akash Askoolum <[email protected]>
Co-authored-by: Robert Kenny <[email protected]>
22d231d
to
934cbba
Compare
The parameter that can be set in `riff-raff.yaml` is `prefixStagePaths`, `prefixFromStagePaths` is a local variable name.
…new `prefixStagePaths` in guardian/riff-raff#1015)
…new `prefixStagePaths` in guardian/riff-raff#1015)
…new `prefixStagePaths` in guardian/riff-raff#1015)
…new `prefixStagePaths` in guardian/riff-raff#1015)
…new `prefixStagePaths` in guardian/riff-raff#1015)
…new `prefixStagePaths` in guardian/riff-raff#1015)
Background
In the
aws-s3
deployment type, the path within S3 that we upload to is controlled by the following parameters:prefixPackage
prefixStack
prefixApp
prefixStage
This results in the path being the same regardless of the stage being deployed.
For example, for the file
image.jpg
and a shared bucket the upload path will be something like<bucket>/<STAGE>/image.jpg
. If the bucket was not shared across stages (as recommended) the upload path will be something like<bucket>/image.jpg
.What does this change?
Introduces a new
prefixStagePaths
parameter for theaws-s3
deployment type.This is to support services such as https://github.com/guardian/interactive-atom-maker. interactive-atom-maker is configured in a slightly non-standard way - CODE files live in
<bucket>/atoms-CODE/image.jpg
, PROD files live in<bucket>/atoms/image.jpg
1. The behaviour described above doesn't quite work here.This change allows us to do:
When set,
prefixStagePaths
takes precedence over all otherprefix<App|Stage|etc...>
options.How to test
Unit tests have been added to check:
prefixStagePaths
is not set, we maintain existing behaviours ofprefixApp
,prefixStage
, etc.prefixStagePaths
is setprefixStagePaths
is set, describing stages ofCODE
andPROD
, what happens when deploying stage ofUAT
(it should fail)prefixStagePaths
andprefix*
are both set, what winsFor a practical demonstration of this new parameter, see https://github.com/guardian/csti-interactives/pull/53. To test, deploy this branch to CODE, then deploy a build from https://github.com/guardian/csti-interactives/pull/53, and observe the paths which Riff-Raff uploads files to.
How can we measure success?
https://github.com/guardian/csti-interactives (specifically https://github.com/guardian/csti-interactives/pull/53) is able to use Riff-Raff for continuous delivery.
Footnotes
We could update how interactive-atom-maker works, however this would involve updating all the articles that reference the files in S3, which is non-trivial. ↩