sid88in / serverless-appsync-plugin

serverless plugin for appsync
MIT License
951 stars 189 forks source link

[BUG] Custom region is NOT WORKING when using RELATIONAL_DATABASE Aurora Cluster #531

Open AILazerka opened 1 year ago

AILazerka commented 1 year ago

Hello.

There is a bug in building the Cloudformation definition of the RELATIONAL_DATABASE when using custom region.

Here is the code from the reference file below:

         resource.Properties.RelationalDatabaseConfig = {
          RdsHttpEndpointConfig: {
            AwsRegion: ds.config.region || config.region,
            DbClusterIdentifier: this.getDbClusterArn(
              Object.assign({}, ds.config, config),
            ),
            DatabaseName: ds.config.databaseName,
            Schema: ds.config.schema,
            AwsSecretStoreArn: ds.config.awsSecretStoreArn,
          },
          RelationalDatabaseSourceType:
            ds.config.relationalDatabaseSourceType || 'RDS_HTTP_ENDPOINT',
        };

This line will take the region defined in the dataSource configuration and overwrite it with the region set in the provider section in the serverless.yml: Object.assign({}, ds.config, config),

It should be the other way round so the region from the dataStore will have the priority.

Here is the reference to the file with code mentioned above: https://github.com/sid88in/serverless-appsync-plugin/blob/a2bb44a211ab23d725a8b21dae58564393d3ab9d/src/index.js#L1143