Fun with ambiguous errors
I was hoping that my first post here would be about the open source projects I've been working on, along with the fun side projects that keep my brain occupied outside of work
I'll get there soon, but I got distracted with what I can only describe as the most ambiguious error I've seen on AWS
'An App Spec file is required, but could not be found in the revision'
Creating a CodePipeline that uses the CodeDeploy controller for ECS is very well documented - However, the documentation focuses on achiveing it via the AWS UI
I had a case where we needed to generate the App Spec file within the CodeBuild Project and output it as an artifact
I got that all working - CodeBuild created an appspec.json
file, included it in the output artifact, then provided as an input source for the Deploy stage on CodePipeline
However ...
I first Googled the error ... Which made me believe that the name has to be appspec.yml
- with references to documentation [https://docs.aws.amazon.com/codedeploy/latest/userguide/reference-appspec-file-validate.html]
I then spent a long time adjusting the file name, and format, to yml
,yaml
,json
and just in case JSON
... 🤦
Still, got the same Error - 'An App Spec file is required, but could not be found in the revision'
It turns out, that this error is shown, for many many reasons ...
Even via aws cli, we get:
$ aws deploy get-deployment --deployment-id $DEPLOMENT_ID
"errorInformation": {
"code": "INVALID_REVISION",
"message": "An AppSpec file is required, but could not be found in the revision"
}
First important findings
- The App Spec file - It can be named Anything
- When provided to CodeDeploy within CodePipeline, it has to be the only file within the input artifact
- I could create an input artifact to CodeDeploy that included a file called
blah.json
, and it would work. However, If the input artifact included any other file, it will throw the error
All the mistakes I found that produce the same error:
- Invalid JSON/YML
CodeDeploy makes no attenpt to surface JSON/YML syntax errors - The App Spec
version
'requirement'
The documentation specifies it's required, and also that theversion
to be unquoted0.0
https://docs.aws.amazon.com/codedeploy/latest/userguide/reference-appspec-file-example.html#appspec-file-example-ecs
I found that theversion
does not need to be included ... Which would have been helpful before I spent a couple of hours trying to getjq
to treat floating point numbers as intergers ... which it doesn't ... - Integers as Strings
The App Spec I was creating, required theContainerPort
parameter
If it's80
- that's fine
If it's"80"
... Oops ... "An AppSpec file is required, but ...." - The App Spec assistant
https://github.com/aws-samples/aws-codedeploy-appspec-assistant
Even getting this to validate the App Spec file, doesn't mean it's going to work
Conclusion
- When creating a revison for CodeDeploy, ensure that
appspec.*
is the only file included in the revision - Ensure that the App Spec file is well formatted (Don't use the App Spec assistant), just dont include the
version
- After figuring out all of this, an 8 sided Rubix cube sounds like fun ...