Skip to content

(gen2-migration) generate command should handle project overrides #14643

@iliapolo

Description

@iliapolo

Is this feature request related to a new or existing Amplify category?

No response

Is this related to another service?

No response

Describe the feature you'd like to request

In Gen1, customers can override the built-in project resources by running amplify override project. This creates an overrides.ts file where customers can override resource properties using the CDK. For example

import { AmplifyProjectInfo, AmplifyRootStackTemplate } from '@aws-amplify/cli-extensibility-helper';

export function override(resources: AmplifyRootStackTemplate, amplifyProjectInfo: AmplifyProjectInfo) {
  resources.authRole.maxSessionDuration = 3600;
}

Our code-generation should take this override.ts file into account and produce the equivalent Gen2 code.

Describe the solution you'd like

Ideally, we would transform the override.ts to look like this:

export function override(backend: Backend<any>, amplifyProjectInfo: { envName: string, projectName: string }) {
  (backend.auth.resources.authenticatedUserIamRole.node.defaultChild as CfnRole).maxSessionDuration = 3600;
}

And then invoke this function from backend.ts:

import { override as overrideProject } from './override.ts`

const branchName = process.env.AWS_BRANCH ?? 'sandbox';
const backend = defineBackend({
  ...
});

overrideProject(backend, { envName: branchName, projectName: '<hard-code-project-name>' });

Describe alternatives you've considered

None

Additional context

export interface AmplifyRootStackTemplate {
authRole?: iam.CfnRole;
unauthRole?: iam.CfnRole;
addCfnParameter: (props: cdk.CfnParameterProps, logicalId: string) => void;
addCfnOutput: (props: cdk.CfnOutputProps, logicalId: string) => void;
addCfnMapping: (props: cdk.CfnMappingProps, logicalId: string) => void;
addCfnCondition: (props: cdk.CfnConditionProps, logicalId: string) => void;
addCfnResource: (props: cdk.CfnResourceProps, logicalId: string) => void;
}

Note that the auth and unauth role used to be part of the root stack in Gen1; In Gen2, they are part of the auth stack.

Is this something that you'd be interested in working on?

  • 👋 I may be able to implement this feature request

Would this feature include a breaking change?

  • ⚠️ This feature might incur a breaking change

Metadata

Metadata

Assignees

No one assigned
    No fields configured for Feature.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions