aws-amplify / amplify-category-api

The AWS Amplify CLI is a toolchain for simplifying serverless web and mobile development. This plugin provides functionality for the API category, allowing for the creation and management of GraphQL and REST based backends for your amplify project.
https://docs.amplify.aws/
Apache License 2.0
87 stars 75 forks source link

backfill script doesn't work after migration to transformer v2 #39

Open CodySwannGT opened 2 years ago

CodySwannGT commented 2 years ago

Before opening, please confirm:

How did you install the Amplify CLI?

npm

If applicable, what version of Node.js are you using?

No response

Amplify CLI Version

8.0.2

What operating system are you using?

Mac

Did you make any manual changes to the cloud resources managed by Amplify? Please describe the changes made.

No

Amplify Categories

Not applicable

Amplify Commands

Not applicable

Describe the bug

After upgrading to transformer v 2, we can no longer run the backfill script here: AWS.config.credentials

{'ResponseMetadata': {'RequestId': '9e18740d-87d1-40a1-8b47-20ed960851c3', 'HTTPStatusCode': 200, 'HTTPHeaders': {'date': 'Tue, 03 May 2022 00:49:48 GMT', 'content-type': 'application/json', 'content-length': '4', 'connection': 'keep-alive', 'x-amzn-requestid': '9e18740d-87d1-40a1-8b47-20ed960851c3', 'x-amzn-remapped-content-length': '0', 'x-amz-executed-version': '$LATEST', 'x-amzn-trace-id': 'root=1-62707c2a-7f25c8cb5368f0b93259c35a;sampled=0'}, 'RetryAttempts': 0}, 'StatusCode': 200, 'ExecutedVersion': '$LATEST', 'Payload': <botocore.response.StreamingBody object at 0x10377eb20>}
Traceback (most recent call last):
  File "/Users/cody/workspace/javascript/serverless/propswapv2/scripts/search/backfill.py", line 104, in <module>
    main()
  File "/Users/cody/workspace/javascript/serverless/propswapv2/scripts/search/backfill.py", line 42, in main
    import_dynamodb_items_to_es(args.tn, args.sk, args.ak, args.st, args.rn, args.esarn, args.lf, scan_limit)
  File "/Users/cody/workspace/javascript/serverless/propswapv2/scripts/search/backfill.py", line 65, in import_dynamodb_items_to_es
    response = table.scan(ExclusiveStartKey=response['LastEvaluatedKey'], Limit=scan_limit)
  File "/opt/homebrew/lib/python3.9/site-packages/boto3/resources/factory.py", line 520, in do_action
    response = action(self, *args, **kwargs)
  File "/opt/homebrew/lib/python3.9/site-packages/boto3/resources/action.py", line 83, in __call__
    response = getattr(parent.meta.client, operation_name)(*args, **params)
  File "/opt/homebrew/lib/python3.9/site-packages/botocore/client.py", line 391, in _api_call
    return self._make_api_call(operation_name, kwargs)
  File "/opt/homebrew/lib/python3.9/site-packages/botocore/client.py", line 708, in _make_api_call
    self.meta.events.emit(
  File "/opt/homebrew/lib/python3.9/site-packages/botocore/hooks.py", line 357, in emit
    return self._emitter.emit(aliased_event_name, **kwargs)
  File "/opt/homebrew/lib/python3.9/site-packages/botocore/hooks.py", line 228, in emit
    return self._emit(event_name, kwargs)
  File "/opt/homebrew/lib/python3.9/site-packages/botocore/hooks.py", line 211, in _emit
    response = handler(**kwargs)
  File "/opt/homebrew/lib/python3.9/site-packages/boto3/dynamodb/transform.py", line 202, in inject_attribute_value_output
    self._transformer.transform(
  File "/opt/homebrew/lib/python3.9/site-packages/boto3/dynamodb/transform.py", line 253, in transform
    self._transform_parameters(
  File "/opt/homebrew/lib/python3.9/site-packages/boto3/dynamodb/transform.py", line 260, in _transform_parameters
    getattr(self, '_transform_%s' % type_name)(
  File "/opt/homebrew/lib/python3.9/site-packages/boto3/dynamodb/transform.py", line 274, in _transform_structure
    self._transform_parameters(
  File "/opt/homebrew/lib/python3.9/site-packages/boto3/dynamodb/transform.py", line 260, in _transform_parameters
    getattr(self, '_transform_%s' % type_name)(
  File "/opt/homebrew/lib/python3.9/site-packages/boto3/dynamodb/transform.py", line 299, in _transform_list
    self._transform_parameters(
  File "/opt/homebrew/lib/python3.9/site-packages/boto3/dynamodb/transform.py", line 260, in _transform_parameters
    getattr(self, '_transform_%s' % type_name)(
  File "/opt/homebrew/lib/python3.9/site-packages/boto3/dynamodb/transform.py", line 285, in _transform_map
    params[key] = transformation(value)
  File "/opt/homebrew/lib/python3.9/site-packages/boto3/dynamodb/types.py", line 271, in deserialize
    return deserializer(value[dynamodb_type])
  File "/opt/homebrew/lib/python3.9/site-packages/boto3/dynamodb/types.py", line 301, in _deserialize_m
    return dict([(k, self.deserialize(v)) for k, v in value.items()])
  File "/opt/homebrew/lib/python3.9/site-packages/boto3/dynamodb/types.py", line 301, in <listcomp>
    return dict([(k, self.deserialize(v)) for k, v in value.items()])
  File "/opt/homebrew/lib/python3.9/site-packages/boto3/dynamodb/types.py", line 271, in deserialize
    return deserializer(value[dynamodb_type])
  File "/opt/homebrew/lib/python3.9/site-packages/boto3/dynamodb/types.py", line 280, in _deserialize_n
    return DYNAMODB_CONTEXT.create_decimal(value)
decimal.Rounded: [<class 'decimal.Rounded'>]

Expected behavior

The backfill script populates elastic search

Reproduction steps

  1. upgrade to transformer 2
  2. run the backfill script

GraphQL schema(s)

```graphql # Put schemas below this line ```

Log output

``` # Put your logs below this line ```

Additional information

No response

CodySwannGT commented 2 years ago

To clarify - I don't think this has to do with v2 per se, but when you migrate to v2, the migration process wipes out your elastic search domain and replaces it with opensearch, which requires that you then run the backfill script.

It's at this point that we get the error, which seems to be related to this however, we are getting the error on the table.scan

This is obviously a complete blocker for us

AnilMaktala commented 1 year ago

Hi @CodySwannGT, Are you still experiencing this issue?

CodySwannGT commented 1 year ago

@AnilMaktala not sure. We gave up on trying to migrate.