Ecosystem heterogeneity determines the ecological resilience of the Amazon to climate change