AWS Amplify subdomains with multiple config file

0

Hi,

I don't know if I can do this with AWS Amplify, but if not, I appreciate so much if you can tell me how can I do it on AWS.

I have a Flutter WebApp that is on Amplify with a subdomain : custom.example.com , but I need multiples subdomains that created from a config file, for example, a config file with two subdomains:

  • fake.example.com
  • example2.example.com

This config file has more configuration, but the core of the app is the same, it's like a remote config.

How can I do this with only one ramification that is main? I need because if a change something in main, I want to change in all subdomains.

Thank you so much.

asked 10 months ago344 views
1 Answer
0

To achieve multiple subdomains for your Flutter WebApp hosted on AWS Amplify and ensure changes made in the main app propagate to all subdomains, you can follow these steps:

Set up your initial Flutter WebApp on Amplify with the main subdomain: custom.example.com.

Create a configuration file that includes the subdomains and other app-specific configurations. You can use a format like JSON or YAML. For example, let's call it app_config.json:

{ "subdomains": [ "fake.example.com", "example2.example.com" ], "otherConfigurations": { // Include other configuration options as needed } }

Store the app_config.json file on a secure and accessible storage location, such as an S3 bucket on AWS.

Modify your Flutter WebApp to retrieve the app_config.json file dynamically during runtime. You can use HTTP requests or AWS SDKs (such as AWS Amplify Flutter) to fetch the file from the storage location.

Parse the app_config.json file and extract the subdomains and other configurations needed for your app.

Iterate through the subdomains obtained from the configuration file and programmatically configure the necessary DNS records to point them to your main Amplify deployment (custom.example.com). You can use a DNS service provider (e.g., Route 53) to manage DNS records programmatically through their API or SDK.

Once the DNS records are set up, users accessing the subdomains (fake.example.com, example2.example.com) will be directed to your main Amplify deployment.

To ensure changes made in the main app propagate to all subdomains, you can periodically check for updates in the app_config.json file. When an update is detected, fetch the updated file, reconfigure DNS records if necessary, and apply any other relevant changes in your Flutter WebApp.

By following this approach, you can maintain a single Amplify deployment for your main app while dynamically handling multiple subdomains based on the configuration file. Any changes made in the main app will automatically apply to all subdomains when the app_config.json file is updated and changes are detected during runtime.

profile picture
answered 10 months ago
  • Hi, thank you for your answer, the problem with that is the config for my domain, I need a differente config.json por every domain, for exmaple, I have multiple restaurants, and I need to show different menus in different subdomains, but is only that, the app is exactly the same but the config file is diferent.

    Can I do that?

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.

Guidelines for Answering Questions