-
Notifications
You must be signed in to change notification settings - Fork 5
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
fix(riff-raff.yaml): Loosen restrictions on GuStacks in an App #1695
Conversation
9e2b212
to
bd365eb
Compare
@@ -33,7 +176,7 @@ describe("The RiffRaffYamlFileExperimental class", () => { | |||
|
|||
expect(() => { | |||
new RiffRaffYamlFileExperimental(app); | |||
}).toThrowError("Unable to produce a working riff-raff.yaml file; missing 4 definitions"); | |||
}).toThrowError("Unable to produce a working riff-raff.yaml file; missing 1 definitions"); // Stack of media-service has no CODE stage |
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.
Previously this was missing 4 definitions:
PASS src/experimental/riff-raff-yaml-file/index.test.ts
● Console
console.log
Unable to produce a working riff-raff.yaml file; missing 4 definitions (details below)
at RiffRaffYamlFileExperimental.validateStacksInApp (src/experimental/riff-raff-yaml-file/index.ts:195:15)
console.log
For the class: MyApplicationStack
at src/experimental/riff-raff-yaml-file/index.ts:197:17
at Array.forEach (<anonymous>)
console.log
┌───────────────┬────────────────────────────┐
│ (index) │ eu-west-1 │
├───────────────┼────────────────────────────┤
│ deploy │ { CODE: '✅', PROD: '✅' } │
│ media-service │ { CODE: '❌', PROD: '✅' } │
└───────────────┴────────────────────────────┘
at src/experimental/riff-raff-yaml-file/index.ts:198:17
at Array.forEach (<anonymous>)
console.log
For the class: MyDatabaseStack
at src/experimental/riff-raff-yaml-file/index.ts:197:17
at Array.forEach (<anonymous>)
console.log
┌───────────────┬────────────────────────────┐
│ (index) │ eu-west-1 │
├───────────────┼────────────────────────────┤
│ deploy │ { CODE: '❌', PROD: '✅' } │
│ media-service │ { CODE: '❌', PROD: '❌' } │
└───────────────┴────────────────────────────┘
at src/experimental/riff-raff-yaml-file/index.ts:198:17
The changes in this PR means only 1 definition is missing:
PASS src/experimental/riff-raff-yaml-file/index.test.ts
● Console
console.log
Unable to produce a working riff-raff.yaml file; missing 1 definitions (details below)
at RiffRaffYamlFileExperimental.validateStacksInApp (src/experimental/riff-raff-yaml-file/index.ts:165:15)
console.log
┌───────────────┬──────┬──────┐
│ (index) │ CODE │ PROD │
├───────────────┼──────┼──────┤
│ deploy │ '✅' │ '✅' │
│ media-service │ '❌' │ '✅' │
└───────────────┴──────┴──────┘
at RiffRaffYamlFileExperimental.validateStacksInApp (src/experimental/riff-raff-yaml-file/index.ts:166:15)
bd365eb
to
e73f32c
Compare
Adds the test case for different GuStacks across multiple AWS accounts. Co-authored-by: Jacob <jacobwinch@users.noreply.github.com> Co-authored-by: Thalia <tjsilver@users.noreply.github.com>
Support the use-case where an `App` includes multiple types of `GuStack`. For example: ```ts class ServiceRunningInDeployTools extends GuStack {} class ServiceRunningInSecurity extends GuStack {} new ServiceRunningInDeployTools(app, "App-CODE-deploy", { stack: "deploy", stage: "CODE", }); new ServiceRunningInSecurity(app, "App-CODE-security", { stack: "security", stage: "CODE", }); ``` It's not clear why this validation was originally added. The class name is used for the `app` property in a `cloud-formation` deployment type. This functionality remains, as demonstrated by the tests. Co-authored-by: Jacob <jacobwinch@users.noreply.github.com> Co-authored-by: Thalia <tjsilver@users.noreply.github.com>
Supports the case of deploying to multiple stacks, but not necessarily the same region.
e73f32c
to
d1be4d9
Compare
* ├───────────────┼──────┼──────┤ | ||
* │ deploy │ '✅' │ '✅' │ | ||
* │ media-service │ '❌' │ '✅' │ | ||
* └───────────────┴──────┴──────┘ | ||
* ``` | ||
* | ||
* @private | ||
*/ | ||
private validateStacksInApp(): void { |
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.
I think it would be useful to validate and describe the logic in this function as a unit test apart from the higher level behaviour, not blocking for merge.
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.
Agreed!
🎉 This PR is included in version 49.0.3 🎉 The release is available on: Your semantic-release bot 📦🚀 |
Background
When we added
riff-raff.yaml
generation in #1372, we had a validation step that:GuStack
s in anApp
region
sstacks
sstage
sGuStack
that matched.This meant, for example, for the following:
We'd get validation errors as there is no
PROD
MyDatabaseStack
definition.The aim of this validation is to only produce
riff-raff.yaml
that works.With
MyDatabaseStack
ofPROD
missing, when we deployPROD
, Riff-Raff would fail to locate the CloudFormation template file, as it simply doesn't exist, and the deployment would fail.This behaviour is due to
allowedStages
(correctly) being a property at the root of theriff-raff.yaml
file, rather than a property per deployment.However, there are some niche scenarios where this 4 part validation is too strict.
What does this change?
In this change, we support the, rather niche, use-case of deploying different
GuStack
s to multiple AWS accounts (aka Riff-Raff stacks), and regions. For example:To get this to work, the validation step changes (see changes to
isCdkStackPresent
).Previously the requirement was that every combination of
GuStack
,stack
,stage
, andregion
was present in anApp
, however this is unnecessarily restrictive for the above use-case.In this change, the validation becomes every combination of
stack
, andstage
are present in anApp
.How to test
See the added tests, also https://github.com/guardian/waf/pull/21.
How can we measure success?
We can auto-generate the
riff-raff.yaml
file for more services, such as https://github.com/guardian/waf.Have we considered potential risks?
N/A - the current tests continue to pass, so existing uses of this feature will continue to work.
Checklist
[ ] I have listed any breaking changes, along with a migration path 1Footnotes
Consider whether this is something that will mean changes to projects that have already been migrated, or to the CDK CLI tool. If changes are required, consider adding a checklist here and/or linking to related PRs. ↩
If you are adding a new construct or pattern, has new documentation been added? If you are amending defaults or changing behaviour, are the existing docs still valid? ↩