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

fix: stops cdk v1 warning for non cdk custom resource #12241

Merged
merged 2 commits into from
Mar 16, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"AWSTemplateFormatVersion": "2010-09-09",
"Parameters": {
"env": {
"Type": "String"
}
},
"Resources": {
"HelloBucket": {
"Type": "AWS::S3::Bucket"
}
},
"Outputs": {}
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,18 @@ describe('adding custom resources migration test', () => {
it('add/update CDK and CFN custom resources', async () => {
const cdkResourceName = `custom${uuid().split('-')[0]}`;
const cfnResourceName = `custom${uuid().split('-')[0]}`;
const cfnResourceNameWithV10 = `custom${uuid().split('-')[0]}`;

await initJSProjectWithProfileV10(projRoot, { name: 'customMigration', disableAmplifyAppCreation: false });
const appId = getAppId(projRoot);
expect(appId).toBeDefined();

await addCDKCustomResource(projRoot, { name: cdkResourceName });
await addCFNCustomResource(projRoot, { name: cfnResourceNameWithV10, promptForCategorySelection: false });
const srcCFNCustomResourceFilePath = path.join(__dirname, '..', '..', '..', 'custom-resources', 'custom-cfn-stack.json');
// adding a resource to custom cfn stack
const destCFNCustomResourceFilePath = path.join(projRoot, 'amplify', 'backend', 'custom', cfnResourceNameWithV10,`${cfnResourceNameWithV10}-cloudformation-template.json`);
fs.copyFileSync(srcCFNCustomResourceFilePath, destCFNCustomResourceFilePath);
Copy link
Member

Choose a reason for hiding this comment

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

consider adding one non-migration test that would spin up only CFN based custom without any CDK.


// this is where we will write our custom cdk stack logic to
const destCustomResourceFilePath = path.join(projRoot, 'amplify', 'backend', 'custom', cdkResourceName, 'cdk-stack.ts');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ const getOverridesWarning = (resourcesToBuild: IAmplifyResource[], dependencyToS
const getCustomResourcesWarning = (resourcesToBuild: IAmplifyResource[], dependencyToSearch: string): AmplifyWarning | undefined => {
let customResourcesWarningObject;
const customResourceImpactedFiles = [];
const customCategoryResources = resourcesToBuild.filter((resource) => resource.category === AmplifyCategories.CUSTOM);
const customCategoryResources = resourcesToBuild.filter((resource) => resource.category === AmplifyCategories.CUSTOM && resource.service !== 'customCloudformation');
Copy link
Member

@sobolk sobolk Mar 15, 2023

Choose a reason for hiding this comment

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

consider extracting second part of condition to !isCFNBasedCustomeResource(resource) for future readers.

customCategoryResources.forEach((resource) => {
const targetDir = path.join(pathManager.getBackendDirPath(), resource.category, resource.resourceName);
const amplifyDetectorProps: AmplifyNodePkgDetectorProps = {
Expand Down