-
Notifications
You must be signed in to change notification settings - Fork 819
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 storage resources by running amplify override storage. This creates an overrides.ts file where customers can override resource properties using the CDK. For example
import { AmplifyProjectInfo, AmplifyS3ResourceTemplate } from '@aws-amplify/cli-extensibility-helper';
export function override(resources: AmplifyS3ResourceTemplate, amplifyProjectInfo: AmplifyProjectInfo) {
resources.s3Bucket!.versioningConfiguration = { status: 'Enabled'}
}In Gen2, the same can be achieved by directly writing equivalent CDK code:
backend.storage.resources.cfnResources.cfnBucket.versioningConfiguration = { status: 'Enabled' };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.storage.resources.cfnResources.cfnBucket.versioningConfiguration = { status: 'Enabled'}
}And then invoke this function from backend.ts:
import { override as overrideStorage } from './storage/override.ts`
const branchName = process.env.AWS_BRANCH ?? 'sandbox';
const backend = defineBackend({
...,
storage,
});
overrideStorage(backend, { envName: branchName, projectName: '<hard-code-project-name>' });Describe alternatives you've considered
None
Additional context
Note that resources.s3Bucket is far from the only resource available for override. The full list is available here:
amplify-cli/packages/amplify-cli-extensibility-helper/src/types/storage/types.ts
Lines 27 to 37 in 664dabc
| export interface AmplifyS3ResourceTemplate extends AmplifyCDKL1 { | |
| s3Bucket?: s3Cdk.CfnBucket; | |
| s3AuthPublicPolicy?: iamCdk.CfnPolicy; | |
| s3AuthProtectedPolicy?: iamCdk.CfnPolicy; | |
| s3AuthPrivatePolicy?: iamCdk.CfnPolicy; | |
| s3AuthUploadPolicy?: iamCdk.CfnPolicy; | |
| s3AuthReadPolicy?: iamCdk.CfnPolicy; | |
| s3GuestPublicPolicy?: iamCdk.CfnPolicy; | |
| s3GuestUploadPolicy?: iamCdk.CfnPolicy; | |
| s3GuestReadPolicy?: iamCdk.CfnPolicy; | |
| } |
amplify-cli/packages/amplify-cli-extensibility-helper/src/types/storage/types.ts
Lines 20 to 22 in 664dabc
| export interface AmplifyDDBResourceTemplate extends AmplifyCDKL1 { | |
| dynamoDBTable?: ddb.CfnTable; | |
| } |
Each one of them would likely require its own special transformation. Some transformations may not even be possible. For example, resources.s3AuthPublicPolicy does not directly map to any Gen2 resource since Gen2 manages storage policies differently.
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