aws-amplify / aws-amplify/amplify-cli
(gen2-migration) `generate` command should handle project overrides
- Dominant language
- TypeScript
- Stars
- 2.9k
- Forks
- 825
- Avg merge
- 11d 23h
- Merged PRs (30d)
- 2
Description
### 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
```ts
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:
```ts
export function override(backend: Backend, amplifyProjectInfo: { envName: string, projectName: string }) {
(backend.auth.resources.authenticatedUserIamRole.node.defaultChild as CfnRole).maxSessionDuration = 3600;
}
```
And then invoke this function from `backend.ts`:
```ts
import { override as overrideProject } from './override.ts`
const branchName = process.env.AWS_BRANCH ?? 'sandbox';
const backend = defineBackend({
...
});
overrideProject(backend, { envName: branchName, projectName: '' });
```
### Describe alternatives you've considered
None
### Additional context
https://github.com/aws-amplify/amplify-cli/blob/664dabc422d81153a3193996a7324d27829ef3b9/packages/amplify-cli-extensibility-helper/src/types/project/types.ts#L7-L16
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
Contributor guide
Assessment
This issue has not been assessed yet.