Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,293,591
Community Members
 
Community Events
165
Community Groups

having issue deploying .NET API to ec2 using CodeDeploy pipe with bitbucket pipeline

Edited

So i'm having this error when trying to deploy to ec2 instance  from S3 with bitbucket pipeline :

commuask.PNG

and  how pipeline looks like:

- step:
name: 'Deployment to S3 Bucket'
deployment: S3Bucket
trigger: 'automatic'
script:
- echo "Your deployment to S3 Bucket script goes here..."
- pipe: atlassian/aws-s3-deploy:1.1.0
variables:
AWS_ACCESS_KEY_ID: $AWS_ACCESS_KEY_ID
AWS_SECRET_ACCESS_KEY: $AWS_SECRET_ACCESS_KEY
AWS_DEFAULT_REGION: $AWS_DEFAULT_REGION
S3_BUCKET: 'webserver-for-weaplan-2/weaplanservicesV1'
LOCAL_PATH: '$(pwd)'

##---------------DEPLOYMENT-OF-DATAHANDLERAPI-TO-WEAPLAN-EC2-INSTANCE-------------##
- step:
name: Deploy DataHandlerAPI to EC2 instance
deployment: DH_EC2
trigger: 'automatic'
script:
- pipe: atlassian/aws-code-deploy:1.1.1
variables:
AWS_ACCESS_KEY_ID: $AWS_ACCESS_KEY_ID
AWS_SECRET_ACCESS_KEY: $AWS_SECRET_ACCESS_KEY
AWS_DEFAULT_REGION: $AWS_DEFAULT_REGION
APPLICATION_NAME: 'DataHandlerAPI'
COMMAND: 'deploy'

S3_BUCKET: 'webserver-for-weaplan-2/weaplanservicesV1'

DEPLOYMENT_GROUP: 'DataHandlerAPI-dg'



1 answer

0 votes
Patrik S Atlassian Team Jun 23, 2022

Hello @HassenLondon ,

Welcome to Atlassian Community!

The error being shown suggests the application name you are trying to deploy in the aws-code-deploy pipe does not match with any application name registered in your S3 bucket.

Also, I see you are uploading an entire directory to your S3 bucket, but the aws-code-deploy pipe only supports the deployment of files that are bundled in zip, tar, tgz, YAML or JSON. 

That said, I would suggest you try updating your YML file accordingly to the below example:

- step:

  name: "Upload to S3 and deploy

  script:

  - apt-get update && apt-get install zip

  - zip -r myapp.zip $(pwd)

  - pipe: atlassian/aws-code-deploy:1.1.1

    variables:

      AWS_DEFAULT_REGION: ${AWS_DEFAULT_REGION}

      AWS_ACCESS_KEY_ID: ${AWS_ACCESS_KEY_ID}

      AWS_SECRET_ACCESS_KEY: ${AWS_SECRET_ACCESS_KEY}

      COMMAND: 'upload'

      APPLICATION_NAME: 'DataHandlerAPI'

      ZIP_FILE: 'myapp.zip'

      S3_BUCKET: 'webserver-for-weaplan-2/weaplanservicesV1'

      VERSION_LABEL: 'DataHandlerAPI-${BITBUCKET_BUILD_NUMBER}-${BITBUCKET_COMMIT}'

  - pipe: atlassian/aws-code-deploy:1.1.1

    variables:

      AWS_DEFAULT_REGION: ${AWS_DEFAULT_REGION}

      AWS_ACCESS_KEY_ID: ${AWS_ACCESS_KEY_ID}

      AWS_SECRET_ACCESS_KEY: ${AWS_SECRET_ACCESS_KEY}

      COMMAND: 'deploy'

      APPLICATION_NAME: 'DataHandlerAPI'

      DEPLOYMENT_GROUP: 'DataHandlerAPI-dg'

      WAIT: 'true'

      S3_BUCKET: 'webserver-for-weaplan-2/weaplanservicesV1'

VERSION_LABEL: 'DataHandlerAPI-${BITBUCKET_BUILD_NUMBER}-${BITBUCKET_COMMIT}'

You can notice the pipe atlassian/aws-code-deploy can be used in 2 different modes: upload or deploy, which is controlled by the variable COMMAND, so we are executing the pipe twice to first upload to S3 and then deploy the uploaded zip file.

In the example above, we are first zipping the directory to a file called myapp.zip.

Then, in the first execution of atlassian/aws-code-deploy the zip file will be uploaded to S3 bucket defined in the variable S3_BUCKET, and assigned the label configured in VERSION_LABEL.

In the second execution of atlassian/aws-code-deploy we are deploying the previously uploaded zip file that matches the APPLICATION_NAME and VERSION_LABEL. It's important for the application name and version label to match between what was uploaded to S3 and what is being deployed, otherwise you will likely run into NotFound exceptions, like the one you reported.

You are also welcome to take a look at the atlassian/aws-code-deploy pipe official documentation, which can provide further details on how it works and how it is configured : 

Hope that helps! Let me know if you have any questions.

Thank you, @HassenLondon .

Kind regards,

Patrik S

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Published in Bitbucket

Git push size limits are coming to Bitbucket Cloud starting April 4th, 2022

Beginning on April 4th, we will be implementing push limits. This means that your push cannot be completed if it is over 3.5 GB. If you do attempt to complete a push that is over 3.5 GB, it will fail...

2,097 views 2 9
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you