Error CodeUnknownError
Script Name
Message: No such file or directory - /opt/codedeploy-agent/deployment-root/a449172f-ee92-4a07-b4eb-04c90047873b/d-URYKGM6UG/deployment-archive/appspec.yml
Log Tail
Can someone help me in figuring out what could be the issue?
It appears that your deployment has an error in the appspec.yml file, or the file is not at the root level of the archive.
Please double check the file location, and also check for typos, or invalid paths. Those types of problems can produce these errors.
version: 0.0
os: linux
files:
- source: /
destination: /var/www/html
permissions:
- object: /var/www/html
pattern: "**"
owner: apache
group: apache
mode: 755
type:
- file
hooks:
BeforeInstall:
- location: Scripts/installapache.sh
runas: root
- location: Scripts/startapache.sh
runas: root
AfterInstall:
- location: Scripts/restartapache.sh
runas: root
Related
When i run App.spec file for aws ECS blue green deployment the error is coming : "The deployment failed because the AppSpec file that specifies the deployment configuration is missing or has an invalid configuration. Failed to parse your appspec file. Please validate your appspec format and try again later." If anyone
knows about this error. Please let me know me.
Validate your AppSpec File
File syntax Validation:
you can use a browser-based tool such as YAML lint http://www.yamllint.com or an Online YAML parser http://yaml-online-parser.appspot.com to help you check your YAML syntax. Most of the time, it would solve your problem.
File Location validation:
Make sure to name your AppSpec File as appspec.yml, To verify that you have placed your AppSpec file in the root directory of the application's source content's directory structure, run one of the following commands:
On local Linux, macOS, or Unix instances:
ls path/to/root/directory/appspec.yml
If the AppSpec file is not located there, a "No such file or directory" error is displayed.
On local Windows instances:
dir path\to\root\directory\appspec.yml
If the AppSpec file is not located there, a "File Not Found" error is displayed.
AppSpec File example for an Amazon ECS deployment
Following is an example of an AppSpec file written in YAML for deploying an Amazon ECS service.
version: 0.0
Resources:
- TargetService:
Type: AWS::ECS::Service
Properties:
TaskDefinition: "arn:aws:ecs:us-east-1:111222333444:task-definition/my-task-definition-family-name:1"
LoadBalancerInfo:
ContainerName: "SampleApplicationName"
ContainerPort: 80
# Optional properties
PlatformVersion: "LATEST"
NetworkConfiguration:
AwsvpcConfiguration:
Subnets: ["subnet-1234abcd","subnet-5678abcd"]
SecurityGroups: ["sg-12345678"]
AssignPublicIp: "ENABLED"
CapacityProviderStrategy:
- Base: 1
CapacityProvider: "FARGATE_SPOT"
Weight: 2
- Base: 0
CapacityProvider: "FARGATE"
Weight: 1
Hooks:
- BeforeInstall: "LambdaFunctionToValidateBeforeInstall"
- AfterInstall: "LambdaFunctionToValidateAfterInstall"
- AfterAllowTestTraffic: "LambdaFunctionToValidateAfterTestTrafficStarts"
- BeforeAllowTraffic: "LambdaFunctionToValidateBeforeAllowingProductionTraffic"
- AfterAllowTraffic: "LambdaFunctionToValidateAfterAllowingProductionTraffic"
AppSpec File example for an Amazon EC2 deployment
See the hooks, which hooks are available and used to do what for a successful deployment.
version: 0.0
os: linux
files:
- source: /
destination: /var/www/html
file_exists_behavior: OVERWRITE
permissions:
- object: /var/www/html
pattern: "**"
owner: root
group: www-data
mode: 644 # gives read and write permissions to the owner of the object (6), read-only permissions to the group (4), and read-only permissions to all other users (4).
# acls:
# - u:deployer:rwx
type:
- file
- object: /var/www/html
pattern: "**"
owner: root
group: www-data
mode: 755 # sets the setuid attribute (4), gives full control permissions to the owner (7), gives read and execute permissions to the group (5), and gives read and execute permissions to all other users (5).
# acls:
# - u:deployer:rwx
type:
- directory
hooks:
BeforeBlockTraffic: # run tasks on instances before they are deregistered from a load balancer.
- location: ./devops/hooks/1_BeforeBlockTraffic.sh
timeout: 300
runas: deployer # we are running codedeploy as non-root user and only the root user has the ability to have runas "su" command without password authentication
# BlockTraffic: # can't be scripted
# - location: ./devops/hooks/2_BlockTraffic.sh
# timeout: 300
# # runas: deployer
AfterBlockTraffic: # run tasks on instances after they are deregistered from a load balancer.
- location: ./devops/hooks/3_AfterBlockTraffic.sh
timeout: 300
runas: deployer
ApplicationStop: # occurs even before the application revision is downloaded
- location: ./devops/hooks/4_ApplicationStop.sh
timeout: 300
runas: root
# DownloadBundle: # can't be scripted
# - location: ./devops/hooks/5_DownloadBundle.sh
# timeout: 300
# runas: deployer
BeforeInstall:
- location: ./devops/hooks/6_BeforeInstall.sh
timeout: 300
runas: root
# Install: # can't be scripted, copies the revision files from the temporary location to the final destination folder.
# - location: ./devops/hooks/7_Install.sh
# timeout: 300
# runas: deployer
AfterInstall:
- location: ./devops/hooks/8_AfterInstall.sh
timeout: 300
# runas: deployer
ApplicationStart:
- location: ./devops/hooks/9_ApplicationStart.sh
timeout: 300
runas: root
ValidateService:
- location: ./devops/hooks/10_ValidateService.sh
timeout: 300
runas: deployer
BeforeAllowTraffic: # run tasks on instances before they are registered with a load balancer.
- location: ./devops/hooks/11_BeforeAllowTraffic.sh
timeout: 300
# runas: deployer
# AllowTraffic: # can't be scripted
# - location: ./devops/hooks/12_AllowTraffic.sh
# timeout: 300
# # runas: deployer
AfterAllowTraffic: # run tasks on instances after they are registered with a load balancer.
- location: ./devops/hooks/13_AfterAllowTraffic.sh
timeout: 300
# runas: deployer
I have below requirement that I need to archive with the AWS code-deploy appspec.yml, I am confused about how to do this, As no matter how I try, the composer/vendor folder/files do not get 755. Any idea on how to solve this?
1. I want everything (files and folders) in /var/www/html to be owned by nginx AND have permission 644 including folders and files.
2. Except "vendor" folder and files inside some modules, so I want to search for the pattern of folder "vendor" and set it to 755.
My current appsepc.yml is like below
version: 0.0
os: linux
files:
- source: /apps
destination: /var/www/html/apps
- source: /core
destination: /var/www/html/core
permissions:
- object: /var/www/html/
pattern: "**"
except: [ "./var/*", "*/vendor/*" ]
owner: nginx
group: nginx
mode: 644
type:
- file
- object: /var/www/html/
pattern: "*/vendor/*"
owner: nginx
group: nginx
mode: 755
I have a Spring Boot Application with gradle as the dependency manager. I have been creating the war file using Export As war file. And have deployed the same in AWS ElasticBeanstalk. The platform I use is Tomcat 8.5 with Java 8 running on 64bit Amazon Linux/3.4.5
Now, I want to use CI/CD of AWS and want to create a Code Pipeline to deploy the war file to EBS.
While creating the Code-Pipeline, it asks me to build the Code Build Project.
Following is my build command :
version: 0.2
#env:
#variables:
# key: "value"
# key: "value"
#parameter-store:
# key: "value"
# key: "value"
#secrets-manager:
# key: secret-id:json-key:version-stage:version-id
# key: secret-id:json-key:version-stage:version-id
#exported-variables:
# - variable
# - variable
#git-credential-helper: yes
#batch:
#fast-fail: true
#build-list:
#build-matrix:
#build-graph:
phases:
#install:
#If you use the Ubuntu standard image 2.0 or later, you must specify runtime-versions.
#If you specify runtime-versions and use an image other than Ubuntu standard image 2.0, the build fails.
#runtime-versions:
# name: version
# name: version
#commands:
# - command
# - command
#pre_build:
#commands:
# - command
# - command
build:
commands:
- gradle build
# - command
#post_build:
#commands:
# - command
# - command
#reports:
#report-name-or-arn:
#files:
# - location
# - location
#base-directory: location
#discard-paths: yes
#file-format: JunitXml | CucumberJson
#artifacts:
#files:
# - location
# - location
#name: $(date +%Y-%m-%d)
#discard-paths: yes
#base-directory: location
#cache:
#paths:
# - paths
What changes do I make here, so that the war file is created and deployed to EBS. Since, I am pretty new to the Build Process and CI/CD, I am a bit confused.
My build.gradle file is :
plugins {
id 'org.springframework.boot' version '2.2.7.RELEASE'
id 'io.spring.dependency-management' version '1.0.9.RELEASE'
id 'java'
id 'war'
}
group = 'com.example'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = '1.8'
configurations {
compileOnly {
extendsFrom annotationProcessor
}
developmentOnly
runtimeClasspath {
extendsFrom developmentOnly
}
}
repositories {
mavenCentral()
}
dependencies {
implementation 'org.springframework.boot:spring-boot-starter-web'
annotationProcessor 'org.projectlombok:lombok'
providedRuntime 'org.springframework.boot:spring-boot-starter-tomcat'
//compile group: 'org.hibernate', name: 'hibernate-gradle-plugin', version: '5.4.15.Final'
compile group: 'org.springframework.boot', name: 'spring-boot-starter-data-jpa', version: '2.2.7.RELEASE'
compile group: 'mysql', name: 'mysql-connector-java', version: '8.0.20'
compile group: 'com.fasterxml.jackson.core', name: 'jackson-databind', version: '2.11.0'
compile group: 'io.jsonwebtoken', name: 'jjwt', version: '0.9.1'
compile group: 'org.springframework.boot', name: 'spring-boot-starter-mail', version: '2.3.0.RELEASE'
compile group: 'org.springframework.boot', name: 'spring-boot-starter-security', version: '2.3.0.RELEASE'
compile group: 'com.amazonaws', name: 'aws-java-sdk', version: '1.11.784'
providedCompile group: 'org.projectlombok', name: 'lombok', version: '0.11.0'
// https://mvnrepository.com/artifact/org.projectlombok/lombok
compileOnly group: 'org.projectlombok', name: 'lombok', version: '1.18.18'
compile group: 'com.google.code.gson', name: 'gson', version: '2.8.6'
compile group: 'org.apache.poi', name: 'poi-ooxml', version: '4.1.2'
compile group: 'org.apache.poi', name: 'poi', version: '4.1.2'
compile group: 'org.codehaus.mojo', name: 'exec-maven-plugin', version: '3.0.0'
compile group: 'com.googlecode.json-simple', name: 'json-simple', version: '1.1.1'
compile group: 'com.google.zxing', name: 'core', version: '3.4.1'
implementation group: 'org.apache.commons', name: 'commons-lang3', version: '3.12.0'
implementation group: 'com.google.common', name: 'google-collect', version: '0.5'
developmentOnly("org.springframework.boot:spring-boot-devtools")
//testImplementation 'org.springframework.security:spring-security-test'
}
test {
useJUnitPlatform()
}
I came across the same problem a few days ago and I hardly found any good resources for gradle. You can easily deploy your application directly to Elastic Beanstalk by uploading a WAR file generated during the gradle build.
When you upload your WAR file to Beanstalk, it gets extracted/exploded and Beanstalk does this for you internally. But when you use the pipeline, you need to upload the exploded files directly instead of the WAR. It seems that the AWS Codepipeline is still not WAR friendly.
First off, to generate an exploded WAR file, you need to add the following to your build.gradle:
task explodedWar(type: Sync) {
into "${buildDir}/exploded"
with war }
To generate the exploded folder, you need to run the following task through your terminal using the command:
./gradlew explodedWar
You will find a folder named exploded in the build folder where you will be able to see the contents of the exploded WAR.
Here is the following builspec.yml file you can use to build the code and deploy it using the pipeline. The environment used by me is Tomcat 8.5 with Corretto 8 running on 64bit Amazon Linux 2:
version: 0.1
phases:
install:
run-as: root
commands:
- echo Installing gradle
- wget https://services.gradle.org/distributions/gradle-7.1.1-bin.zip
- unzip -d /opt/gradle gradle-7.1.1-bin.zip
pre_build:
commands:
- echo Entering pre build
build:
commands:
- /opt/gradle/gradle-7.1.1/bin/gradle clean
- /opt/gradle/gradle-7.1.1/bin/gradle explodedWar
post_build:
commands:
- echo Entering post build
artifacts:
files:
- '**/*'
base-directory: build/exploded/
discard-paths: no
You can check the AWS buildspec.yml documentation for more syntax and features depending on your use case.
I am getting following error logs -
2019-05-15 11:51:20 default[20190515t114916] { [Error: ENOENT: no such file or
directory, stat '/srv/client/dist/client/index.html']
2019-05-15 11:51:20 default[20190515t114916] errno: -2,
2019-05-15 11:51:20 default[20190515t114916] code: 'ENOENT',
2019-05-15 11:51:20 default[20190515t114916] syscall: 'stat',
2019-05-15 11:51:20 default[20190515t114916] path: '/srv/client/dist/client/i
ndex.html',
while deploying an app built in Angular (version 1) and node js (version 10)
my app folder structure is as follows, in client folder I have angular js codes and in server folder I have node js -
app.yaml file looks like
runtime: nodejs10
and cloudbuild.yaml file is as -
steps:
#install
- name: 'gcr.io/cloud-builders/npm'
args: ['install']
#deploy
- name: 'gcr.io/cloud-builders/gcloud'
args: ['app', 'deploy']
I am newbie in google cloud and not sure how to configure yaml files. Can anyone help me please?
You should add ng build after the install step, and append something like this
in app.yaml
- url: /
static_files: dist/index.html
upload: dist/index.html
- url: /
static_dir: dist
the dist folder will be created by ng build
No matter what I put inside the stop_server file the CodeDeploy ends up with the error as above.
I even commented out all the lines to simplify debugging, so now it looks inside like this
#!/bin/bash
# pkill -f node
My appspec.yml:
version: 0.0
os: linux
files:
- source: /app.js
destination: /home/ec2-user/node-website
- source: /package.json
destination: /home/ec2-user/node-website
- source: /public/
destination: /home/ec2-user/node-website/public
- source: /node_modules
destination: /home/ec2-user/node-website/node_modules
permissions:
- object: /
pattern: "**"
owner: ec2-user
group: ec2-user
hooks:
AfterInstall:
- location: scripts/install_dependencies
timeout: 300
runas: ec2-user
#- location: scripts/codestar_remote_access
# timeout: 300
# runas: ec2-user
- location: scripts/start_server
timeout: 300
runas: ec2-user
ApplicationStop:
- location: scripts/stop_server
timeout: 300
runas: ec2-user
Any sugestions highly appreciated!
When you do a deployment, it will actually use the ApplicationStop from your last successful deployment, not your current deployment. I resolved the problem by deleting the application that I have problem with and creating a new one.
You can check the code-deploy logs to find more details, the logs is normally located in:
/opt/codedeploy-agent/deployment-root/deployment-logs/codedeploy-agent-deployments.log
Find more detailed error logs and let me know if you still cannot figure it out