AWS Codedeploy Wordpress deployment fails due to PHP version change in buildspec file - wordpress

I am running my Wordpress site hosted in AWS EC2 [Amazon Linux2 AMI].
I have a pipeline to deploy the latest source from Github.
The codebuild buildspec file is as follow: [Mentioned only related part]
version: 0.2
phases: install:
runtime-versions: php: 7.4
Codebuild project in cloudformation is like this:
Image: 'aws/codebuild/amazonlinux2-x86_64-standard:3.0'
Using above configuration, deployment is going without problem and problem happens when I update like below: [Mentioned only related part]
In cfn template:
Image: 'aws/codebuild/amazonlinux2-x86_64-standard:4.0'
In buildspec: runtime-versions: php: 8.1
Validation script in deployment hooks runs some validation commands to check RDS connection and it fails:
LifecycleEvent - ValidateService Script - deploy_hooks/validate_service.sh [stdout]OK SO FAR
[stderr]mysqlcheck: Got error: 1045: Access denied for user 'root'#'10.37.253.207' (using password: NO) when trying to connect
After deployment, I loginto the ec2 instance and below WP cli command fails as well:
$ wp db check
These above problems does not occur when I roll back to previous state of the PHP version.
In cfn template:
Image: 'aws/codebuild/amazonlinux2-x86_64-standard:3.0'
In buildspec:
runtime-versions: php: 7.4
What might be the problem ?
Reference:
https://docs.aws.amazon.com/codebuild/latest/userguide/build-env-ref-available.html
https://docs.aws.amazon.com/codebuild/latest/userguide/available-runtimes.html#linux-runtimes
** UPDATE:
Codedeploy is failing to deploy DB endpoint , password and other information in wp-config.php file when codedeploy is executed by codepipeline.
If I terminate the ec2 instance, the auto-scaling will launch a new instance for me and deployment is triggered by the codedeploy and the deployment is success. I can access the site.
Does it mean that executing Codedeploy through Codepipeline is the problem?

Related

Gitlab CI: Access private repository from CI pipeline fails

I try to set up a Gitlab CI configuration, which executes the unit tests of a symfony project. The same configuration works for an old project, but in my new one the command composer update fails. The error message says that it isn’t possible to clone our own bundle out of our Gitlab.
$ composer update
Loading composer repositories with package information
In Git.php line 471:
Failed to execute git clone --mirror -- ‘https://glp...XXX:private-token#gi
tlab.company.com/bundle/test-bundle.git’ ‘/tmp/cache/vcs/https---gitla
b.company.com-bundle-test-bundle.git/’
Cloning into bare repository ‘/tmp/cache/vcs/https---gitlab.company.com-bundle-test-bundle.git’...
fatal: unable to access ‘https://gitlab.company.com/bundle/test-bundle
.git/’: Failed to connect to gitlab.company.com port 443 after 0 ms: Conn
ection refused
At first I tried to use a personal access token in my .gitlab-ci.yaml but get the previous mentioned error.
test:
image: composer:latest
stage: test
before_script:
- composer config gitlab-token.gitlab.company.com $PERSONAL_CI_TOKEN
After that I tried the access by username/password.
echo "{\"http-basic\":{\"gitlab.company.com\":{\"username\":\"user\",\"password\":\"password\"}}}” > $HOME/.composer/auth.json
All the possibilities worked in my composer docker container and in my other project the access is still possible. I don't know how to solve this error.
Please check if you have added your self-hosted gitlab domain in your config in the composer.json file.
It should look like this:
"config": { "gitlab-domains": ["gitlab.company.com"] }

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

Symfony console output creates extra unwanted characters

