Code deploy agent unable to find appspec.yml file - amazon-web-services

I am trying to perform CI/CD workflow on ec2 instance using aws codedeploy but I am getting below error at the time of deployment:
The CodeDeploy agent did not find an AppSpec file within the unpacked revision directory at
revision-relative path "appspec.yml".
How can I create appsepc.yml file in order to succeed deployment.As I doing it first time.Someone let me know.

Exact setup of appsepc.yml is use-case specific, and it has to be tailored to your application requirements. Thus you are the only one who can create it.
But AWS provides examples of such files:
AppSpec File example for an EC2/On-Premises deployment
aws-codedeploy-samples

appspec.yml file is what instructs the codedeploy agent on what are the steps to run on the EC2 instances. You can find the detailed structure and example provided by AWS

Related

How to deploy application to a new EC2 instance using existing AWS CodeDeploy Application and DeploymentGroup?

I'm getting the following error message on deployment failure although the zip file in the s3 bucket contains the appspec.yml in the app root directory.
The Code Deployment Application and Deployment Group along with the Jenkins job I'm working with were workable with an EC2 instance. What I tried to do is to deploy the application to a new EC2 instance which has the same IAM role.
In the Environment configuration section of the Code Deployment Group, I checked Amazon EC2 instances and added the EC2 instance name to where I wanted to deploy the application.
I am very beginner with Code Deployment and overall AWS services.
The CodeDeploy agent did not find an AppSpec file within the unpacked revision directory at revision-relative path "appspec.yml". The revision was unpacked to directory "/opt/codedeploy-agent/deployment-root/8517bbbb-ba13-4173-afe9-20f3fa628e35/d-G5E9NUM39/deployment-archive", and the AppSpec file was expected but not found at path "/opt/codedeploy-agent/deployment-root/8517bbbb-ba13-4173-afe9-20f3fa628e35/d-G5E9NUM39/deployment-archive/appspec.yml". Consult the AWS CodeDeploy Appspec documentation for more information at http://docs.aws.amazon.com/codedeploy/latest/userguide/reference-appspec-file.html
Also I checked the /opt/codedeploy-agent/deployment-root/8517bbbb-ba13-4173-afe9-20f3fa628e35 directory of the EC2 instance which doesn't have d-G5E9NUM39

AWS reference solution for a serverless SaaS system - Error: Template file not found - template.yml

I'm trying to deploy an AWS reference solution using AWS Cloud9, that demonstrates a sample SaaS system. The repo for the solution is here:
https://github.com/aws-samples/aws-saas-factory-ref-solution-serverless-saas/blob/main/DOCUMENTATION.md
There's a deployment file that can be run in order to bootstrap the example system in AWS - it's /aws-saas-factory-ref-solution-serverless-saas/deployment.sh within the repo.
Part of the deployment script builds bootstrap resources using the file /aws-saas-factory-ref-solution-serverless-saas/server/bootstrap-template.yaml, which is a CloudFormation template. The script then deploys bootstrap resources based on the configuration file /aws-saas-factory-ref-solution-serverless-saas/server/samconfig-bootstrap.toml
The relevant parts of ./deployment.sh that perform the build and bootstrap are as follows. The build and deployment utilise the AWS 'Serverless Application Model' (sam):
sam build -t bootstrap-template.yaml --use-container --region=$REGION
sam deploy --config-file samconfig-bootstrap.toml --region=$REGION --parameter-overrides AdminEmailParameter=$1
When I run the ./deployment.sh on a Cloud 9 instance on EC2 (in Singapore region), I get the following error during the common resource bootstrapping stage:
[11034] Failed to execute script main
sam deploy --config-file samconfig-bootstrap.toml --region=ap-southeast-1 --parameter-overrides AdminEmailParameter=chris.halcrow#elenium.com
Error: Template file not found at /home/ec2-user/environment/aws-saas-factory-ref-solution-serverless-saas/server/template.yml
I'm not seeing anything when I search the code for template.yml, so I'm not sure what's attempting to reference this. The file isn't present in the solution.
The guide here describes how to quickly set up an AWS Cloud9 environment running on an EC2 instance, into which the solution can be cloned from its Github repo in order to run the ./deployment.sh script - https://catalog.us-east-1.prod.workshops.aws/workshops/b0c6ad36-0a4b-45d8-856b-8a64f0ac76bb/en-US/pre-requisites/12-own-aws-account
After looking at the build-spec file (buildspec.yaml files are used to provide meta-data for CI/CD in AWS CodeBuild), it seems that the AWS team is testing the deployment using CI/CD Pipelines and forgot to update the shell script.
You on the other hand don't need to worry about the the build-spec file.
Solution
Go and just change template.yml to tenant-template.yaml
I found out that template.yml is an artifact that's normally produced during the build process - see SAM deploy command reference
sam deploy
By default when you use this command, the AWS SAM CLI assumes that
your current working directory is your project's root directory. The
AWS SAM CLI first tries to locate a template file built using the sam
build command, located in the .aws-sam subfolder, and named
template.yaml.
It seems that the template.yml wasn't being created due to insufficient memory size of the EC2 instance that Cloud9 was running in.
The solution for this was provided by #ujwalbukka in the following git issue, within the repo for the reference solution:
https://github.com/aws-samples/aws-saas-factory-ref-solution-serverless-saas/issues/19
To get the SaaS reference solution to run in Cloud9, I cloned an additional repo inside Cloud9 (the repo for the AWS workshop for the SaaS reference solution). I cloned this using git clone https://github.com/aws-samples/aws-serverless-saas-workshop.git
After cloning that repo, I ran through the steps here to run scripts that exist in the workshop repo, that increase the Cloud9 EC2 instance size and install the prerequisites for running the reference solution.

