Skip to content

AWS Multiple ENV drift issue

0

I have built a web application through aws amplify. i am having issue with my environments across the board. originally, when i set the envs they where working fine but at some point down line someone changed the git ignore file to ignore some files from the amplify folder... this started all my problems! After fixing this and setting the env correctly, it seemed to be working. however, after every merge from dev -> staging-> prod my environment didn't have the correct values and when it would deploy and i was constantly experiencing env drifts, even after fixing them. recently it got worse, our whole dev got overridden and all data was deleted. now we see that our production is missing the right cognito config. here is the error. "InvalidIdentityPoolConfigurationException: Invalid identity pool configuration. Check assigned IAM roles for this pool." what is required is i must restore the production config... however i am afraid to run any changes in my cli due to fact that i don't trust what is going on anymore... is there was way that some one can do this on the support side? Also, is there any safe guard I can add so that env drifting does not happen?

asked 2 years ago233 views

2 Answers
3

Try below to address your concerns and fix:

Restoring Production Configuration

  1. Backup Existing Configurations: Before making any changes, ensure you have backups of your current configurations, including the amplify folder and any related files.

  2. Manual Restoration: You can manually restore the production configuration by:

  • Reviewing the amplify/backend folder for the correct Cognito configuration files.
  • Using the amplify pull command to fetch the latest backend environment from the cloud.
  • Carefully updating the configuration files and pushing changes using amplify push.

Preventing Environment Drift

  1. Git Management:
  • Ensure that the .gitignore file includes all necessary files from the amplify folder to prevent accidental exclusions.
  • Use branch protection rules to prevent unauthorized changes to critical files.
  1. Environment Variables:
  • Use Amplify's environment variables feature to manage configuration settings securely.
  • Store sensitive data in AWS Systems Manager Parameter Store or Secrets Manager.
  1. Drift Detection:
  • Regularly use AWS CloudFormation's drift detection feature to identify and resolve discrepancies.
  • Treat the CloudFormation templates in the amplify/backend directory as the source of truth and avoid manual changes in the AWS Console.
  1. CI/CD Pipeline:
  • Implement a robust CI/CD pipeline to automate deployments and ensure consistency across environments.
  • Use Amplify's build settings to enforce environment-specific configurations.

Then, please carefully review the error message: "InvalidIdentityPoolConfigurationException: Invalid identity pool configuration." This suggests an issue with IAM roles assigned to the Cognito identity pool. Verify the roles and permissions in the AWS Management Console.

EXPERT

answered 2 years ago

0

Hey,

Hope you're keeping well.

In Amplify, environment drift usually happens when the amplify/backend folder and team-provider-info.json are not consistently committed and merged across branches. To safely restore production, use amplify pull --env prod from a clean clone of the repo to sync with the backend configuration stored in the Amplify service, and verify the Cognito identity pool and IAM roles in the AWS console under Amazon Cognito > Federated Identities. To prevent future drift, ensure these backend config files are never excluded in .gitignore and always merged carefully between environments.

Thanks and regards,
Taz

answered a year ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.