aws-amplify / aws-amplify/amplify-hosting
Backend Environment fails to initialise in pull only mode when Authentication category is configured with Third Party identity providers for the identity pool
- Dominant language
- Dockerfile
- Stars
- 481
- Forks
- 123
- PR merge metrics
- No merged PRs in 30d
Description
### Before opening, please confirm:
- [X] I have checked to see if my question is addressed in the [FAQ](https://github.com/aws-amplify/amplify-hosting/blob/master/FAQ.md).
- [X] I have [searched for duplicate or closed issues](https://github.com/aws-amplify/amplify-hosting/issues?q=is%3Aissue+).
- [X] I have read the guide for [submitting bug reports](https://github.com/aws-amplify/amplify-hosting/blob/master/CONTRIBUTING.md).
- [X] I have done my best to include a minimal, self-contained set of instructions for consistently reproducing the issue.
- [X] I have removed any sensitive information from my code snippets and submission.
### App Id
N/A
### AWS Region
us-east-1
### Amplify Hosting feature
Build settings
### Describe the bug
When connecting a backend environment to a frontend hosting environment in a pull only mode i.e. (AMPLIFY_BACKEND_PULL_ONLY as true) we face below error even though "AMPLIFY_GOOGLE_CLIENT_ID" and "AMPLIFY_GOOGLE_CLIENT_SECRET" environment variables are perfectly set.
"Amplify pull failed: auth headless is missing the following inputParams googleClientId"
### Expected behavior
Backend environment("Aws-exports.js" file to be specific) should be pulled without any issues.
### Reproduction steps
1. Create a sample react application as dummy front-end application and host it over Amplify.
2. Create a backend environment with third party auth. Please find entered CLI inputs below.
```
$ amplify add auth
Using service: Cognito, provided by: awscloudformation
The current configured provider is Amazon Cognito.
Do you want to use the default authentication and security configuration? Manual configuration
Select the authentication/authorization services that you want to use: User Sign-Up, Sign-In, connected with AWS IAM controls (Enables per-
user Storage features for images or other content, Analytics, and more)
Provide a friendly name for your resource that will be used to label this category in the project: ***************
Enter a name for your identity pool. ***************
Allow unauthenticated logins? (Provides scoped down permissions that you can control via AWS IAM) No
Do you want to enable 3rd party authentication providers in your identity pool? Yes
Select the third party identity providers you want to configure for your identity pool: Google
You've opted to allow users to authenticate via Google. If you haven't already, you'll need to go to https://developers.google.com/identity and create an App ID.
Enter your Google Web Client ID for your identity pool: test
Provide a name for your user pool: ***************
Warning: you will not be able to edit these selections.
How do you want users to be able to sign in? Username
Do you want to add User Pool Groups? No
Do you want to add an admin queries API? No
Multifactor authentication (MFA) user login options: OFF
Email based user registration/forgot password: Disabled (Uses SMS/TOTP as an alternative)
Please specify an SMS verification message: Your verification code is {####}
Do you want to override the default password policy for this User Pool? No
Warning: you will not be able to edit these selections.
What attributes are required for signing up? Email
Specify the app's refresh token expiration period (in days): 30
Do you want to specify the user attributes this app can read and write? No
Do you want to enable any of the following capabilities?
Do you want to use an OAuth flow? No
? Do you want to configure Lambda Triggers for Cognito? Yes
? Which triggers do you want to enable for Cognito
[WARNING] @aws-cdk/core.Lazy#anyValue is deprecated.
Use `Lazy.any()` or `Lazy.uncachedAny()` instead.
This API will be removed in the next major release.
✅ Successfully added auth resource *************** locally
✅ Some next steps:
"amplify push" will build all your local backend resources and provision it in the cloud
"amplify publish" will build all your local backend and frontend resources (if you have hosting category added) and provision it in the cloud
$ amplify push
```
3. Attach this backend with the frontend application with unchecked "Enable full-stack continuous deployments (CI/CD)"
4. During the Backend phase the issue will be observed.
### Build Settings
```yaml
version: 1
applications:
- frontend:
phases:
preBuild:
commands:
- npm ci
build:
commands:
- npm run build
artifacts:
baseDirectory: build
files:
- '**/*'
cache:
paths:
- node_modules/**/*
appRoot: apps/web
```
### Log output
```
# Put your logs below this line
## Checking for associated backend environment...
## Backend environment association found
2022-12-30T02:36:39.728Z [INFO]: ## Running amplify pull to generate aws-exports.js file for frontend
2022-12-30T02:36:42.006Z [INFO]: [0mAmplify AppID found: . Amplify App name is: [0m
2022-12-30T02:36:42.083Z [INFO]: [0mBackend environment dev found in Amplify Console app: [0m
2022-12-30T02:36:42.508Z [WARNING]: - Fetching updates to backend environment: dev from the cloud.
2022-12-30T02:36:42.989Z [WARNING]: - Building resource auth/
2022-12-30T02:36:43.046Z [WARNING]: [WARNING] @aws-cdk/core.Lazy#anyValue is deprecated.
Use `Lazy.any()` or `Lazy.uncachedAny()` instead.
This API will be removed in the next major release.
2022-12-30T02:36:43.130Z [WARNING]: - Building resource auth/userPoolGroups
2022-12-30T02:36:43.165Z [WARNING]: [WARNING] @aws-cdk/core.Lazy#anyValue is deprecated.
Use `Lazy.any()` or `Lazy.uncachedAny()` instead.
This API will be removed in the next major release.
2022-12-30T02:36:43.218Z [WARNING]: ✔ Successfully pulled backend environment dev from the cloud.
2022-12-30T02:36:43.227Z [WARNING]: ✖ There was an error initializing your environment.
2022-12-30T02:36:43.231Z [INFO]: 🛑 Could not initialize categories for 'dev': auth headless is missing the following inputParams googleClientId
2022-12-30T02:36:43.231Z [INFO]: Resolution: Review the error message and stack trace for additional information.
Learn more at: https://docs.amplify.aws/cli/project/troubleshooting/
2022-12-30T02:36:43.233Z [INFO]:
2022-12-30T02:36:43.233Z [INFO]: Session Identifier: f8c959b0-a0c2-4ddf-8db0-89531fb0b7f2
2022-12-30T02:36:43.290Z [ERROR]: !!! Build failed
2022-12-30T02:36:43.290Z [ERROR]: !!! Non-Zero Exit Code detected
2022-12-30T02:36:43.290Z [INFO]: # Starting environment caching...
2022-12-30T02:36:43.290Z [INFO]: # Uploading environment cache artifact...
2022-12-30T02:36:43.402Z [INFO]: # Uploaded environment cache artifact
2022-12-30T02:36:43.402Z [INFO]: # Environment caching completed
Terminating logging...
```
### Additional information
_No response_
Contributor guide
Research direction
Start with the Amplify pull step in the Backend phase and the auth headless initialization reported in the log. Reproduce the pull-only setup with a third-party Google identity provider and inspect how AMPLIFY_GOOGLE_CLIENT_ID and AMPLIFY_GOOGLE_CLIENT_SECRET are handled. Done means the backend initializes successfully and aws-exports.js is generated without the missing googleClientId error.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- aws, javascript, react
- Domain
- authentication, ci-cd, cloud
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100