question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Switching ENVs does not clear #current-cloud-backend

See original GitHub issue

Note: If your issue/bug is regarding the AWS Amplify Console service, please log it in the Amplify Console GitHub Issue Tracker

Describe the bug

When a table with a @connection exists with this key already deployed:

type A @key(name: "ByBIdCId", fields: ["BId", "CId"], queryField: "AByBIdCId") {
   B: String @connection
   BId: String
   C: String @connection
   CId: String
}

And I try to deploy this

type A @key(name: "ByBIdCId", fields: ["BId", "CId"], queryField: "AByBIdCId")
            @key(name: "ByBId", fields: ["BId"], queryField: "AByBId") 

The CLI errors with Attempting to mutate more than 1 global secondary index at the same time

I can see in the /build/stacks/<table>.json that the GSIs have generated correctly in the Cloudformation.

Amplify CLI Version 4.28.2

To Reproduce Steps to reproduce the behavior or terminal output if applicable

Expected behavior The key/index would deploy; using the console I can create the index OK.

Screenshots CF Stack (truncated):

"GlobalSecondaryIndexes": [
                    {
                        "IndexName": "ByB",
                        "KeySchema": [
                            {
                                "AttributeName": "BiD",
                                "KeyType": "HASH"
                            }
                        ],
                        "Projection": {
                            "ProjectionType": "ALL"
                        },
                        "ProvisionedThroughput": {
                          
                        }
                    },
                    {
                        "IndexName": "ByBC",
                        "KeySchema": [
                            {
                                "AttributeName": "BiD",
                                "KeyType": "HASH"
                            },
                            {
                                "AttributeName": "CiD",
                                "KeyType": "RANGE"
                            }
                        ],
                        "Projection": {
                            "ProjectionType": "ALL"
                        },
                        "ProvisionedThroughput": {
                           
                        }
                    },
                    {
                        "IndexName": "gsi-B",
                        "KeySchema": [
                            {
                                "AttributeName": "",
                                "KeyType": "HASH"
                            }
                        ],
                        "Projection": {
                            "ProjectionType": "ALL"
                        },
                        "ProvisionedThroughput": {
                            
                        }
                    },
                    {
                        "IndexName": "gsi-C",
                        "KeySchema": [
                            {
                                "AttributeName": "",
                                "KeyType": "HASH"
                            }
                        ],
                        "Projection": {
                            "ProjectionType": "ALL"
                        },
                        "ProvisionedThroughput": {
                           
                        }
                    },
                    {
                        "IndexName": "gsi-D",
                        "KeySchema": [
                            {
                                "AttributeName": "",
                                "KeyType": "HASH"
                            }
                        ],
                        "Projection": {
                            "ProjectionType": "ALL"
                        },
                        "ProvisionedThroughput": {
                            
                        }
                    }
                ]

Desktop (please complete the following information):

  • OS: Windows 10
  • Node Version. 12.13.1

I tried with 2 different tables and both yielded the same result, whether adding the Primary/Sort index key before or after the Primary index key.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
dsypniewskicommented, Oct 1, 2020

If you are creating the new @key between other existing @keys this could be related to #5380 If that’s the case just add the key as the last one for given model instead of between and it should work.

0reactions
josefaidtcommented, Dec 21, 2022

Closing as this issue has since been resolved. Upon checking out or creating an environment the files in #current-cloud-backend are updated to reflect the target environment.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Team environments - Overview - AWS Amplify Docs
View the list of backend environments in your cloud project by visiting the Amplify Console.
Read more >
How to pull an existing app/environment FROM AWS Amplify ...
I am working on a shared project which has an Amplify backend environment hooked up (note, it's the production environment). To not affect...
Read more >
Use environment variables | Cloud Run Documentation
Caution: You should not use environment variables to store and consume ... If you are changing a value for a variable, replace the...
Read more >
AWS Amplify and Multiple Serverless Environments
This will set up another environment for the project in the cloud. The backend-configs and resources are now cloned from the 'master' ...
Read more >
How to manage multiple environments with Terraform using ...
You can switch to a different workspace using the terraform workspace ... Unfortunately, the backend block does not allow you to use any ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found