Skip to content
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(migrate-template-gen): add category template generator #13962

Merged
merged 2 commits into from
Oct 7, 2024

Conversation

abhi7cr
Copy link
Contributor

@abhi7cr abhi7cr commented Oct 7, 2024

Description of changes

Add category template generator to output CFN templates for each step of refactor. The class is category agnostic and will expose 3 methods to facilitate generation of templates needed for refactor:

  1. Preprocess gen1 stack resolving parameters, outputs, conditions and dependencies
  2. Remove gen2 resources prior to refactor, resolving output Refs
  3. Move gen1 resources from gen1 stack to gen2 stack for refactor operation

Note: Each step generates the necessary templates under .amplify/migration/templates/<category> folder but the steps will be executed later on by the customer following the README.md file.

Description of how you validated changes

Local testing, unit tests

Checklist

  • PR description included
  • yarn test passes
  • Tests are changed or added
  • Relevant documentation is changed or added (and PR referenced)
  • New AWS SDK calls or CloudFormation actions have been added to relevant test and service IAM policies
  • Pull request labels are added

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@abhi7cr abhi7cr requested a review from a team as a code owner October 7, 2024 17:27
@@ -11,7 +11,7 @@ class CfnParameterResolver {
const parametersFromTemplate = this.template.Parameters;
for (const { ParameterKey, ParameterValue } of parameters) {
assert(ParameterKey);
assert(ParameterValue);
if (!ParameterValue) continue;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there are keys with null/undefined values.

assert(stackOutputs);
assert(stackTemplateOutputs);
let stackTemplateResourcesString = JSON.stringify(stackTemplateResources);
Copy link
Contributor Author

@abhi7cr abhi7cr Oct 7, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the main change here is to only replace Refs within Resources section rather than the entire template. This way Outputs section Ref values can be replaced later on with stack outputs

@abhi7cr abhi7cr merged commit 64eea24 into migrations Oct 7, 2024
5 checks passed
@abhi7cr abhi7cr deleted the gen2-migration-template-gen branch October 7, 2024 21:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants