Travis CI deploy: invalid option "--secret_access_key=" - amazon-web-services

I am building a Java web app with Travis CI and trying to deploy it to an AWS Elastic Beanstalk instance. The build goes well:
The command "mvn test -B" exited with 0.
... but the deploy fails and says:
Fetching: dpl-1.8.31.gem (100%)
Successfully installed dpl-1.8.31
1 gem installed
invalid option "--secret_access_key="
failed to deploy
my .travis.yml file seems to be valid and I have stored in it my encrypted secret access key for AWS using the travis CLI tool:
travis encrypt secret_access_key="< my secret access key >"
So why can't I deploy to AWS? why does Travis tell me invalid option "--secret_access_key="?
I have checked the Travis dpl docs for Elastic Beanstalk and they say the option for the key should be --secret-access-key=..., with dashes (instead of underscores like in invalid option "--secret_access_key=" from my Travis log).
How can I deploy my application?

I also encountered this issue and it was because the encrypted environment variable I used for secret_access_key: was spelled incorrectly. Most likely the value used here is wrong or non-existent and will produce this error.
secret_access_key: $ENCRYPTED_VAR_SPELLED_WRONG

Related

Errors when applying AWS eb commands

https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/create_deploy_nodejs_express.html
I'm trying to follow these steps to deploy an example of an Express application for the first time. After installing the Elastic Beanstalk Command Line Interface (EB CLI), I can apply eb commands in the Command Prompt (using Windows 10). After initializing a Git repository, I should use commands to configure an EB CLI repository.
These command are being applied in the directory of an an ExpressJS project:
First I enter the command: eb init – platform Node.js – region us-east-2 which results in the message in a separate window Application AWS2 has been created.
Next I enter command: eb create – sample node-express-env which results in the error message ERROR: InvalidParameterValueError - Environment node-express-env already exists.
Then when I enter the command: eb open the message says ERROR: This branch does not have a default environment. You must either specify an environment by typing "eb open my-env-name" or set a default environment by typing "eb use my-env-name".
Then when I enter: eb open node-express-env there's another message ERROR: NotFoundError - Environment "node-express-env" not Found. which contradicts the message from 2.
Make sure that, you configured the CLI to use the same region in which your environment is created.

How do i continue working with Amplify on a new machine?

I'm using react native for my project. On my old machine, when i ran amplify status, i had Auth, Api and Storage services listed.
I moved to my new machine, installed node, watchman, brew etc... and then navigated to my react native project and ran: react-native run-ios, and voila, my app is running. All the calls to my AWS Api, Auth and Storage are working perfectly.
Now i can make some amplify commands. Such as amplify status. I tried: amplify env add: here's what i got:
Users-MBP-2:projectname username$ amplify env add
Note: It is recommended to run this command from the root of your app directory
? Do you want to use an existing environment? Yes
? Choose the environment you would like to use: dev
Using default provider awscloudformation
✖ There was an error initializing your environment.
init failed
Error: ENOENT: no such file or directory, open '/Users/username/.aws/credentials'
at Object.openSync (fs.js:462:3)
at Proxy.readFileSync (fs.js:364:35)
at Object.readFileSync (/usr/local/lib/node_modules/#aws-amplify/cli/node_modules/aws-sdk/lib/util.js:95:26)
at IniLoader.parseFile (/usr/local/lib/node_modules/#aws-amplify/cli/node_modules/aws-sdk/lib/shared-ini/ini-loader.js:6:47)
at IniLoader.loadFrom (/usr/local/lib/node_modules/#aws-amplify/cli/node_modules/aws-sdk/lib/shared-ini/ini-loader.js:56:30)
at Config.region (/usr/local/lib/node_modules/#aws-amplify/cli/node_modules/aws-sdk/lib/node_loader.js:100:36)
at Config.set (/usr/local/lib/node_modules/#aws-amplify/cli/node_modules/aws-sdk/lib/config.js:507:39)
at Config.<anonymous> (/usr/local/lib/node_modules/#aws-amplify/cli/node_modules/aws-sdk/lib/config.js:342:12)
at Config.each (/usr/local/lib/node_modules/#aws-amplify/cli/node_modules/aws-sdk/lib/util.js:507:32)
at new Config (/usr/local/lib/node_modules/#aws-amplify/cli/node_modules/aws-sdk/lib/config.js:341:19) {
errno: -2,
syscall: 'open',
code: 'ENOENT',
path: '/Users/username/.aws/credentials'
}
Do you think credentials info needs to be brought/configured to my new machine?
When i run amplify configure project it's like doing an amplify init and building a project from scratch. I'm being asked:
? Enter a name for the project: ProjectName
? Choose your default editor: Visual Studio Code
? Choose the type of app that you're building javascript
Please tell us about your project
? What javascript framework are you using (Use arrow keys)
angular
ember
ionic
react
❯ react-native
vue
none
etc....
I also already have a region, username and accessKey, secretAccess key etc..
I do not want to replace or ruin anything in my current backend or current project! Whats going on?
Ensure amplify-cli is installed and you're logged in with your AWS details.
npm install -g #aws-amplify/cli
amplify configure
Running amplify configure is mainly to give the cli knowledge of your AWS account so subsequent commands can have access to things.
If you get amplify: command not found errors try restarting your terminal. If still no luck, you will need to check amplify has been added to your PATH variable.
Run amplify env add , but choose an existing environment. This will let you choose the environment you created on your other machine so you can pull those settings down to your new machine.
amplify env add
? Do you want to use an existing environment? Yes
Production
Follow up with:
amplify pull
You don't need to run amplify add auth again or anything. All of that will pull down automatically after you've done the above.
You DO NOT need to do all config again, but some for sure
You have to install amplify cli npm install -g #aws-amplify/cli
use amplify pull
https://docs.amplify.aws/cli/start#amplify-pull
Follow the rest of steps -
-- provide the accessKeyId, secretAccessKey
-- region
-- select amplify project
and then rest of app related thing like IDE, directory......
I tried every solution then I found this. (in MacBook)
% sudo -i
Password:
~ root# npm install -g #aws-amplify/cli
-- Ctrl+D to exist from Root user
% amplify pull --appId xxxx --envName yyyy.
Note: To get --appId xxxx --envName yyyy
Log in to the AWS console. Choose AWS Amplify. Click your app. Go to Backend
environments. Find the backend environment you wish to pull. Click
Edit backend. See top right then click 'Local setup instructions
' ( amplify pull --appId
YOUR_APP_ID --envName YOUR_ENV_NAME )
Waiting until it request to verify your amplify.
✔ Successfully received Amplify Studio tokens.
? Choose your default editor: Visual Studio Code
? Choose the type of app that you're building javascript
Please tell us about your project
? What javascript framework are you using react
? Source Directory Path: src
? Distribution Directory Path: build
? Build Command: npm run-script build
? Start Command: npm run-script start
✔ Synced UI components.
? Do you plan on modifying this backend? Yes
⠴ Building resource api/xxxx✅ GraphQL schema compiled successfully.
Edit your schema at ....
✔ Successfully pulled backend environment yyyy from the cloud.
✅
Successfully pulled backend environment staging from the cloud.
Run 'amplify pull' to sync future upstream changes.
% amplify pull
% npm install
% npm start
Hope this help every one!!
Happy Coding :)

amplify init fails on validation caused [$LATEST] inside 'stackName' value

I developing Vue project and have problem with amplify deployment console:
I configured an Amplify project with Cognito Id Pools (Google).
Added an environment 'dev' into the project located on the 'dev' git-branch. Successfully pushed to cloud.
Then using Amplify console created Deployment project based on Github. Checked the environment and branch, and other settings properly. And tried to deploy project
'Provision' stage passed successfully
'Build' failed
After searching info about problem with no result I deleted Amplify from my project locally and on the cloud, using 'amplify delete'. Cleared my git-project from amplify's files and folder. Did all create actions again and got same error:
ValidationError: 1 validation error detected: Value '2019/08/17/[$LATEST]84c0b31765d7431faf5d8f4b51322d03' at 'stackName' failed to satisfy constraint: Member must satisfy regular expression pattern: [a-zA-Z][-a-zA-Z0-9]|arn:[-a-zA-Z0-9:/._+]
Value: '2019/08/17/[$LATEST]84c0b31765d7431faf5d8f4b51322d03' is abnormal. And [$LATEST] looks like variable name, that copied directly instead of being interpreted.
I don't know what to do. And what is the reason of problem.
The problem was on version of Amplify module on the cloud is lower than my local version
My local amplify module version is 1.12.0.
Cloud's amplify version is 1.7.2.
After downgraded my local amplify version to 1.11.0 and recreated amplify project it works successfully.

AWS Elastic Beanstalk not deploying code fixes

I'm using aws EB to deploy my django app. I use the AWSEBCLI.
Everything works fine but if for some reason I mistakenly deploy broken code the ebcli will never deploy a new corrected version.
I'll have to SSH into the EC2 instance and fix it manually. Why? is there a way to force new code?
For example, I do some edits and I run git add . then git commit -m 'xx' then eb deploy
the result is:
TabError: inconsistent use of tabs and spaces in indentation.
container_command 01_migrate in .ebextensions/02_python.config failed.
For more detail, check /var/log/eb-activity.log using console or EB CLI.
INFO: Command execution completed on all instances. Summary: [Successful: 0, Failed: 1].
ERROR: Unsuccessful command execution on instance id(s) 'i-xxx'. Aborting the operation.
ERROR: Failed to deploy application.
At this point even if I edit the code, fix the indentation make the new git adds & commits eb will always show me this error until I SSH into the instance and I fix it manually.
Only then it will start to accept new commits. I really don't understand why and is rather annoying. Any ideas on how to skip the whole SSH part?

AWS Elastic Beanstalk - ERROR: No Application Version named 'v0_9_2-76-gf5a4' found

I'm trying to deploy my code to AWS Beanstalk and get this error. I researched that it could be that the number of versions is more than 500, so I deleted a lot of versions. But, I still get this error.
eb deploy
ERROR: No Application Version named 'v0_9_2-76-gf5a4' found.
I also tried
git aws.push
Error: Failed to create the AWS Elastic Beanstalk application version
Edit:
Trying with eb deploy --debug I now get:
Instance: i-2ad238d5 Module: AWSEBAutoScalingGroup ConfigSet: null Command failed on instance. Return code: 1 Output: Error occurred during build: Command hooks failed . Script /opt/elasticbeanstalk/hooks/appdeploy/pre/10_bundle_install.sh failed with returncode 18
ebcli.objects.exceptions.ServiceError: Update environment operation is
complete, but with errors. For more information, see troubleshooting
documentation.
Did you update the file .elasticbeanstalk/config.yml ? It may have a wrong setup.
Make a backup of .elasticbeanstalk/ folder and remove it
Execute eb create
Select the same region you deployed it before. You can check the region on .elasticbeanstalk/config.yml backup
A list with the environments will appear, select the right one
Deploy now
Remove the .elasticbeanstalk/config.yml backup
Check for the .elasticbeanstalk/config.yml file
environment: CORRECT_ENV_NAME
global:
application_name: CORRECT_APP_NAME
In my case, I was doing eb deploy X where X was an environment for a different project.
When I had the error
InvalidParameterValueError: No Application Version named 'app-9f5c-180927_071528' found.
I fixed this by specifying the label I wanted to push up.
eb deploy XXX-env -l XXX.0.0.1
The -l flag is documented AWS EB Deploy Docs
most likely, the deploy is trying an incorrect Elasticbeanstalk Application. it could be because you renamed the application in the AWS console.
so double check you're pointing to the correct elasticbeanstalk Environment and Application. it could be picking out default values from your .elasticbeanstalk/config.yml file.