I'm trying to configure a simple CI/CD flow using AWS and Bitbucket Pipelines, everything is working as should, but when the deployment to CodeDeploy comes in, it stops with an error message.
This is the diagram of my setup:
Build and push Docker Image to ECR(Ok) -> Deploy to ECS(Ok) -> Upload to AWS CodeDeploy(Ok) -> Deploy to AWS CodeDeploy(Fails)
As you can see, it's a pretty straightforward setup, so I think that this simplicity makes it a bit harder to understand where the problem can be.
Complete error message:
✖ Failed to fetch revision..
An error occurred (RevisionDoesNotExistException) when calling the GetApplicationRevision operation: No application revision was found for revision.
Error message with DEBUG enabled:
DEBUG: Response body:
b'{"__type":"RevisionDoesNotExistException","message":"No application revision found for revision."}'
DEBUG: Response headers: {'x-amzn-RequestId': '2bcb3131-aa53-4ce1-a84b-4c86059e9d12', 'Date': 'Sun, 03 Jul 2022 22:01:46 GMT', 'Content-Type': 'application/x-amz-json-1.1', 'Content-Length': '98'}
DEBUG: Response body:
b'{"__type":"RevisionDoesNotExistException","message":"No application revision found for revision."}'
DEBUG: Event needs-retry.codedeploy.GetApplicationRevision: calling handler <botocore.retryhandler.RetryHandler object at 0x7f2cfeef5040>
DEBUG: No retry needed.
The thing I've already tried:
- Review user permissions and services roles.
- Review all my variables, mostly to verify if everything was in the same region and things like that.
- Review S3 routes to verify that the files exist and where in the place that they should.
- Manually replicate the setup step by step using only the AWS Console. (With success)
- Use DEBUG inside the Upload script, It doesn't show anything helpful.
These are the Upload & Deploy section of my pipeline.yml
**Upload**
upload-to-codedeploy: &upload-to-codedeploy
name: Upload to AWS CodeDeploy
image: php:8.0-apache
script: # Test
- pipe: atlassian/aws-code-deploy:1.1.1
variables:
# Common Variables
AWS_ACCESS_KEY_ID: $AWS_ACCESS_KEY_ID # Optional if already defined in the context.
AWS_SECRET_ACCESS_KEY: $AWS_SECRET_ACCESS_KEY # Optional if already defined in the context.
AWS_DEFAULT_REGION: $AWS_DEFAULT_REGION # Optional if already defined in the context.
APPLICATION_NAME: 'dev-test-deploy'
COMMAND: 'upload' # 'upload' or 'deploy'.
S3_BUCKET: $S3_BUCKET
# Upload Variables
ZIP_FILE: 'appspec.zip'
BUNDLE_TYPE: 'zip'
FOLDER: 'pipeline'
VERSION_LABEL: $S3_BUCKET
DEBUG: 'true'
**Deploy**
deploy-to-codedeploy: &deploy-to-codedeploy
name: Deploy to AWS CodeDeploy
image: php:8.0-apache
script: # Test
- pipe: atlassian/aws-code-deploy:1.1.1
variables:
# Common Variables
AWS_ACCESS_KEY_ID: $AWS_ACCESS_KEY_ID # Optional if already defined in the context.
AWS_SECRET_ACCESS_KEY: $AWS_SECRET_ACCESS_KEY # Optional if already defined in the context.
AWS_DEFAULT_REGION: $AWS_DEFAULT_REGION # Optional if already defined in the context.
APPLICATION_NAME: 'dev-test-deploy'
S3_BUCKET: $S3_BUCKET
BUNDLE_TYPE: 'YAML'
WAIT: 'true'
# Upload Variables
ZIP_FILE: 'appspec.yaml'
# Deploy specific variables
DEPLOYMENT_GROUP: "dev-test-deploy-group"
#VERSION_LABEL: 'app-$(date +%Y-%m-%d)-1'
COMMAND: 'deploy' # 'upload' or 'deploy'.
IGNORE_APPLICATION_STOP_FAILURES: 'true'
FILE_EXISTS_BEHAVIOR: 'OVERWRITE'
FOLDER: 'pipeline'
VERSION_LABEL: $S3_BUCKET
DEBUG: 'true'
**appspec.yaml**
version: 0.0
Resources:
- TargetService:
Type: AWS::ECS::Service
Properties:
TaskDefinition: "arn:aws:ecs:us-east-1:891903962143:task-definition/cb-app-task"
LoadBalancerInfo:
ContainerName: "php-docker"
ContainerPort: 80
Any help would be welcome, thanks.