Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Celebration

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root

Avatar

1 badge earned

Collect

Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!

Challenges
Coins

Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.

Recognition
Ribbon

Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!

Leaderboard

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,462,796
Community Members
 
Community Events
176
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

Atlassian Community Events