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

feat: storage import #5893

Merged
merged 3 commits into from
Nov 20, 2020
Merged

feat: storage import #5893

merged 3 commits into from
Nov 20, 2020

Conversation

attilah
Copy link
Contributor

@attilah attilah commented Nov 17, 2020

Description of changes:

Add import functionality to the CLI for S3 and DynamoDB resources via the amplify storage import command.

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@attilah attilah requested a review from yuth November 17, 2020 18:18
@codecov
Copy link

codecov bot commented Nov 17, 2020

Codecov Report

Merging #5893 (021bef6) into master (d6909f4) will increase coverage by 0.02%.
The diff coverage is 0.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #5893      +/-   ##
==========================================
+ Coverage   58.13%   58.16%   +0.02%     
==========================================
  Files         413      407       -6     
  Lines       18886    18746     -140     
  Branches     3573     3738     +165     
==========================================
- Hits        10980    10903      -77     
+ Misses       7244     7051     -193     
- Partials      662      792     +130     
Impacted Files Coverage Δ
packages/amplify-category-auth/src/index.js 9.90% <0.00%> (-0.41%) ⬇️
...c/provider-utils/awscloudformation/import/index.ts 5.11% <0.00%> (+0.10%) ⬆️
...auth/src/provider-utils/awscloudformation/index.js 5.78% <ø> (ø)
packages/amplify-cli-core/src/index.ts 100.00% <ø> (ø)
.../amplify-cli-core/src/state-manager/pathManager.ts 67.08% <0.00%> (-0.82%) ⬇️
packages/amplify-util-mock/src/api/api.ts 0.00% <0.00%> (ø)
packages/amplify-cli-core/src/errors/index.ts 100.00% <0.00%> (ø)
packages/amplify-cli-core/src/jsonUtilities.ts 100.00% <0.00%> (ø)
packages/graphql-mapping-template/src/print.ts 35.29% <0.00%> (ø)
... and 28 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update d6909f4...3ea61da. Read the comment docs.

@lgtm-com
Copy link

lgtm-com bot commented Nov 17, 2020

This pull request introduces 1 alert when merging e31160e into f3df233 - view on LGTM.com

new alerts:

  • 1 for Unused variable, import, function or class

Copy link
Contributor

@yuth yuth left a comment

Choose a reason for hiding this comment

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

Overall looks good!

): Promise<{ questionParameters: S3ImportParameters; answers: S3ImportAnswers } | undefined> => {
await ensureAuth(context);

let authResources = (await context.amplify.getResourceStatus('auth')).allResources.filter(
Copy link
Contributor

Choose a reason for hiding this comment

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

allResources also includes resources that will be deleted in the next push right. What do you think about filtering those

const amplifyMeta = stateManager.getMeta();
const { Region } = amplifyMeta.providers[providerName];

// Get list of user pools to see if there is anything to import
Copy link
Contributor

Choose a reason for hiding this comment

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

Copy/paste from auth

// Get list of user pools to see if there is anything to import
const bucketList = await s3.listBuckets();

// Return it no userpools found in the project's region
Copy link
Contributor

Choose a reason for hiding this comment

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

Same


const ensureAuth = async (context: $TSContext): Promise<void> => {
while (!checkIfAuthExists(context)) {
const addOrImportQuestion = {
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we expose this as a method in auth category so we dont have multiple places to maintain this


tableList = tableList.filter(t => !dynamoDBResources.includes(t));

// Return it no userpools found in the project's region
Copy link
Contributor

Choose a reason for hiding this comment

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

comment should be ddb

// const resourceName = resourceAlreadyExists(context);
const { amplify } = context;
const { amplifyMeta } = amplify.getProjectDetails();

const dynamoDbResources = {};

Object.keys(amplifyMeta[category]).forEach(resourceName => {
if (amplifyMeta[category][resourceName].service === serviceName && amplifyMeta[category][resourceName].mobileHubMigrated !== true) {
if (
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we need to print a more friendlier message when customer has imported or migrated table? When they do amplify status they would see the table but when they run update the error message says No resources to update. May be if we can metion that they also can't update imported resource that would make it clearer


const resource = _.get(context.exeInfo, ['amplifyMeta', category, resourceName]);

// Imported auth resource behavior is different from Amplify managed resources, as
Copy link
Contributor

Choose a reason for hiding this comment

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

Comment needs to be updated for storage


// check if this initialization is happening on a pull
if (isPulling && allResources.length > 0) {
tasks.push(...allResources);
Copy link
Contributor

Choose a reason for hiding this comment

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

Why push here and concat on the line above?

@ammarkarachi ammarkarachi merged commit ad7b028 into aws-amplify:master Nov 20, 2020
@lgtm-com
Copy link

lgtm-com bot commented Nov 20, 2020

This pull request introduces 3 alerts when merging 3ea61da into d6909f4 - view on LGTM.com

new alerts:

  • 3 for Unused variable, import, function or class

@github-actions
Copy link

This pull request has been automatically locked since there hasn't been any recent activity after it was closed. Please open a new issue for related bugs.

Looking for a help forum? We recommend joining the Amplify Community Discord server *-help channels for those types of questions.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 22, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants