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
89 stars 77 forks source link

@searchable can not be addded to the model #2223

Open biloshkurskyi-ss opened 9 months ago

biloshkurskyi-ss commented 9 months ago

How did you install the Amplify CLI?

npm

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

v21.6.1

Amplify CLI Version

12.10.1

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.

Do not remember exactly. Note: The environment was cloned from another one. No something special

Describe the bug

have a type Recorder @model @auth(rules: [...]) { { id: ID! firstName: String ... }

Add @searchable to it like: type Recorder @model @searchable ...

Expected behavior

@searchable should be added to the model

Reproduction steps

  1. Add @searchable to the model
  2. amplify push

Project Identifier

26019afdc69d49143fe99441bf73b9d3

Log output

``` Deployment failed. appname AWS::CloudFormation::Stack UPDATE_FAILED Thu Jan 25 2024 19:10:26… SearchableStack AWS::CloudFormation::Stack CREATE_FAILED Thu Jan 25 2024 19:10:08… ConnectionStack AWS::CloudFormation::Stack UPDATE_COMPLETE Thu Jan 25 2024 19:11:52 🛑 The following resources failed to deploy: Resource Name: OpenSearchDomain (AWS::Elasticsearch::Domain) Event Type: create Reason: Invalid instance type: t2.small.elasticsearch (Service: AWSElasticsearch; Status Code: 409; Error Code: InvalidTypeException; Request ID: fde79bcf-4aeb-4e7c-b8a9-14eba3e9a3aa; Proxy: null) 🛑 Resource is not in the state stackUpdateComplete Name: OpenSearchDomain (AWS::Elasticsearch::Domain), Event Type: create, Reason: Invalid instance type: t2.small.elasticsearch (Service: AWSElasticsearch; Status Code: 409; Error Code: InvalidTypeException; Request ID: fde79bcf-4aeb-4e7c-b8a9-14eba3e9a3aa; Proxy: null), IsCustomResource: false Session Identifier: 7060d53c-d34b-4803-aa0b-2832b0dd3f7c ```

Additional information

Checked on the little bit older amplify and node.js version after that do updated it to the latest and the issue is still the same.

Before submitting, please confirm:

phani-srikar commented 9 months ago

Hi @biloshkurskyi-ss, I am unable to replicate the issue on my end with the same CLI version 12.10.1. When I add searchable to a model and deploy, I'm able to deploy a cluster with t2.small.search instance type. Can you check your amplify/team-provider-info.json file and see if you have any overrides for instance type setup in your project? Doc link

biloshkurskyi-ss commented 9 months ago

Hello @phani-srikar,

Thank you for checking on your end.

Today I have tried to do a push and it still doesn't work.

Deployment failed.
api-app-name             AWS::CloudFormation::Stack     UPDATE_FAILED
SearchableStack                AWS::CloudFormation::Stack     CREATE_FAILED

I've reviewed the app settings in the team-provider-info.json file and noticed that the OpenSearchInstanceType parameter is missing. I was under the impression that it would be automatically added after implementing @searchable.

 dev": {
    "awscloudformation": {
      "AuthRoleName": "amplify-app-name-xxxx-dev-xxxxxxx-authRole",
      "UnauthRoleArn": "arn:aws:iam::XXXXXXXXXX:role/amplify-app-name-xxxx-dev-xxxxxxx-unauthRole",
      "AuthRoleArn": "arn:aws:iam::XXXXXXXXXX:role/amplify-app-name-xxxx-dev-xxxxxxx-authRole",
      "Region": "xx-xxxx-x",
      "DeploymentBucketName": "amplify-app-name-xxxx-dev-xxxxxxx-deployment",
      "UnauthRoleName": "amplify-app-name-xxxx-dev-xxxxxxx-unauthRole",
      "StackName": "amplify-app-name-xxxx-dev-xxxxxxx",
      "StackId": "arn:aws:cloudformation:xx-xxxx-x:XXXXXXXXXX:stack/amplify-app-name-xxxx-dev-xxxxxxx/xxxxx-xxxxx-xxxxx",
      "AmplifyAppId": "xxxxxxxxxx"
    },
    "categories": {
      "auth": {
        "app-name-xxxx": {}
      },
      "api": {
        "app-name-xxxx": {}
      },
      "storage": {
        "s3app-name-xxxxstoragexxxxxxx": {}
      }
    }
  }

What additional information or settings would be helpful for you to investigate this issue further?

Also, could you please check if the system logs have been shared? If they haven't been exported, could you guide me on how to do so? I assumed they would be automatically transferred with the Session Identifier or a similar method. Is there a way for me to manually push these logs?

The latest logs:

🛑 The following resources failed to deploy:
Resource Name: OpenSearchDomain (AWS::Elasticsearch::Domain)
Event Type: create
Reason: Invalid instance type: t2.small.elasticsearch (Service: AWSElasticsearch; Status Code: 409; Error Code: InvalidTypeException; Request ID: 7d16c53d-2458-49cb-8541-eb9b4e0637bf; Proxy: null)

🛑 Resource is not in the state stackUpdateComplete
Name: OpenSearchDomain (AWS::Elasticsearch::Domain), Event Type: create, Reason: Invalid instance type: t2.small.elasticsearch (Service: AWSElasticsearch; Status Code: 409; Error Code: InvalidTypeException; Request ID: 7d16c53d-2458-49cb-8541-eb9b4e0637bf; Proxy: null), IsCustomResource: false

Session Identifier: a18a3328-116e-4f25-9f64-3af675f66339
AnilMaktala commented 9 months ago

Hey @biloshkurskyi-ss, Thank you for checking and providing the team-provider-info file. Can you please confirm the region where you are deploying this app?

biloshkurskyi-ss commented 9 months ago

Hello @AnilMaktala the eu-north-1 region is used.

AnilMaktala commented 9 months ago

Hey @biloshkurskyi-ss, Appreciate your confirmation regarding the region. We've successfully replicated this issue in the 'eu-north-1' region, so we're flagging it as a bug for the team to investigate further.

image
AnilMaktala commented 9 months ago

@biloshkurskyi-ss, As a workaround, you can perform the following steps to switch the search instance type to t3.small.elasticsearch and inform us if it resolves your issue.

  1. Run amplify override api.
  2. Insert the following code snippet into \amplify\backend\api\<api name>\override.ts.
    
    import { AmplifyApiGraphQlResourceStackTemplate, AmplifyProjectInfo } from '@aws-amplify/cli-extensibility-helper';

export function override(resources: AmplifyApiGraphQlResourceStackTemplate, amplifyProjectInfo: AmplifyProjectInfo) { resources.opensearch.OpenSearchDomain.elasticsearchClusterConfig = { ...resources.opensearch.OpenSearchDomain.elasticsearchClusterConfig, instanceType: "t3.small.elasticsearch", };

}

biloshkurskyi-ss commented 5 months ago

Hello @AnilMaktala the workaround is working in dev and prod environments. Thanks for your help! 🤝