From 5789b26036c4e93f569669e25c3cf2637b4abdb8 Mon Sep 17 00:00:00 2001 From: Ammar <56042290+ammarkarachi@users.noreply.github.com> Date: Thu, 21 Jan 2021 16:17:47 -0800 Subject: [PATCH] Revert "feat: provide tags on create app (#6381)" (#6456) This reverts commit 0530d1af0e1c46bac45da2c0185d213058a28849. --- .../src/__tests__/tags.test.ts | 26 ++++++++----------- .../src/amplify-service-manager.js | 16 ------------ 2 files changed, 11 insertions(+), 31 deletions(-) diff --git a/packages/amplify-e2e-tests/src/__tests__/tags.test.ts b/packages/amplify-e2e-tests/src/__tests__/tags.test.ts index 300f6a79c22..e74e2535971 100644 --- a/packages/amplify-e2e-tests/src/__tests__/tags.test.ts +++ b/packages/amplify-e2e-tests/src/__tests__/tags.test.ts @@ -3,12 +3,12 @@ import { createNewProjectDir, deleteProject, deleteProjectDir, + amplifyPushWithoutCodegen, getProjectMeta, getProjectTags, describeCloudFormationStack, + addDEVHosting, } from 'amplify-e2e-core'; -import _ from 'lodash'; -import { Amplify } from 'aws-sdk'; describe('generated tags test', () => { let projRoot: string; @@ -23,7 +23,11 @@ describe('generated tags test', () => { }); it('should compare the nested stack tags key with the tags.json file and return true', async () => { - await initJSProjectWithProfile(projRoot, { disableAmplifyAppCreation: false }); + const projName = 'tagsTest'; + const envName = 'devtag'; + await initJSProjectWithProfile(projRoot, { name: projName, envName }); + await addDEVHosting(projRoot); + await amplifyPushWithoutCodegen(projRoot); // This block of code gets the necessary info to compare the values of both the local tags from the JSON file and tags on the stack const amplifyMeta = getProjectMeta(projRoot); @@ -31,18 +35,10 @@ describe('generated tags test', () => { const rootStackInfo = await describeCloudFormationStack(meta.StackName, meta.Region); const localTags = getProjectTags(projRoot); - expect(checkEquality(localTags, rootStackInfo.Tags)).toBeTruthy(); - const { AmplifyAppId, Region } = meta; - const amplify = new Amplify({ region: Region }); - const amplifyApp = await amplify.getApp({ appId: AmplifyAppId }).promise(); - const tagMap = amplifyApp.app.tags; - const amplifyTags = Object.keys(tagMap).map(key => { - return { - Key: key, - Value: tagMap[key], - }; - }); - expect(checkEquality(localTags, amplifyTags)).toBeTruthy(); + // Currently only checks to make sure that thhe pushed tags have the same amount and name of keys than the ones added locally on the tags.json file + expect(checkEquality(localTags, rootStackInfo.Tags)).toBe(true); + expect(rootStackInfo.Tags.filter(r => r.Key === 'user:Stack')[0].Value).toEqual(envName); + expect(rootStackInfo.Tags.filter(r => r.Key === 'user:Application')[0].Value).toEqual(projName); }); }); diff --git a/packages/amplify-provider-awscloudformation/src/amplify-service-manager.js b/packages/amplify-provider-awscloudformation/src/amplify-service-manager.js index 84a27a7c373..92ca82e5d95 100644 --- a/packages/amplify-provider-awscloudformation/src/amplify-service-manager.js +++ b/packages/amplify-provider-awscloudformation/src/amplify-service-manager.js @@ -18,7 +18,6 @@ async function init(amplifyServiceParams) { let deploymentBucketName = `${stackName}-deployment`; const amplifyClient = await getConfiguredAmplifyClient(context, awsConfig); - logger('init.getConfiguredAmplifyClient', [!!amplifyClient])(); if (!amplifyClient) { // This happens when the Amplify service is not available in the region return { @@ -29,7 +28,6 @@ async function init(amplifyServiceParams) { } const hasPermission = await checkAmplifyServiceIAMPermission(context, amplifyClient); - logger('init.checkAmplifyServiceIAMPermission', [hasPermission])(); if (!hasPermission) { return { amplifyAppId, @@ -117,18 +115,13 @@ async function init(amplifyServiceParams) { } if (!amplifyAppId) { - logger('in if', [amplifyAppId])(); - const createAppParams = { name: projectName, - tags: getTagMap(context), environmentVariables: { _LIVE_PACKAGE_UPDATES: '[{"pkg":"@aws-amplify/cli","type":"npm","version":"latest"}]' }, }; - logger('after create params', [amplifyAppId])(); const log = logger('init.amplifyClient.createApp', [createAppParams]); try { - logger('amplifyAppCreationEnabled', [amplifyAppCreationEnabled()])(); if (amplifyAppCreationEnabled()) { log(); const createAppResponse = await amplifyClient.createApp(createAppParams).promise(); @@ -209,14 +202,6 @@ async function init(amplifyServiceParams) { deploymentBucketName, }; } -function getTagMap(context) { - const tags = context.amplify.getTags(context); - const tagMap = tags.reduce((obj, tag) => { - obj[tag.Key] = tag.Value; - return obj; - }, {}); - return tagMap; -} async function deleteEnv(context, envName, awsConfig) { if (stateManager.teamProviderInfoExists()) { @@ -306,7 +291,6 @@ async function postPushCheck(context) { if (!amplifyAppId) { const createAppParams = { name: projectConfig.projectName, - tags: getTagMap(context), environmentVariables: { _LIVE_PACKAGE_UPDATES: '[{"pkg":"@aws-amplify/cli","type":"npm","version":"latest"}]' }, }; const log = logger('postPushCheck.amplifyClient.createApp', [createAppParams]);