Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Geo] amplify add geo doesn't set region of Amazon Location Service in aws-exports.js using cli v.6.3.1 #8538

Closed
4 tasks done
DominicBortmes opened this issue Oct 25, 2021 · 3 comments
Assignees
Labels
bug Something isn't working geo Issues for the geo category

Comments

@DominicBortmes
Copy link

Before opening, please confirm:

  • I have installed the latest version of the Amplify CLI (see above), and confirmed that the issue still persists.
  • I have searched for duplicate or closed issues.
  • I have read the guide for submitting bug reports.
  • I have done my best to include a minimal, self-contained set of instructions for consistently reproducing the issue.

How did you install the Amplify CLI?

npm install -g @aws-amplify

If applicable, what version of Node.js are you using?

v16.11.1

Amplify CLI Version

6.3.1

What operating system are you using?

Amazon Linux 2 (Cloud9)

Amplify Categories

Not applicable

Amplify Commands

add

Describe the bug

amplify add geo created an aws-exports.js that does not include the project region into the geo settings of the amplify project. This breaks the rendering of any map (unless the map is explictly instantianted with the region parameter set) since API requests are sent against an in-existing region https://maps.geo.undefined.amazonaws.com/maps/v0/maps/.

/* eslint-disable */
// WARNING: DO NOT EDIT. This file is automatically generated by AWS Amplify. It will be overwritten.

const awsmobile = {
    "aws_project_region": "eu-west-1",
    "aws_cognito_identity_pool_id": "<redacted>",
    "aws_cognito_region": "eu-west-1",
    "aws_user_pools_id": "<redacted>",
    "aws_user_pools_web_client_id": "<redacted>",
    "oauth": {},
    "aws_cognito_login_mechanisms": [
        "PREFERRED_USERNAME"
    ],
    "aws_cognito_signup_attributes": [
        "EMAIL"
    ],
    "aws_cognito_mfa_configuration": "OFF",
    "aws_cognito_mfa_types": [
        "SMS"
    ],
    "aws_cognito_password_protection_settings": {
        "passwordPolicyMinLength": 8,
        "passwordPolicyCharacters": []
    },
    "aws_cognito_verification_mechanisms": [
        "EMAIL"
    ],
    "geo": {
        "AmazonLocationService": {
            "maps": {
                "items": {
                    "geo-test": {
                        "style": "VectorEsriStreets"
                    }
                },
                "default": "geo-test"
            },
            "region": "eu-west-1"
        }
    }
};


export default awsmobile;

The geo section lacks the documented region to be used of Amazon Location Services. Note that the region is setup correctly, since other configuration sections like auth take over the region correctly.

Note that there seem to be related bugs open that interfere with this issue. Issue-8405 of the amplify cli reports that the JSON keys of the geo settings section seem to be inconsistent across different versions, increasing the risk of unsuccessful config parsing.
Issue-57 of maplibre-gl-js-amplify points out that a missing default region for Amazon Location Service (in aws-exports.js's geo section) can break rendering of Maps. (When aws-exports.js does export a default AND devs don't set the region expliclty for every map initialized in JS.)

Expected behavior

amplify add geo should create a config that contains the project region and looks below. I verfied with an older version of amplify cli (6.2.1) that the region used to be passed through successfully.

{
    // ...
    "geo": {
        "AmazonLocationService": {
            maps: {...}, 
            search_indices: {...},
            region: REGION_OF_AMPLIFY_PROJECT
        }
    }
}

### Reproduction steps

### Reproduce issue with npm aws-amplify@6.3.1
1. install most recent amplify cli version (npm install -g @aws-amplify)
2. init an amplify project with `amplify init`
3. Add geo feature with defaults by executing `amplify add geo`
4. Generate `aws-exports.js` by pushing to cloud `amplify push`
5. Find that the generated `aws-exports.js` __does not set the the `region` key__ under .geo.AmazonLocationService.

### Proof that older version (aws-amplify@6.2.1) behaved as expected
This works with older amplify version v. 6.2.1 executing the same steps, i.e.
1a. npm rm -g @aws-amplify (clean up previously used version)
1b. install amplify cli  `npm install -g @aws-amplify/[email protected] `        
2. init an amplify project with `amplify init`
3. Add geo feature with defaults by executing `amplify add geo`
4. Generate `aws-exports.js` by pushing to cloud `amplify push`
5. Find that the generated `aws-exports.js`  __does set the the `region` key__ under .geo.AmazonLocationService as expected

### GraphQL schema(s)

-

### Log output

-

### Additional information

_No response_
@thaddmt thaddmt added the geo Issues for the geo category label Oct 25, 2021
@phani-srikar phani-srikar added the bug Something isn't working label Oct 25, 2021
@phani-srikar phani-srikar self-assigned this Oct 25, 2021
@phani-srikar
Copy link
Contributor

phani-srikar commented Oct 25, 2021

Hi @DominicBortmes. Thank you for creating this issue. I followed the steps you mentioned with Amplify CLI v6.3.1 but cannot reproduce the issue. I see that the region key exists in aws-exports after the push.
My exports file looks like this:

/* eslint-disable */
// WARNING: DO NOT EDIT. This file is automatically generated by AWS Amplify. It will be overwritten.

const awsmobile = {
    "aws_project_region": "eu-west-1",
    "aws_cognito_identity_pool_id": "<redacted>",
    "aws_cognito_region": "eu-west-1",
    "aws_user_pools_id": "<redacted>",
    "aws_user_pools_web_client_id": "<redacted>",
    "oauth": {},
    "aws_cognito_login_mechanisms": [
        "PREFERRED_USERNAME"
    ],
    "aws_cognito_signup_attributes": [
        "EMAIL"
    ],
    "aws_cognito_mfa_configuration": "OFF",
    "aws_cognito_mfa_types": [
        "SMS"
    ],
    "aws_cognito_password_protection_settings": {
        "passwordPolicyMinLength": 8,
        "passwordPolicyCharacters": []
    },
    "aws_cognito_verification_mechanisms": [
        "EMAIL"
    ],
    "geo": {
        "amazon_location_service": {
            "region": "eu-west-1",
            "maps": {
                "items": {
                    "mapcaee87cf-dev": {
                        "style": "VectorEsriStreets"
                    }
                },
                "default": "mapcaee87cf-dev"
            }
        }
    }
};


export default awsmobile;

After a bit of investigation, I was able to reproduce a similar behavior in an Amplify project with some Geo resources added using CLI v6.2.1 and some using v6.3.1. The fix will be released soon. Thanks again for bringing this to our attention.

@phani-srikar phani-srikar added pending-response Issue is pending response from the issue author and removed bug Something isn't working labels Oct 25, 2021
@phani-srikar phani-srikar added bug Something isn't working and removed pending-response Issue is pending response from the issue author labels Oct 26, 2021
@phani-srikar phani-srikar reopened this Nov 9, 2021
@phani-srikar
Copy link
Contributor

This has been fixed with amplify CLI v6.4.0. Please run amplify push --force after upgrading the Amplify CLI.

@github-actions
Copy link

This issue has been automatically locked since there hasn't been any recent activity after it was closed. Please open a new issue for related bugs.

Looking for a help forum? We recommend joining the Amplify Community Discord server *-help channels for those types of questions.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jan 12, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working geo Issues for the geo category
Projects
None yet
Development

No branches or pull requests

3 participants