Unable to create deployment for ecs using aws cli (The deployment specifies that the revision is a null file, but the revision provided is a zip file)

I am trying to deploy (using Blue/Green deployment controller) a revision of my APIs. When i do this manually by creating an updated task revision and updating the service, this works fine. But when i try using the CLI, when i push the appspec.yml file to s3 i get a create-deployment command returned back. And when i try to trigger deployment using this command, the triggered deployment shows in the deployments section but is failed and the error i see is The deployment specifies that the revision is a null file, but the revision provided is a zip file. Please help.
I moved away from storing it as a zip file and stored as a normal json only and it worked for me.

"BundleType must be either YAML or Json" Error using Jenkins and AWS CodeDeploy

I am trying to deploy revisions to my AWS lambda functions using Jenkins and the AWS CodeDeploy add-on. I am able to build the project successfully and upload a zip of the project to an S3 bucket. At this point I receive the error:
BundleType must be either YAML or JSON
I have an appspec.yml file in my code directory. I am unsure if I need to instruct Jenkins to do something different, or if I need to instruct AWS to unzip the file and use it.
Today CodeDeploy lambda deployment only take in a YAML or JSON file as deployment revision input (which is just your AppSpec file). Today CodeDeploy Jenkins plugin needs to be updated to support uploading YAML or JSON file without zipping it: https://github.com/jenkinsci/aws-codedeploy-plugin/blob/master/src/main/java/com/amazonaws/codedeploy/AWSCodeDeployPublisher.java#L230

alternate appspec.yml location for AWS CodePipeline/CodeDeploy

i'm learning AWS-based continuous integration and have a basic CodeCommit → CodePipeline → CodeDeploy workflow setup per the tutorial. when i push to CodeCommit, CodePipeline triggers a build in CodeDeploy, however it does not find my appspec.yml manifest because it's not in the root of my repository.
how do i configure CodePipeline/CodeDeploy to look for appspec.yml under the subdirectory inst/aws/ instead of the repository root? i don't want to restructure my repo (which also has non-AWS content) just to accommodate a vendor-specific preference.
By default CodeDeploy agent looks at the root of your bundle for appspec.yml. Unfortunately you can't configure the location of the appspec.
You can do that with the use of AppSpecTemplatePath.
The file name of the AppSpec file stored in the pipeline source file
location, such as your pipeline's CodeCommit repository. The default
file name is appspec.yaml. If your AppSpec file has the same name and
is stored at the root level in your file repository, you do not need
to provide the file name. If the path is not the default, enter the
path and file name.
Source: https://docs.aws.amazon.com/codepipeline/latest/userguide/action-reference-ECSbluegreen.html#action-reference-ECSbluegreen-type