Bitbucket CI/CD pipeline - Deploy to AWS with Elastic Beanstalk

Rohit Pundlik December 18, 2019

I am trying to deploy web api on aws elastic beanstalk using bitbucker CI/CD pipeline. Below is the configuration for the same.

image: microsoft/dotnet:sdk

pipelines:
  default:
    - step:
        caches:
          - dotnetcore
        deployment: myapi-test1
        script: # Modify the comma`nds below to build your repository.
          - pipe: atlassian/aws-elasticbeanstalk-deploy:0.5.4
            variables:
              AWS_ACCESS_KEY_ID: '<access_key>'
              AWS_SECRET_ACCESS_KEY: '<secret_key>'
              AWS_DEFAULT_REGION: 'us-east-1'
              APPLICATION_NAME: 'myapi'
              ENVIRONMENT_NAME: 'test'
              ZIP_FILE: 'https://applicationxyz.s3.amazonaws.com/applicationxyz.zip'
              S3_BUCKET: 'myapplication' # Optional.
              # VERSION_LABEL: '<string>' # Optional.
              # DESCRIPTION: '<string>' # Optional.
              # WAIT: '<boolean>' # Optional.
              # WAIT_INTERVAL: '<integer>' # Optional.
              # COMMAND: '<string>' # Optional.
              # DEBUG: '<boolean>' # Optional.

 However, I am getting below error for the zip file.

NFO: The application source bundle doesn't have a known file extension (zip, jar or war). This might cause some issues. INFO: Uploading to s3 bucket: myapplication. The user-provided path https://applicationxyz.s3.amazonaws.com/applicationxyz.zip does not exist.

I am not sure why I am getting this error. Prior to this we are already deploying the web api manually on elastic beanstalk, so there are few zip files already available. So, I have even tried to use those, still the issue is not resolved.

Any help on this appreciated !

3 answers

0 votes
ktomk
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
December 20, 2019

Running the pipe should be independent to the  .Net core application.

So the job is just to create the ZIP and upload it.

Maybe it's a path issue. Please try with prefixing:

ZIP_FILE: '${BITBUCKET_CLONE_DIR}/application.zip'

 or

ZIP_FILE: '$BITBUCKET_CLONE_DIR/application.zip'

 

Rohit Pundlik December 20, 2019

So, Do I need to set any path to this variable? If yes, then which path I should set

ktomk
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
December 20, 2019

Well that was for what those two suggestions for, have you tried if any of them works? Maybe even both?

Or was the suggestion unclear and you didn't know where to copy the two suggestions in? It was just meant to have two alternatives so that you have something to try and test right away.

Rohit Pundlik January 9, 2020

Yes, its unclear to me and I dont know how to use the $BITBUCKET_CLONE_DIR.  I have tried to use it but didn't got any success.

I have tried number of times for CI/CD but no matter what its still not getting successfully executed. And, I don't know where I am going wrong.

The zip file doesn't contains the files which will be used to execute the application. Files like dll, .json file, project files etc.

Any help on this appreciated as I am looking for this from long time.

0 votes
Rohit Pundlik December 20, 2019

Hi @ktomk Thanks for the reply. Below are the details what I have tried and I am looking for.

The application which is I am trying to integrate with CI/CD is .net core web api application.

Till now we are deploying this manually on aws elastic beanstalk. The reason I asked here as I didn't find any good documentation OR link which will explain exact steps to be followed for .Net core application. 

As of now I have made some progress, which is resulting in beanstalk environment trying to deploy the application but with the errors. 

Below is the modified configuration as of now

image: atlassian/default-image:2

pipelines:
  default:
    - step:
        name: "Build and Test"
        script:
          - echo "Everything is awesome!"
          - apt-get update
          - apt-get install -y zip
          - zip -j application.zip MyApplication.WebAPI/*
          - pipe: atlassian/aws-elasticbeanstalk-deploy:0.2.3
            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: $APPLICATION_NAME
              COMMAND: 'upload-only'
              ZIP_FILE: 'application.zip'
              S3_BUCKET: 'bitbucketcicd'
              VERSION_LABEL: 'deployApi-$BITBUCKET_BUILD_NUMBER-multiple'
    - step:
        name: "Deploy to Test"
        deployment: test
        script:
        - echo "Deployment!"
        - pipe: atlassian/aws-elasticbeanstalk-deploy:0.2.3
          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: $APPLICATION_NAME
            COMMAND: 'deploy-only'
            VERSION_LABEL: 'deployApi-$BITBUCKET_BUILD_NUMBER-multiple'
            ENVIRONMENT_NAME: $ENVIRONMENT_NAME
            WAIT: 'true'

 

When any .net application is published to aws elastic beanstalk, publish files will be copied to s3 bucket, which are used by elastic beanstalk environment.

So, right now I am not able to understand how can i get the publish files and zip it into specific folder and upload on the s3.

Any help on this appreciated !

0 votes
ktomk
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
December 19, 2019

Hi @Rohit Pundlik, welcome to the Atlassian Community!

If I may ask, how could you resolve (if not please share your progress as you asked for it) Implementing CI/CD pipeline in bitbucket (asked two days ago). That entry still has not an answer so it's not so clear what happened there and it sounds tremendously related to what you ask here, so I think everyone here can't wait for a bit more of differentiation from your side. So please share!

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events