i got this weird error, where every output in the console with symfony creates some extra characters. The following is the output after a basic symfony in the console.
$ symfony
←[32mSymfony CLI←[39m version ←[33mv4.22.0←[39m (c) 2017-2021 Symfony SAS
Symfony CLI helps developers manage projects, from local code to remote infrastructure
These are common commands used in various situations:
←[33mWork on a project locally←[39m
←[32mnew←[39m Create a new Symfony project
←[32mserve←[39m Run a local web server
←[32mserver:stop←[39m Stop the local web server
←[32msecurity:check←[39m Check security issues in project dependencies
←[32mcomposer←[39m Runs Composer without memory limit
←[32mconsole←[39m Runs the Symfony Console (bin/console) for current project
←[32mphp, pecl, pear, php-fpm, php-cgi, php-config, phpdbg, phpize←[39m Runs the named binary using the configured PHP version
←[33mManage a project on Cloud←[39m
←[32mlogin←[39m Log in with your SymfonyConnect account
←[32minit←[39m Initialize a new project using templates
←[32mlink←[39m Link current git repository to a SymfonyCloud project
←[32mprojects←[39m List active projects
←[32menvs←[39m List environments
←[32menv:create←[39m Create an environment
←[32mtunnel:open←[39m Open SSH tunnels to the app's services
←[32mssh←[39m Open an SSH connection to the app container
←[32mdeploy←[39m Deploy an environment
←[32mdomains←[39m List domains
←[32mvars←[39m List variables
←[32muser:add←[39m Add a user to the project
Show all commands with ←[32msymfony.exe help←[39m,
Get help for a specific command with ←[32msymfony.exe help COMMAND←[39m.
As you can see, I get this ←[33m here and there. Any help is gratefully accepted. Please let me know if you need any additional information from me.
$ bin/console --version
Symfony 5.2.1 (env: dev, debug: true)

Concourse unauthorized error pushing to Artifactory using docker-image-resource

I'm trying to use Concourse to grab a dockerfile defintion from a git repository, do some work, build the docker image, and push the new image to Artifactory. See below for the pipeline definition. At this time I have all stages up to the artifactory stage (the one that pushes to Artifactory) working. The artifactory stage exits with error with the following output:
waiting for docker to come up...
sha256:c6039bfb6ac572503c8d97f42b6a419b94139f37876ad331d03cb7c3e8811ff2
The push refers to repository [artifactory.server.com:2077/base/golang/alpine]
a4ab5bf94afd: Preparing
unauthorized: The client does not have permission to push to the repository.
This would seem straight-forward as an Artifactory permissions issue, except that I've tested locally with the docker cli and am able to push using the same user/pass as specified within destination_username and destination_password. I double checked the credentials to make sure I'm using the same ones and find that I am.
Question #1: is there any other known cause for getting this error? I've scoured the resource github page without finding anything. Any ideas why I may be getting the permissions error?
Without having an answer to the above question, I'd really like to dig deeper into troubleshooting the problem. To do so I use fly hijack to get a shell in the corresponding container. I notice that docker is installed on the container, so next step I think would be to do a docker import on the tarball for the image I'm trying to push and then perform a docker push to push it to the repo. When attempting to run the import I get the error:
Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is
the docker daemon running?
Question #2: Why can't I use docker commands from within the container? Perhaps this has something to do with the issue I'm seeing with pushing to repo when running the pipeline (I don't think so)? Is it because the container isn't running with privilege? I thought that the privileged argument would be supplied in the resource type definition, but if not, how can I run with privilege?
resources:
- name: image-repo
type: git
source:
branch: master
private_key: ((private_key))
uri: ssh://git#git-server/repo.git
- name: artifactory
type: docker-image
source:
repository: artifactory.server.com:2077/((repo))
tag: latest
username: ((destination_username))
password: ((destination_password))
jobs:
- name: update-image
plan:
- get: image-repo
- task: do-stuff
file: image-repo/scripts/do-stuff.yml
vars:
repository-directory: ((repo))
- task: build-image
privileged: true
file: image-repo/scripts/build-image.yml
- put: artifactory
params:
import_file: image/image.tar
Arghhhh. Found after much troubleshooting that the destination_password wasn't being picked up properly due to special characters and a lack of quotes. Fixed the issue by properly setting the password within yaml file being included with the --load-vars flag.

(Meteor) Mup deploy "read ECONNREST Error"

I don’t know what is going on.
I reinstalled my Computer and updated Meteor. I had some permission problems in a earlier problem I could fix that tho. Meteor is normally running if I don't want to deploy it. Deploying used to work just fine btw.
mup.cmd deploy --settings settings.json
Building App Bundle Locally
Started TaskList: Pushing Meteor App
[82.165.207.55] - Pushing Meteor App Bundle to the Server
[82.165.207.55] - Pushing Meteor App Bundle to the Server: SUCCESS
[82.165.207.55] - Prepare Bundle
[82.165.207.55] - Prepare Bundle: SUCCESS
Started TaskList: Configuring App
[82.165.207.55] - Pushing the Startup Script
[82.165.207.55] - Pushing the Startup Script: SUCCESS
[82.165.207.55] - Sending Environment Variables
[82.165.207.55] - Sending Environment Variables: SUCCESS
Started TaskList: Start Meteor
[82.165.207.55] - Start Meteor
events.js:183
throw er; // Unhandled ‘error’ event
^
Error: read ECONNRESET
at _errnoException (util.js:1022:11)
at TCP.onread (net.js:615:25)
What does that mean? I couldn’t find any solution for my problem online. Do you know what is wrong?
This error can happen if your IP address cannot SSH. Make sure your IP
hasn't changed, or change your rules/IP in the security groups of the
service you are using.
There was another case of this recently here mup setup : Error: Timed out while waiting for handshake
But I don't think he sorted it out. He has also reported it on the mup issues list
You can also enable debugging and set mup to be verbose like this:
DEBUG=mup* mup <command> --verbose
(docs at http://meteor-up.com/docs.html)

Resources