Skip to content

How to customize AWS Amplify Flutter endpoints to use LocalStack #6083

@Crackz

Description

@Crackz

Environment

  • Amplify Flutter Version: 2.2.0
  • Amplify Auth Cognito Version: 2.2.0
  • Flutter Version: 3.24.0
  • Dart Version: 3.5.0
  • Platform: Flutter Mobile App

Current Implementation

I'm currently using AWS Amplify in my Flutter application with the following plugins:

  • AmplifyAuthCognito for authentication

My initialization code looks like this:

Future<void> configureAmplify() async {
  try {
    final auth = AmplifyAuthCognito();
    await Amplify.addPlugins([auth]);
    await Amplify.configure(amplifyconfig);
  } on AmplifyAlreadyConfiguredException {
    logger.d('Amplify was already configured.');
  } catch (e) {
    logger.d('An error occurred configuring Amplify: $e');
  }
}

Question
For local development and testing, I want to redirect all AWS API calls from Amplify to LocalStack instead of the actual AWS services.

Is there a way to configure Amplify Flutter to use custom endpoints for auth specifically ?

I'm looking for a way to modify the amplifyconfig or use some other configuration method to point to my LocalStack instance running at http://localhost:4566 instead of the actual AWS Cognito endpoints.

Extra
it's supported by the js client

Amplify.configure({
  Auth: {
    Cognito: {
      // Lcoalstack configurations
      userPoolId: "eu-west-1_localUserPoolId",
      userPoolClientId: "userPoolClientId",
      userPoolEndpoint: "http://localhost:4566/eu-west-1_localUserPoolId", <- notice
      loginWith: {
        email: true,
      },
      signUpVerificationMethod: "code",
      userAttributes: {
        email: { required: true },
      },
    },
  },
});

Metadata

Metadata

Assignees

No one assigned

    Labels

    authIssues related to the Auth CategoryquestionA question about the Amplify Flutter libraries

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions