AWS : Amplify-Cli Crashing During initial setup - aws-amplify

I am always getting this error I tried uninstalling and reinstalling
Platform Windows 11
PS C:\path> amplify pull --appId xxxxx --envName dev
Opening link: https://ap-south-1.admin.amplifyapp.com/admin/xxx/dev/verify/?loginVersion=1
/ Confirm login in the browser or manually paste in your CLI login key:
√ Successfully received Amplify Studio tokens.
Amplify AppID found: xxxxxxx. Amplify App name is: xxxxxxxx
Backend environment dev found in Amplify Console app: xxxxxxx
? Choose your default editor: Visual Studio Code
? Choose the type of app that you're building (Use arrow keys)
at runMicrotasks (<anonymous>)
at processTicksAndRejections (internal/process/task_queues.js:95:5)
at async attachBackend (C:\snapshot\repo\build\node_modules\#aws-amplify\cli-internal\lib\attach-backend.js:44:9)
at async Object.run (C:\snapshot\repo\build\node_modules\#aws-amplify\cli-internal\lib\commands\pull.js:68:9)
at async Object.executeAmplifyCommand (C:\snapshot\repo\build\node_modules\#aws-amplify\cli-internal\lib\index.js:292:9)
at async executePluginModuleCommand (C:\snapshot\repo\build\node_modules\#aws-amplify\cli-internal\lib\execution-manager.js:142:5)
at async executeCommand (C:\snapshot\repo\build\node_modules\#aws-amplify\cli-internal\lib\execution-manager.js:40:9)
at async Object.run (C:\snapshot\repo\build\node_modules\#aws-amplify\cli-internal\lib\index.js:165:13)

Related

Github Probot create-probot-app: 'Cannot POST /' (404) response to webhook request

Testing out the npx create-probot-app; tried with each of the starters and the same problem exists.
I create, build, and run the app, and then configure and install the app on github, I am able to receive webhook events but I'm seeing my local app respond with a 404.
smee receives the event
error: Error: cannot POST / (404)
ERROR (server): Not Found
Error: Not Found
at Request.callback (/Users/X/Projects/Y/compiler/githubapp/x-bot/node_modules/superagent/lib/node/index.js:884:15)
at IncomingMessage.<anonymous> (/Users/X/Projects/Y/compiler/githubapp/x-bot/node_modules/superagent/lib/node/index.js:1127:20)
at IncomingMessage.emit (events.js:326:22)
at IncomingMessage.EventEmitter.emit (domain.js:483:12)
at endReadableNT (_stream_readable.js:1241:12)
at processTicksAndRejections (internal/process/task_queues.js:84:21)
status: 404
My index.ts:
export = (app: Probot) => {
app.on("issues.opened", async (context) => {
const issueComment = context.issue({
body: "Thanks for opening this issue!",
});
await context.octokit.issues.createComment(issueComment);
});
// For more information on building apps:
// https://probot.github.io/docs/
// To get your app running against GitHub, see:
// https://probot.github.io/docs/development/
};
I've checked that my environment variables appear to be setup correctly in .env
In sum, github is sending a webhook, smee is receiving it, but my local app is responding with 404: cannot post /
Not able to get the example app to process webhook events due to what appears to be a routing issue. Anyone encountered this before?
Make sure you don't have any other applications running on Port 3000. Create React App uses 3000 by default and can cause the error you are describing.
One of the possible reasons could be that your GitHub App does not have privileges to take that action. Would it be possible that your GitHub App is missing the 'issues' privilege setting? (https://docs.github.com/en/rest/reference/permissions-required-for-github-apps#permission-on-issues)

AWS Amplify build failing - Failed to get profile: Profile configuration is missing for: amplify

I have an AWS-Amplify project that had been building without a problem but is now failing.
# Starting phase: build
2021-11-20T00:40:02.506Z [INFO]: [31mFailed to get profile: Profile configuration is missing for: amplify[39m
2021-11-20T00:40:02.564Z [ERROR]: !!! Build failed
2021-11-20T00:40:02.564Z [ERROR]: !!! Non-Zero Exit Code detected
2021-11-20T00:40:02.564Z [INFO]: # Starting environment caching...
2021-11-20T00:40:02.565Z [INFO]: # Environment caching completed
Terminating logging...
The problem seemed to start after I made an error doing a pull request (in the wrong direction!), however, the problem has persisted despite reverting back to an earlier commit.
I have also ensured all the Amplify code is up to date amplify pull, as well as trying amplify configure and amplify init on my development machine.
Other posts that describe problems with 'Profile Configuration' seem to be related to the development machine and setting up the CLI. This failure is happening when I try to build on AWS using continuous deploys, building locally works fine.
so i got it to work.
Just delete the aws-exports.json and the amplify folder.
Then run the command from amplify which is something like:
amplify pull --appId XXXXXXXXXXX --envName dev
After a few mins, it will prompt you to select:
AWS PROFILE
AWS KEYS
select AWS KEYS
enter credentials for a programmatic user and it should be fine

GitlabCI: Failed to authenticate, have you run firebase login?

I followed this tutorial to deploy my web project using firebase and Gitlab CI.
I use this conf to deploy on firebase:
# .gitlab-ci.yml
deploy:
stage: deploy
environment: production
before_script:
- npm i -g firebase-tools
script:
- firebase deploy --token "$FIREBASE_TOKEN" -P "$PROJECT_NAME" --debug
only:
refs:
- master
changes:
- src/**/*
I stored the FIREBASE_TOKEN variable in my GitLab as protected and masked.
But when it's run in the pipeline it failed and return this error message:
$ firebase deploy --token "$FIREBASE_TOKEN" -P "$PROJECT_NAME" --debug
[2020-06-27T21:26:52.339Z] > command requires scopes: ["email","openid","https://www.googleapis.com/auth/cloudplatformprojects.readonly","https://www.googleapis.com/auth/firebase","https://www.googleapis.com/auth/cloud-platform"]
[2020-06-27T21:26:55.356Z] Error: Could not load the default credentials. Browse to https://cloud.google.com/docs/authentication/getting-started for more information.
at GoogleAuth.getApplicationDefaultAsync (/usr/local/lib/node_modules/firebase-tools/node_modules/google-auth-library/build/src/auth/googleauth.js:160:19)
at processTicksAndRejections (internal/process/task_queues.js:97:5)
at runNextTicks (internal/process/task_queues.js:66:3)
at listOnTimeout (internal/timers.js:518:9)
at processTimers (internal/timers.js:492:7)
at async GoogleAuth.getClient (/usr/local/lib/node_modules/firebase-tools/node_modules/google-auth-library/build/src/auth/googleauth.js:502:17)
at async GoogleAuth.getAccessToken (/usr/local/lib/node_modules/firebase-tools/node_modules/google-auth-library/build/src/auth/googleauth.js:524:24)
Error: Failed to authenticate, have you run firebase login?
ERROR: Job failed: exit code 1
I don't know why I get:
Failed to authenticate, have you run firebase login?
because I use a token to authenticate using the --token flag.
Have someone an idea why I get this error?
Ok so it was a dummy error. My variable $FIREBASE_TOKEN was not taken into account because I checked the Protect variable (Export variable to pipelines running on protected branches and tags only.) option. But I was working on a feature branch to test it that was not protected.
I encountered the same error, but through GitHub Actions. The solution was to run the command firebase init hosting:github locally, as indicated by the documentation at https://github.com/marketplace/actions/deploy-to-firebase-hosting. After signing in, this will set a GitHub Secret for you in your repository.
The following was taken from the above-mentioned documentation:
"It's important to store this token as an encrypted secret to prevent unintended access to your Firebase project. Set it in the "Secrets" area of your repository settings and add it as FIREBASE_SERVICE_ACCOUNT: https://github.com/USERNAME/REPOSITORY/settings/secrets. "

How do I put Firebase-Admin credentials in an Environment Variable?

I'm trying to setup a Firebase project on Codeship CI/CD and I cannot seem to get the service credentials JSON key to work with my project when it's stored in an environment variable.
MVCE
Dev environment startup script
export FIREBASE_CREDENTIAL=BASE64ENCODED_credentials_json
export DATABASE_URL=https://my-project.firebaseio.com
echo $FIREBASE_CREDENTIAL | base64 -D > FIREBASE_CREDENTIAL.json
npm start
index.ts
import * as admin from "firebase-admin";
const credentials = require("../FIREBASE_CREDENTIAL.json");
const databaseURL = process.env.DATABASE_URL;
console.log(credentials.project_id); // succeeds
console.log(databaseURL); // is correct
admin.initializeApp({
...credentials,
databaseURL,
databaseAuthVariableOverride: { uid: "scraper" }
});
admin
.database()
.ref("/test")
.set(admin.database.ServerValue.TIMESTAMP);
Codeship script
echo $FIREBASE_CREDENTIAL | base64 -di > FIREBASE_CREDENTIAL.json
nvm install 8
npm install
npm test
Results
On dev machine, the write succeeds as expected
On Codeship CI container, I get this error.
console.warn node_modules/#firebase/logger/dist/index.cjs.js:66
[2018-10-05T12:53:51.316Z] #firebase/database: FIREBASE WARNING: {"code":"app/invalid-credential","message":"Credential implementation provided to initializeApp() via the \"credential\" property failed to fetch a valid Google OAuth2 access token with the following error: \"Failed to parse access token response: Error: Error while making request: getaddrinfo ENOTFOUND metadata.google.internal metadata.google.internal:80. Error code: ENOTFOUND\"."}

Error opening database, Cordova Web Browser

I am creating a database for an application in ionic 2, and it fails where I create it:
this.sqlite.create({
name: 'details.db',
location: 'default'
}).then((db: SQLiteObject) => {
//... }
Error:
OPEN database: details.db
Error: exec proxy not found for :: SQLitePlugin :: close
Error: exec proxy not found for :: SQLitePlugin :: open
OPEN database: details.db FAILED, aborting any pending transactions
Error: Could not open database
at newSQLError (SQLitePlugin.js:25)
at SQLitePlugin.js:198
at Object.module.exports [as exec] (cordova.js:1006)
at SQLitePlugin.js:207
at Object.module.exports [as exec] (cordova.js:1006)
at SQLitePlugin.open (SQLitePlugin.js:210)
at new SQLitePlugin (SQLitePlugin.js:84)
at Object.<anonymous> (SQLitePlugin.js:600)
at Object.openDatabase (SQLitePlugin.js:58)
at index.js:176
I have added the Cordova functionalities via ionic cordova platform add browser.
I run the app liko so:
ionic cordova run browser
Does it mean that this cordova functionality(create database) is not available in a browser?
You cannot open database via Cordova Web Browser.
What you can do is use the Emulator for Android provided by Visual Studio.
This way the database will be accessible.
It seems that you'll have to use a mock to be able to use browser environment with SQlite. I will try this, too: https://medium.com/#tintin301/ionic-sqlite-storage-setting-up-for-browser-development-and-testing-67c0f17fc7af
Some people warned about this so I would recommend this other approach:
https://forum.ionicframework.com/t/ionic-native-sqlite-issue/87416/18

Resources