It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Bitbucket Pipelines Pipe: AWS CodeDeploy

Hi team, 

I have setup my bitbucket pipeline using "Bitbucket Pipelines Pipe: AWS CodeDeploy" but I am facing the

error " /pipe.sh: line 40: AWS_ACCESS_KEY_ID: AWS_ACCESS_KEY_ID variable missing."

Pipeline Script:-

==============

image: node:10.15.0pipelines:
  default:
    - step:
        name: Build
        script:
          - "apt-get update -y"
          - "cd admin/front-end/"
          - "npm install"
          - CI=false
          - "npm run build"
          - "apt-get install -y zip"
          - "zip -r /tmp/myapp.zip *"
        artifacts:
          - myapp.zip
    - step:
        name: Upload to S3
        script:
          - pipe: atlassian/aws-code-deploy:0.2.3
            variables:
              AWS_DEFAULT_REGION: 'ap-southeast-1'
              AWS_ACCESS_KEY_ID: $AKIAS2IMCQIEEY3AQA7Q
              AWS_SECRET_ACCESS_KEY: $2aRhX5cctbGyjNobEGV83cppuU9SzDJNtg2ILtdN
              COMMAND: 'upload'
              APPLICATION_NAME: 'SampleApplication'
              ZIP_FILE: 'myapp.zip'
              S3_BUCKET: 'codedeployap'
              VERSION_LABEL: 'my-app-1.0.0'    - step:
        name: Deploy with CodeDeploy
        script:
          - pipe: atlassian/aws-code-deploy:0.2.3
            variables:
              AWS_DEFAULT_REGION: 'ap-southeast-1'
              AWS_ACCESS_KEY_ID: $AKIAS2IMCQIEEY3AQA7Q
              AWS_SECRET_ACCESS_KEY: $2aRhX5cctbGyjNobEGV83cppuU9SzDJNtg2ILtdN
              COMMAND: 'deploy'
              APPLICATION_NAME: 'SampleApplication'
              DEPLOYMENT_GROUP: 'DG7'
              WAIT: 'true'
              S3_BUCKET: 'codedeployap'
              VERSION_LABEL: 'my-app-1.0.0'

 

Can any one please help me in this issue  ASAP.

 

I have followed the following link:-

https://confluence.atlassian.com/bitbucket/deploy-to-amazon-aws-875304040.html

and

https://hackernoon.com/deploy-to-ec2-with-aws-codedeploy-from-bitbucket-pipelines-4f403e96d50c

 

 

Regards,

Venkat

 

1 answer

0 votes

Hi @tech71 . You have a dollar sign in front of your keys. The pipe thinks that it's a reference to the environment variable. Removing the dollar sign will solve the issue. However, it's better to not hard code your keys in the bitbucket_pipelines.yml and user Pipelines variables to store them. Hope that helps

Hi Alexander Zhukov ,

Thanks for your reply, I tried without dollar sign in my script but i am getting following error can you please check and reply with solution and I have attached my scripts and screenshot of my error.

Pipeline Script:-

image: node:10.15.0

pipelines:
default:
- step:
name: Build
script:
- "apt-get update -y"
- "cd admin/front-end/"
- "npm install"
- CI=false
- "npm run build"
- "apt-get install -y zip"
- "zip -r /tmp/myapp.zip *"
artifacts:
- myapp.zip
- step:
name: Upload to S3
script:
- pipe: atlassian/aws-code-deploy:0.2.3
variables:
AWS_DEFAULT_REGION: 'ap-southeast-1'
AWS_ACCESS_KEY_ID: 'AKIAS2IMCQIEEY3AQA7Q'
AWS_SECRET_ACCESS_KEY: '2aRhX5cctbGyjNobEGV83cppuU9SzDJNtg2ILtdN'
COMMAND: 'upload'
APPLICATION_NAME: 'SampleApplication'
ZIP_FILE: 'myapp.zip'
S3_BUCKET: 'codedeployap'
VERSION_LABEL: 'my-app-1.0.0'
- step:
name: Deploy with CodeDeploy
script:
- pipe: atlassian/aws-code-deploy:0.2.3
variables:
AWS_DEFAULT_REGION: 'ap-southeast-1'
AWS_ACCESS_KEY_ID: 'AKIAS2IMCQIEEY3AQA7Q'
AWS_SECRET_ACCESS_KEY: '2aRhX5cctbGyjNobEGV83cppuU9SzDJNtg2ILtdN'
COMMAND: 'deploy'
APPLICATION_NAME: 'SampleApplication'
DEPLOYMENT_GROUP: 'DG7'
WAIT: 'true'
S3_BUCKET: 'codedeployap'
VERSION_LABEL: 'my-app-1.0.0'

========================================

Error :-

pipeline-error.png

 

Regards,

Venkat

9052325074

@tech71 , in your "Build" step you create a zip archive under the /tmp directory. However, artifacts paths are relative to the current working directory. You should instead create a zip file in the current working directory 

zip -r myapp.zip *

After that your myapp.zip will be available as an artifact for next steps. For more details you can refer to the docs for using artifacts .

Hi Alexander Zhukov ,

Thanks for your quick reply and  As per your instruction I have changed the  "zip -r myapp.zip *" but I am getting same error .

Please edit my code and reply back if possible .

Pipeline:-

image: node:10.15.0

pipelines:
default:
- step:
name: Build
script:
- apt-get update -y
- cd admin/front-end/
- npm install
- CI=false
- npm run build
- apt-get install -y zip
- zip -r myapp.zip *
artifacts:
- myapp.zip
- step:
name: Upload to S3
script:
- pipe: atlassian/aws-code-deploy:0.2.3
variables:
AWS_DEFAULT_REGION: 'ap-southeast-1'
AWS_ACCESS_KEY_ID: 'AKIAS2IMCQIEEY3AQA7Q'
AWS_SECRET_ACCESS_KEY: '2aRhX5cctbGyjNobEGV83cppuU9SzDJNtg2ILtdN'
COMMAND: 'upload'
APPLICATION_NAME: 'SampleApplication'
ZIP_FILE: 'myapp.zip'
S3_BUCKET: 'codedeployap'
VERSION_LABEL: 'my-app-1.0.0'

- step:
name: Deploy with CodeDeploy
script:
- pipe: atlassian/aws-code-deploy:0.2.3
variables:
AWS_DEFAULT_REGION: 'ap-southeast-1'
AWS_ACCESS_KEY_ID: 'AKIAS2IMCQIEEY3AQA7Q'
AWS_SECRET_ACCESS_KEY: '2aRhX5cctbGyjNobEGV83cppuU9SzDJNtg2ILtdN'
COMMAND: 'deploy'
APPLICATION_NAME: 'SampleApplication'
DEPLOYMENT_GROUP: 'DG7'
WAIT: 'true'
S3_BUCKET: 'codedeployap'
VERSION_LABEL: 'my-app-1.0.0'


Thanks and Regards,
Venkat,


Hi @tech71 . Since your building your app under the admin/front-end/ directory, your artifact will be stored under that directory, so you need to change your artifacts path:

artifacts:
- admin/front-end/myapp.zip

 You should also change the path to ZIP_FILE as well:

ZIP_FILE: 'admin/front-end/myapp.zip'

Hi Alexander Zhukov ,

Thanks for your quick reply , Actually earlier I was using AWS code deploy Plugin, where as it was working and i had two paths for deployment, one was for fron-end second was for back;-end. Now I am using this scripted pipeline as there AWS code deploy Plugin removed form Market-place-bit bucket side.

Now the now artifact is going to S3, but deployment is failed, my deployment path is /var/www/html.

but in script I didn't find any variables into it.

Can you please help me with this?

Capture0.PNGCapture01.PNGCapture02.PNG

Pipeline Script:-

image: node:10.15.0

pipelines:
default:
- step:
name: Build
script:
- apt-get update -y
- cd admin/front-end/
- npm install
- CI=false
- npm run build
- apt-get install -y zip
- zip -r myapp.zip *
artifacts:
- admin/front-end/myapp.zip

- step:
name: Upload to S3
script:
- pipe: atlassian/aws-code-deploy:0.2.3
variables:
AWS_DEFAULT_REGION: 'ap-southeast-1'
AWS_ACCESS_KEY_ID: 'AKIAS2IMCQIEEY3AQA7Q'
AWS_SECRET_ACCESS_KEY: '2aRhX5cctbGyjNobEGV83cppuU9SzDJNtg2ILtdN'
COMMAND: 'upload'
APPLICATION_NAME: 'SampleApplication'
ZIP_FILE: 'admin/front-end/myapp.zip'
S3_BUCKET: 'codedeployap'
VERSION_LABEL: 'my-app-1.0.0'

- step:
name: Deploy with CodeDeploy
script:
- pipe: atlassian/aws-code-deploy:0.2.3
variables:
AWS_DEFAULT_REGION: 'ap-southeast-1'
AWS_ACCESS_KEY_ID: 'AKIAS2IMCQIEEY3AQA7Q'
AWS_SECRET_ACCESS_KEY: '2aRhX5cctbGyjNobEGV83cppuU9SzDJNtg2ILtdN'
COMMAND: 'deploy'
APPLICATION_NAME: 'SampleApplication'
DEPLOYMENT_GROUP: 'DG7'
WAIT: 'true'
S3_BUCKET: 'codedeployap'
VERSION_LABEL: 'my-app-1.0.0'

Thank you

Venkat

I am getting error 

```
/pipe.sh: line 72: DEPLOYMENT_GROUP: DEPLOYMENT_GROUP variable missing.

```

 

Where do we find the deployment group?

@KuldeepY You'll find it in the Repository Settings > Repository Variables.

Suggest an answer

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

What We Learned When We Researched Open Source Vulnerabilities in 7 Popular Coding Languages

...hey are a part of us, shaping how we interact with the world around us. The same holds true for programming languages when we think about how different kinds of vulnerabilities raise their heads in t...

1,041 views 0 3
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